Skip to content

API Specifications

YeonJeong edited this page Oct 7, 2023 · 28 revisions

API Specifications for SpeechBuddy


User

POST /user/signup/ (creates new user by signing up)

Request

Header
Key Value Description
None None N/A
Body
{
  "email": "string",
  "password": "string",
  "nickname": "string"
}

Response

Status Code
Code key of Message Description
201 None Successfully created
400 email missing input value, blank input, invalid email format, length error(✅len<=50), already taken
400 password missing input value, blank input, length error(✅len>=8)
400 nickname missing input value, blank input, length error(✅len<=15)
POST /user/validateemail/send/ (sends verification code via email)

Request

Header
Key Value Description
None None N/A
Body
{
  "email": "string"
}

Response

Status Code
Code key of Message Description
200 None N/A (successfully sent)
400 email missing input value, blank input, invalid email format, length error(✅len<=50), already taken
POST /user/validateemail/accept/ (checks email verification code)

Request

Header
Key Value Description
None None N/A
Body
{
  "email": "string", // should be automatically set by frontend! not by a user!
  "code": "string"
}

Response

Status Code
Code key of Message Description
200 None N/A (successfully checked)
400 email missing input value, blank input, invalid email format, length error(✅len<=50), already taken
400 code missing input value, blank input, length error(✅len==6)
400 fail wrong code
POST /user/login/ (creates new authorization tokens)

Request

Header
Key Value Description
None None N/A
Body
{
  "email": "string",
  "password": "string"
}

Response

Body
{
  "access": "string",
  "refresh": "string"
}
Status Code
Code key of Message Description
200 None OK
400 email missing input value, blank input, invalid email format, no such user w/ the email
400 password missing input value, blank input, wrong password
POST /user/refresh/ (refreshes user's authorization tokens)

Request

Header
Key Value Description
None None N/A
Body
{
  "refresh": "string"
}

Response

Body
{
  "access": "string"
}
Status Code
Code key of Message Description
200 None OK
400 refresh missing input value, blank input
401 detail and code refresh token expired; user has to attempt a new login
POST /user/logout/ (deletes user's authorization tokens) 🔒

Request

Header
Key Value Description
Authorization Bearer {access} user's access token (must be sent with the prefix 'Bearer')
Body
{
  "refresh": "string"
}

Response

Status Code
Code key of Message Description
200 None OK
400 refresh missing input value, blank input
403 detail no access token was sent in the header
403 detail, code and messages access token expired; user has to refresh to retrieve a new token
GET /user/profile/ (gets user's profile) 🔒

Request

Header
Key Value Description
Authorization Bearer {access} user's access token (must be sent with the prefix 'Bearer')

Response

Body
{
  "user": {
    "id": int,
    "email": "string",
    "nickname": "string",
    "updated_at": timestamp
    ... // more fields to be added later
  }
}
Status Code
Code key of Message Description
200 None OK
403 detail no access token was sent in the header
403 detail, code and messages access token expired; user has to refresh to retrieve a new token
PATCH /user/profile/nickname/ (changes user's nickname) 🔒

Request

Header
Key Value Description
Authorization Bearer {access} user's access token (must be sent with the prefix 'Bearer')
Body
{
  "nickname": "string"
}

Response

Status Code
Code key of Message Description
200 None Successfully changed
400 nickname missing input value, blank input, length error(✅len<=15), same as the original nickname
PATCH /user/profile/password/ (changes user's password) 🔒

Request

Header
Key Value Description
Authorization Bearer {access} user's access token (must be sent with the prefix 'Bearer')
Body
{
  "password": "string"
}

Response

Status Code
Code key of Message Description
200 None Successfully changed
400 password missing input value, blank input, length error(✅len>=8)

Symbol

Clone this wiki locally