This is a sample API for experimenting with the JSON:API format. It allows you to create an account so you can modify your own data.

Sign up for a free account. Then you can use the same username and password to log in to the API.

Contents

Logging In

You authenticate to the API with a modified version of the OAuth 2 password grant.

POST http://sandboxapi.bignerdranch.com/oauth/token

grant_type=password
username=you@yourodmain.com
password=yourpassword

The difference from normal OAuth 2 is that instead of receiving a token back in the response body, you'll receive it in a `Set-Cookie` header:

Set-Cookie: access_token=b027b3ed3873...; Path=/; HttpOnly; Secure

Accessing Data

All your requests should include the following header:
Content-Type=application/vnd.api+json
If you've correctly configured your HTTP client, they should also automatically send the access_token cookie that was set, even though the `HttpOnly` setting means it won't be accessible to JavaScript.

List Games

GET http://sandboxapi.bignerdranch.com/games
Response:
200 OK
{
    "data": [
        {
            "id": "1",
            "type": "games",
            "links": {
                "self": "http://sandboxapi.bignerdranch.com/games/1"
            },
            "attributes": {
                "title": "Final Fantasy 7",
            }
        }
    ]
}

Show Game

GET http://sandboxapi.bignerdranch.com/games/1
Response:
200 OK
{
    "data": {
        "id": "1",
        "type": "games",
        "links": {
            "self": "http://sandboxapi.bignerdranch.com/games/1"
        },
        "attributes": {
            "title": "Final Fantasy 7",
        }
    }
}

Create Game

Request
POST http://sandboxapi.bignerdranch.com/games
{
    "data": {
        "type": "games",
        "attributes": {
            "title": "Fallout 3",
        }
    }
}
Response
201 Created
{
    "data": {
        "id": "2",
        "type": "games",
        "links": {
            "self": "http://sandboxapi.bignerdranch.com/games/2"
        },
        "attributes": {
            "title": "Fallout 3",
        }
    }
}

Update Game

Request
PATCH http://sandboxapi.bignerdranch.com/games/1
{
    "data": {
        "id": "1",
        "type": "games",
        "attributes": {
            "title": "Fallout 4"
        }
    }
}
Response
200 OK
{
    "data": {
        "id": "1",
        "type": "games",
        "links": {
            "self": "http://sandboxapi.bignerdranch.com/games/1"
        },
        "attributes": {
            "title": "Fallout 4",
        }
    }
}

Delete Game

Request
DELETE http://sandboxapi.bignerdranch.com/games/1
Response
204 No Content

Learning More

About Sandbox API

This API is based on Reststate Sandbox API. Visit its GitHub page to learn more.