API Documentation

Use the Final Parsec API to manage your games.

Authentication

Include the API token for your user account in the authorization header when making requests. You can find this token in the "API Token" section of the Edit user account page.

Here's how to add the token to the request header using cURL:

Example request with bearer token

curl https://www.finalparsec.com/api/games \
  -H "Authorization: Token token={token}"

Tokens allow for actions to be performed on your behalf. Keep them private and do not publish them publicly.

You can regenerate your token if you suspect it has been compromised.

Only one token for your account is valid at a time.


Games

This represents a game hosted on Final Parsec.

The Game object

  • Name
    id
    Type
    integer
    Description

    Unique identifier for the game.

  • Name
    name
    Type
    string
    Description

    The game's name, meant to be displayed to the player.

  • Name
    assets
    Type
    array
    Description

    The assets required to make the game playable. Typically includes wasm, pck, js, and similar files. Assets have a filename and base64 encoded content.


Create a game

POST /api/games

This endpoint allows you to create new games. A name is required.

Request - just a game with a name

curl -X POST https://www.finalparsec.com/api/games \
  -H "Authorization: Token token={token}" \
  -H "Content-Type: application/json" \
  -d '{ "game": { "name": "Hello World" } }'

Optionally, a collection of assets can be included to make your game immediately playable.

See the Final-Parsec/publish-game GitHub Action if you are interested in performing this step as part of a workflow.

Request with chonky json payload in distinct file

curl -X POST https://www.finalparsec.com/api/games \
  -H "Authorization: Token token={token}" \
  -H "Content-Type: application/json" \
  -d @payload.json

payload.json - bundle metadata and assets here before upload

{
  "game": {
    "name": "My Game",
    "assets": [
      {
        "filename": "my_game.pck",
        "data": "data:application/octet-stream;base64,{encoded_asset_data_here}"
      },
      {
        "filename": "my_game.wasm",
        "data": "data:application/octet-stream;base64,{encoded_asset_data_here}"
      }
    ]
  }
}

List your games

GET /api/games

This endpoint allows you to retrieve a list of games you have uploaded.

Game assets are not included in this response.

Request

curl https://www.finalparsec.com/api/games \
  -H "Authorization: Token token={token}"

Response

{
  "games": [
    {
      "id": 1,
      "name": "Aurora TD"
    },
    {
      "id": 11,
      "name": "Office Sim"
    }
  ]
}

Update a game

PATCH /api/games/{id}

This endpoint allows for partial updates of existing games.

Send a payload similar to creating a game, but include the unique ID for the game to update in the URL.

Attributes which are not included in the payload will remain unmodified.

Request - renaming a game

curl -X PATCH https://www.finalparsec.com/api/games/{id} \
  -H "Authorization: Token token={token}" \
  -H "Content-Type: application/json" \
  -d '{ "game": { "name": "Updated Game Name" } }'

Get a game

GET /api/games/{id}

This endpoint allows you to retrieve a single game.

Game assets are included in this response.

Request

curl https://www.finalparsec.com/api/games/{id} \
  -H "Authorization: Token token={token}"

Response

{
  "game": {
    "id": 1,
    "name": "Aurora TD",
    "assets": [
      {
        "filename": "my_game.pck",
        "data": "data:application/octet-stream;base64,{encoded_asset_data_here}"
      },
      {
        "filename": "my_game.wasm",
        "data": "data:application/octet-stream;base64,{encoded_asset_data_here}"
      }
    ]
  }
}