balance game rest api
Build with django and django rest framework
Api Examples
games/
games/<int:game_id>
users/signup/
users/signin/
users/signout/
GET
// games/
{
"status": 200,
"games": [
{
"id": 9,
"title": "Cpt.America vs IronMan",
"choices": [
{
"id": 1,
"text": "Cpt.America",
"votes": 0
},
{
"id": 2,
"text": "IronMan",
"votes": 0
}
]
},
{
"id": 10,
"title": "woooo",
"choices": [
{
"id": 3,
"text": "fuuuuu",
"votes": 0
},
{
"id": 4,
"text": "barrr",
"votes": 0
}
]
}
]
}
// games/<int:game_id>/
{
"status": 200,
"game": {
"id": 10,
"title": "woooo",
"choices": [
{
"id": 3,
"text": "fuuuuu",
"votes": 0
},
{
"id": 4,
"text": "barrr",
"votes": 0
}
]
}
}POST
// games/
// request body
{
"title": "fooooo vs barrrrrr",
"choices": [
{
"text": "buuuuu"
},
{
"text": "barrrrrr"
}
]
}// response body
{
"status": 201,
"description": "new game is successfully created.",
"game": {
"id": 18,
"title": "fooooo vs barrrrrr",
"choices": [
{
"id": 19,
"text": "buuuuu",
"votes": 0
},
{
"id": 20,
"text": "barrrrrr",
"votes": 0
}
]
}
}PUT
// games/<int:game_id>/
// reqeuest body
{
"title": "woooo",
"choices": [
{"text": "fuuuuu"},
{"text": "barrr"}
]
}// response body
{
"status": "200",
"description": "game is updated",
"game": {
"id": 10,
"title": "woooo",
"choices": [
{
"id": 3,
"text": "fuuuuu",
"votes": 0
},
{
"id": 4,
"text": "barrr",
"votes": 0
}
]
}
}DELETE
// games/<int:game_id>/
// response body
{
"deleted_game_id": 18,
"deleted_game_title": "fooooo vs barrrrrr",
"description": "game is successfully deleted"
}method: POST
// request body
{
"id": "foo",
"password": "bar"
}// response body
{
"Token": "<tooooooooooooooooooooooooookeeeeeeeeeeen>"
}method: POST
// request body
{
"id": "foo",
"password": "bar"
}// response body
{
"Token": "<tooooooooooooooooooooooooookeeeeeeeeeeen>"
}send request with header that contains token
response HTTP code 204 No content