9 API
Paul Black edited this page 2024-07-01 04:53:36 +00:00

API Endpoints

/add-game

Type: POST

Used to add a game to the DB. Requires authentication (config.app.password).

Expects to receive a json body with the following information, name, publishedLink, year, state, education, level, place, name1, name2

name is the name of the game.
publishedLink is the published link of the game https://example.com/.
year is the year the competitor competed.
state is what state the competitor is from.
education is whether they competed in Secondary or Post-secondary.
level is the highest level the competitor's game reached. Either State or National.
place is what the competitor placed in their competition.
name1 is the name of team member 1.
name2 is the name of team member 2.

Note: currently this endpoint doesn't support uploading an image directly! Use /upload/image. Here's an example.

/games

Type: GET

Used for fetching a current list of games from the DB. Returns a json body. Here's an example or you can use the production API to view the json directly here.

/upload-image/{ID-OF-GAME}

Type: POST

This call requires authentication (config.app.password).

This endpoint expects to receive a file, using the ID of the game. This will then put the file in ~/game-images on the server-side. With how SkillsGames is setup, the API and the front-end are on 2 different servers, so a Python script watches for changes in that directory and copies it over to the other server hosting the front-end. This will not automatically rename the file, you are expected to handle that separately. You may use the json of the /add-game endpoint to fetch the ID and then send it over to this endpoint in your application.