Staging site (and staging DB): https://kozee-app-staging.fly.dev/
Outline of how to login as a user, start a game session, and complete pre-/post-pulse checks.
First, login to the API using the following endpoint:
POST /api/login
The request body (form-data) should include the following fields:
username: string
password: string
The response will be in this form:
{
"message": "login successful",
"twoFactorAuthEnabled": true,
"target": "USER_ID",
"status": 200
}
If twoFactorAuthEnabled
is true, that means the user has enabled 2FA and you will need to verify the user using the following endpoint:
POST /api/verify
The request body (form-data) should include the following fields:
code: string (the 2FA code the user received via email)
type: string (will be "2fa" in this case)
target: string (the user ID from the previous response)
Which, if successful, will return:
{
"status": 200
}
If the above is successful, the user will be authenticated and logged in.
To log out the user, use the following endpoint:
POST /api/logout
To display a user's game library, use the following endpoint:
GET /api/games
The response will be in this form:
{
"data": {
"recentlyPlayedGames": [
{
"id": "clrgmsost0cgwpn9160amvvuq",
"igdb_id": 270528,
"igdb_name": "Autumn's Bounty",
"users": [
{
"ownerId": "clrffwd14001ul7de2mk4v20f"
}
],
"banned": false,
"playable": {
"id": "cls8vzj780000ue13y8k084bm",
"createdAt": "2024-02-05T12:06:46.438Z",
"updatedAt": "2024-02-05T13:06:53.604Z",
"title": "AutumnsBountyWebGLv1.1.3",
"gameId": "clrgmsost0cgwpn9160amvvuq"
},
"totalPlayTime": 126,
"lastPlayed": "2024-02-26T17:37:39.011Z",
"cover": "//images.igdb.com/igdb/image/upload/t_thumb/co7705.jpg"
}
],
"gameCollection": [
{
"id": "clrgn4sh14vgxpn91im1ec8d8",
"igdb_id": 116753,
"igdb_name": "A Short Hike",
"users": [
{
"ownerId": "clrffwd14001ul7de2mk4v20f"
}
],
"banned": false,
"playable": null,
"totalPlayTime": 189,
"lastPlayed": "2024-01-26T11:57:14.339Z",
"cover": "//images.igdb.com/igdb/image/upload/t_thumb/co6e83.jpg"
},
{
"id": "clrgn578l51bopn91pmet2ixd",
"igdb_id": 113112,
"igdb_name": "Hades",
"users": [
{
"ownerId": "clrffwd14001ul7de2mk4v20f"
}
],
"banned": false,
"playable": null,
"totalPlayTime": 54,
"lastPlayed": "2024-02-09T21:22:59.341Z",
"cover": "//images.igdb.com/igdb/image/upload/t_thumb/co39vc.jpg"
},
{
"id": "clrgn5btn539qpn91gw92ev4o",
"igdb_id": 79995,
"igdb_name": "Sable",
"users": [
{
"ownerId": "clrffwd14001ul7de2mk4v20f"
}
],
"banned": false,
"playable": null,
"totalPlayTime": 87,
"lastPlayed": "2024-02-09T21:24:25.898Z",
"cover": "//images.igdb.com/igdb/image/upload/t_thumb/co3yzs.jpg"
}
]
}
}
To start a game session for a game, use the following endpoint:
POST /api/gaming-sessions
Pass the game ID via form-data:
gameId: string (e.g. "clrgn578l51bopn91pmet2ixd")
{
"success": true,
"data": {
"gamingSession": {
"id": "cltamh4ns0009c2cxwlt0ktha",
"createdAt": "2024-03-02T21:55:46.264Z",
"updatedAt": "2024-03-02T21:55:46.264Z",
"title": "Gaming Session - \"clrgmsost0cgwpn9160amvvuq\" - 3/2/2024",
"description": "",
"totalPlayTime": 0,
"ownerId": "clrffwd14001ul7de2mk4v20f",
"gameInCollectionId": "clrgmsost0cgwpn9160amvvuq",
"preSurveyId": null,
"postSurveyId": null
}
}
}
After creating a game session, create a survey (you will need to create two for each gaming session, a pre- and post-survey/pulse check). This will need to be connected to the game session created previously.
Surveys contain pulse check questions are associated with a game session.
When you start a game session
POST: /api/surveys?step=pre-survey or (or post-survey)
Pass the gaming session ID via form-data
gaming-session-id: string (e.g. "cltx8i3pq0009uv8pmt9bkoed")
Response:
{
"success": true,
"data": {
"survey": {
"id": "cltammh4t000bc2cx752rposy",
"createdAt": "2024-03-02T21:59:55.708Z",
"updatedAt": "2024-03-02T21:59:55.708Z",
"title": "",
"description": "",
"ownerId": "clrffwd14001ul7de2mk4v20f",
"overallSentiment": 0,
"pulseChecks": [
{
"id": "cltammh4u000cc2cx1ys8vh1p",
"createdAt": "2024-03-02T21:59:55.708Z",
"updatedAt": "2024-03-02T21:59:55.708Z",
"sentiment": 5,
"invert": false,
"question": "How do you feel mentally and emotionally now?",
"surveyId": "cltammh4t000bc2cx752rposy"
}
]
}
}
}
To update an existing survey, with the results of a pulse check, use the following endpoint:
POST: /api/surveys/:surveyId?step=pre-survey (or post-survey)
This endpoint should be called once to submit the results of the pre-gaming session pulse check. You will need to create a new survey for the post-gaming session pulse check and call this endpoint again with the new survey ID and the ?step=post-survey
query parameter.
If called with ?step=post-survey
, the total play time, player points (an unused feature right now), and weighted game keywords (weights for game tags are incremented/decremented based on overall sentiment, used for game recommendations) will be calculated and saved.
To submit the results of a pulse check, pass the result via form-data the overall sentiment of the pulse check (1-5):
overall-sentiment: number