Skip to content

trxe/bodyx-backend-flask

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BODYX Service

Authentication

Send a request with basic auth.

{
  "username": "username",
  "password": "password"
}

To make any API request, include the token received from a successful login as the value of the key x-access-token in the header of the request.

{
  "data": {
    "token": "sampleToken$eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.ey..."
    "isAdmin": true
  },
  "error": "",
  "message": "Login success"
}

Usage

Headers should include content-type andx-access-token. All responses should have the form:

{
  "data": "content of response",
  "msg": "message on success",
  "error": "message on error"
}

Viewer and Admin API

Admin only API

List all shows

Definition GET /shows

Response 200 OK on success

Find a show

Definition GET /shows/<id>

Response 200 OK on success

Registering a new show

Definition POST /shows

Arguments

  • "enTitle":string
  • "cnTitle":string
  • "durationMins":integer

Response

  • 201 Created on success
  • 400 Bad request on invalid input
{
  "id": "61d5ac4958b919489f458d9f",
  "enTitle": "English",
  "cnTitle": "中文",
  "durationMins": 120
}

Update a show

Definition PUT /shows/<id>

Arguments

  • "id":integer
  • "enTitle":string
  • "cnTitle":string
  • "durationMins":integer

Response

  • 201 Created on success
  • 404 Not found
  • 400 Bad request on invalid input or id

Delete a show

Definition DELETE /shows/<id>

Response

  • 204 No content on success
  • 404 Not found
  • 400 Bad request on invalid id

List all sessions

Definition GET /sessions

Response 200 OK on success

Find a session

Definition GET /sessions/<id>

Response 200 OK on success

Filter sessions by show id

Definition GET /sessions?show_id=<id>

Response 200 OK on success

Registering a new session

Definition POST /shows

Arguments

  • "dateTime":string must be in ISO8601 format (see below)
  • "eventId":string
  • "showId":string must correspond to some show id

Response

  • 201 Created on success
  • 400 Bad request on invalid input
{
  "dateTime": "2012-01-01T23:30:00+02:00",
  "eventId": "first",
  "showId": "61d5ac4958b919489f458d9f"
}

Update a session

Definition PUT /shows/<id>

Arguments

  • "dateTime":string
  • "eventId":string
  • "showId":string
  • "isPlaying":bool
  • "rooms":list

Response

  • 201 Created on success
  • 404 Not found
  • 400 Bad request on invalid input or id
{
  "isPlaying": true,
  "rooms": [
    {
      "title": "Round Table",
      "url": "new_url",
      "isUnlocked": true
    },
    {
      "title": "Cashier Counter",
      "url": "another_new_url",
      "isUnlocked": false
    }
  ]
}	

Delete a session

Definition DELETE /shows/<id>

Response

  • 204 No content on success
  • 404 Not found
  • 400 Bad request on invalid id