Challenge with Friends is a multiplayer game in which players compete to finish the most challenges to earn points and score high on the leaderboard. This is only the backend portion of the project which has contributions from Lucy Beck, Travis Zhang, and Tanay Menezes.
GET /api/players/
Response:
{
"success": true,
"data": [
{
"id": 1,
"name": "test name",
"username": "test username",
"points": 0,
"current challenges": [ <SERIALIZED CHALLENGE>, ... ],
"completed challenges": [ <SERIALIZED CHALLENGE>, ... ],
"groups": [ <SERIALIZED GROUP>, ... ],
"authored_challenges": [ <SERIALIZED CHALLENGE>, ... ],
"image": {
"url": <URL HERE>,
"created_at": <DATETIME STRING HERE>,
"challenge_id": null,
"player_id": 1
}
},
{
"id": 2,
"name": "test name 2",
"username": "user2",
"points": 0,
"current challenges": [ <SERIALIZED CHALLENGE>, ... ],
"completed challenges": [ <SERIALIZED CHALLENGE>, ... ],
"groups": [ <SERIALIZED GROUP>, ... ],
"authored_challenges": [ <SERIALIZED CHALLENGE>, ... ],
"image": {
"url": <URL HERE>,
"created_at": <DATETIME STRING HERE>,
"challenge_id": null,
"player_id": 2
}
}
...
]
}
In this route, challenge_id
in the image branch will be null
because the image is associated with the player and not the challenge.
GET /api/players/{player_id}/
Response:
{
"success": true,
"data": {
"id": 1,
"username": "test username",
"points": 0,
"current challenges": [ <SERIALIZED CHALLENGE>, ... ],
"completed challenges": [ <SERIALIZED CHALLENGE>, ... ],
"groups": [ <SERIALIZED GROUP>, ... ],
"authored_challenges": [ <SERIALIZED CHALLENGE>, ... ],
"image": {
"url": <URL HERE>,
"created_at": <DATETIME STRING HERE>,
"challenge_id": null,
"player_id": 1
}
}
}
In this route, challenge_id
in the image branch will be null
because the image is associated with the player and not the challenge.
DELETE /api/players/{player_id}/
Response: No Response if successful
GET /api/players/{player_username}/
Response:
{
"success": true,
"data": {
"id": 1,
"username": "test username",
"points": 0,
"current challenges": [ <SERIALIZED CHALLENGE>, ... ],
"completed challenges": [ <SERIALIZED CHALLENGE>, ... ],
"groups": [ <SERIALIZED GROUP>, ... ],
"authored_challenges": [ <SERIALIZED CHALLENGE>, ... ],
"image": {
"url": <URL HERE>,
"created_at": <DATETIME STRING HERE>,
"challenge_id": null,
"player_id": 1
}
}
}
In this route, challenge_id
in the image branch will be null
because the image is associated with the challenge and not the player.
POST /api/players/
Allowable files: .png
, .jpeg
, .jpe
, .jpg
, .gif
Request:
{
"username": <USER INPUT>,
"password": <USER INPUT>,
"image_data": <USER INPUT (HAS TO BE BASE64 ENCODED)>
}
Response:
{
"success": true,
"data": {
"id": 1,
"username": "test username",
"points": 0,
"current challenges": [ ],
"completed challenges": [ ],
"groups": [ ],
"authored_challenges": [ ],
"image": {
"url": <URL HERE>,
"created_at": <DATETIME STRING HERE>,
"challenge_id": null,
"player_id": 1
}
}
}
In this route, challenge_id
in the image branch will be null
because the image is associated with the player and not the challenge.
POST /api/login/
Request:
{
"username": <USER INPUT>,
"password": <USER INPUT>
}
Response:
{
"success": true,
"data": {
"id": 1,
"username": "test username",
"points": 0,
"current challenges": [ ],
"completed challenges": [ ],
"groups": [ ],
"authored_challenges": [ ],
"image": {
"url": <URL HERE>,
"created_at": <DATETIME STRING HERE>,
"challenge_id": null,
"player_id": 1
}
}
}
In this route, challenge_id
in the image branch will be null
because the image is associated with the challenge and not the player.
GET /api/players/<int:player_id>/challenges/
Response:
{
"success": true,
"data": [
{
"id": 1,
"title": "test title",
"description": "test description",
"claimed": true,
"completed": false,
"author_username": "user1",
"author_id": 1,
"group_id": 1,
"player": [<SERIALIZED PLAYER> ],
"image": null
},
{
"id": 2,
"title": "test title",
"description": "test description",
"claimed": true,
"completed": false,
"author_username": "user1",
"author_id": 1,
"group_id": 1,
"player": [<SERIALIZED PLAYER> ],
"image": null
}
...
]
}
GET /api/challenges/
Response:
{
"success": true,
"data": [
{
"id": 1,
"title": "test title",
"description": "test description",
"claimed": false,
"completed": false,
"author_username": "user1",
"author_id": 1,
"group_id": 1,
"player": [ ],
"image": <CAN BE NULL OR SERIALIZED IMAGE>
},
{
"id": 2,
"title": "test title",
"description": "test description",
"claimed": true,
"completed": true,
"author_username": "user1",
"author_id": 1,
"group_id": 1,
"player": [<SERIALIZED PLAYER> ],
"image": <CAN BE NULL OR SERIALIZED IMAGE>
}
...
]
}
GET /api/challenges/unclaimed/
Response:
{
"success": true,
"data": [
{
"id": 1,
"title": "test title",
"description": "test description",
"claimed": false,
"completed": false,
"author_username": "user1",
"author_id": 1,
"group_id": 1,
"player": [ ],
"image": null
},
{
"id": 2,
"title": "test title",
"description": "test description",
"claimed": false,
"completed": false,
"author_username": "user1",
"author_id": 1,
"group_id": 1,
"player": [ ],
"image": null
}
...
]
}
image
is null because it has not been completed yet.
GET /api/challenges/completed/
Response:
{
"success": true,
"data": [
{
"id": 1,
"title": "test title",
"description": "test description",
"claimed": true,
"completed": true,
"author_username": "user1",
"author_id": 1,
"group_id": 1,
"player": [ <SERIALIZED PLAYER>],
"image": [ <SERIALIZED IMAGE> ]
},
{
"id": 2,
"title": "test title 2",
"description": "test description 2",
"claimed": true,
"completed": true,
"author_username": "user2",
"author_id": 2,
"group_id": 3,
"player": [<SERIALIZED PLAYER> ],
"image": [ <SERIALIZED IMAGE> ]
}
...
]
}
GET /api/challenges/{challenge_id}/
Response:
{
"success": true,
"data": {
"id": 1,
"title": "test title",
"description": "test description",
"claimed": false,
"completed": false,
"author_username": "user1",
"author_id": 1,
"group_id": 1,
"player": [ <SERIALIZED PLAYER>],
"image": <CAN BE NULL OR SERIALIZED IMAGE>
}
}
GET /api/challenges/{challenge_id}/group/
Response:
{
"success": true,
"data": {
"group_id": 1
}
}
DELETE /api/challenges/{challenge_id}/
Response:
{
"success": true,
"data": {
"id": 1,
"title": "test title",
"description": "test description",
"claimed": false,
"completed": false,
"author_username": "user1",
"author_id": 1,
"group_id": 1,
"player": [ <SERIALIZED PLAYER>],
"image": null
}
}
image
is null because it has not been completed yet.
GET /api/challenges/{challenge_title}/
Response:
{
"success": true,
"data": {
"id": 1,
"title": "test title",
"description": "test description",
"claimed": false,
"completed": false,
"author_username": "user1",
"author_id": 1,
"group_id": 1,
"player": [ <SERIALIZED PLAYER>],
"image": null
}
}
image
is null because it has not been completed yet.
POST /api/challenges/
Request:
{
"title": <USER INPUT>,
"description": <USER INPUT>,
"username": <USER INPUT>,
"author_id": <USER INPUT>,
"group_id": <USER INPUT>
}
Response:
{
"success": true,
"data": {
"id": 1,
"title": "test title",
"description": "test description",
"claimed": false,
"completed": false,
"author_username": "user1",
"author_id": 1,
"group_id": 1,
"player": [ ],
"image": null
}
}
By default, image
is null because it has not been completed yet.
POST /api/challenges/assign_challenge_player/
Request:
{
"player_id": <USER INPUT>,
"challenge_id": <USER INPUT>,
}
Response:
{
"success": true,
"data": {
"id": 1,
"title": "test title",
"description": "test description",
"claimed": true,
"completed": false,
"author_username": "user1",
"author_id": 1,
"group_id": 1,
"player": [<SERIALIZED PLAYER> ],
"image": null
}
}
POST /api/challenges/mark_completed/
Allowable files: .png
, .jpeg
, .jpe
, .jpg
, .gif
Request:
{
"challenge_id": <USER INPUT>,
"image_data": <USER INPUT (HAS TO BE BASE64 ENCODED)>
}
Response:
{
"success": true,
"data": {
"id": 1,
"title": "test title",
"description": "test description",
"claimed": true,
"completed": true,
"author_username": "user1",
"author_id": 1,
"group_id": 1,
"player": [<SERIALIZED PLAYER> ],
"image": {
"url": <URL HERE>,
"created_at": <DATETIME STRING HERE>,
"challenge_id": 1,
"player_id": null
}
}
}
In this route, player_id
in the image branch will be null
because the image is associated with the challenge and not the player.
GET /api/groups/
Response:
{
"success": true,
"data": [
{
"id": 1,
"name": "test name",
"players": [ <SERIALIZED PLAYER>, ... ],
"challenges": [ <SERIALIZED CHALLENGE>, ... ],
},
{
"id": 2,
"name": "test name 2",
"players": [ <SERIALIZED PLAYER>, ... ],
"challenges": [ <SERIALIZED CHALLENGE>, ... ],
}
...
]
}
GET /api/groups/{group_id}/
Response:
{
"success": true,
"data": {
"id": 1,
"name": "test name",
"players": [ <SERIALIZED PLAYER>, ... ],
"challenges": [ <SERIALIZED CHALLENGE>, ... ],
}
}
GET /api/groups/{group_name}/
Response:
{
"success": true,
"data": {
"id": 1,
"name": "test name",
"players": [ <SERIALIZED PLAYER>, ... ],
"challenges": [ <SERIALIZED CHALLENGE>, ... ]
}
}
POST /api/groups/
Request:
{
"name": <USER INPUT>,
}
Response:
{
"success": true,
"data": {
"id": 1,
"name": "test name",
"players": [ ],
"challenges": [ ]
}
}
POST /api/groups/assign_player_group/
Request:
{
"player_id": <USER INPUT>,
"group_id": <USER INPUT>,
}
Response:
{
"success": true,
"data": {
"id": 1,
"name": "test name",
"players": [<SERIALIZED PLAYER>, ... ],
"challenges": [<SERIALIZED CHALLENGE>, ... ]
}
}
DELETE /api/groups/{group_id}/{player_id}/
Response:
{
"success": true,
"data": {
"id": 1,
"name": "test name",
"players": [<SERIALIZED PLAYER>, ... ],
"challenges": [<SERIALIZED CHALLENGE>, ... ]
}
}
GET /api/leaderboard/{group_id}/
Response:
{
"success": true,
"data": [ [<USERNAME>, <POINTS>], ... ]
}
}
GET /api/leaderboard/
Response:
{
"success": true,
"data": [ [<USERNAME>, <POINTS>], ... ]
}
}
POST /api/players/update_profile_pic/
Request:
{
"player_id": <USER INPUT>,
"image_data": <USER INPUT (HAS TO BE BASE64 ENCODED)>
}
Response:
{
"success": true,
"data": {
"id": 1,
"username": "test username",
"points": 0,
"current challenges": [ <SERIALIZED CHALLENGE>, ... ],
"completed challenges": [ <SERIALIZED CHALLENGE>, ... ],
"groups": [ <SERIALIZED GROUP>, ... ],
"authored_challenges": [ <SERIALIZED CHALLENGE>, ... ],
"image": {
"url": <URL HERE>,
"created_at": <DATETIME STRING HERE>,
"challenge_id": null,
"player_id": 1
}
}
}