Skip to content
This repository was archived by the owner on Mar 21, 2021. It is now read-only.

Latest commit

 

History

History
206 lines (161 loc) · 1.99 KB

API-spec.md

File metadata and controls

206 lines (161 loc) · 1.99 KB

API

  • All endpoints require JWT with HTTP Authorization except the register API (POST /users/).
  • Using UUID to improve security is not yet considered.

User

GET /users/<int:pk>/

  • Get user info

Response

{
  "id": 2,
  "username": "JungWinter",
}

POST /users/

  • Register
  • Only this endpoint is opened in public.

Request

{
  "username": "JungWinter",
  "password": "test",
}

Response

{
  "id": 1,
  "username": "JungWinter",
}

POST /auth/login

Request

{
  "username": "JungWinter",
  "password": "test",
}

Response

{
  "access": "access token",
  "refresh": "refresh token",
}

POST /auth/refresh

Request

{
  "token": "refresh token",
}

Response

{
  "access": "access token",
}

Chat

GET /rooms/

Response

[
  {
    "id": 1,
    "title": "Room001",
    "participants": [
      1,
      2,
    ],
  },
  {
    "id": 2,
    "title": "Room002",
    "participants": [
      2,
      3,
    ],
  },
]

POST /rooms/

Request

{
  "title": "Test Room",
  "participants": [
    1,
    2,
  ],
}

Response

{
  "id": 1,
  "title": "Test Room",
  "participants": [
    1,
    2,
  ],
}

GET /rooms/<int:pk>/

Response

{
  "id": 1,
  "title": "Test Room",
  "participants": [
    1,
    2,
  ],
}

GET /rooms/<int:pk>/messages/

Response

[
  {
    "id": 2,
    "sender": 1,
    "room": 1,
    "content": "Good",
  },
  {
    "id": 1,
    "sender": 2,
    "room": 1,
    "content": "How are you?",
  },
]

POST /rooms/<int:pk>/messages/

Request

{
  "sender": 1,
  "room": 1,
  "content": "Good",
}

Response

{
  "id": 2,
  "sender": 1,
  "room": 1,
  "content": "Good",
}

GET /rooms/<int:pk>/messages/<int:pk>/

Response

{
  "id": 1,
  "sender": 2,
  "room": 1,
  "content": "How are you?",
},