API Games
API endpoints for managing games hosted on Final Parsec. A game is the same object you create and manage through Game Hosting in the app. These endpoints let you do the same thing from a script or CI pipeline.
These endpoints require an API token. See API Authentication.
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
This endpoint allows you to create new games. A name is required.
An "anonymous game" will be created if an authentication token is not provided with the request. Anonymous games are shown without any association to a user profile. ANY user may claim anonymous games as their own or transfer the game assets to a game they own.
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
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
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
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}"
}
]
}
}