Skip to content

yeonjunky/balance_game_backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

88 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Balance game

balance game rest api

Build with django and django rest framework

api design guidelines

Api Examples

Paths

games/
games/<int:game_id>

users/signup/
users/signin/
users/signout/

games/ request body and response example

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"
}

users/ request body and response example

sign up

method: POST

// request body
{
    "id": "foo",
    "password": "bar"
}
// response body
{
    "Token": "<tooooooooooooooooooooooooookeeeeeeeeeeen>"
}

sign in

method: POST

// request body
{
    "id": "foo",
    "password": "bar"
}
// response body
{
    "Token": "<tooooooooooooooooooooooooookeeeeeeeeeeen>"
}

sign out

send request with header that contains token

response HTTP code 204 No content

About

balance game backend repository

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published