Skip to content

API endpoints

Sihan Tawsik edited this page May 8, 2020 · 6 revisions

API Endpoints

Description

The API endpoints, how to use them and their responses.

Usage

1. /auth/register

Post

Request
Headers
  1. content-type: application/json
Body
  1. username
  2. password
  3. account_type
Format
curl --header "Content-Type: application/json" \
    --request POST \
    --data '{"username":"username","password":"password","account_type":"1"}' \
    http://localhost:5000/auth/register
1. Response: 200
Headers
  1. content-type: application/json
Body
  1. auth_token
  2. message
  3. status
Format
{
  "auth_token": a_token, 
  "message": "Successfully registered.", 
  "status": "success"
}
2. Response: 409

If the user already exits.

Headers
  1. content-type: application/json
Body
  1. message
  2. status
Format
{
  "message": "User already exists. Please Log in.", 
  "status": "fail"
}
3. Response: 401

Any type of errors.

Headers
  1. content-type: application/json
Body
  1. message
  2. status
Format
{
  "message": "Some error occurred. Please try again.", 
  "status": "fail"
}

2. /auth/login

Post

Request
Headers
  1. content-type: application/json
Body
  1. username
  2. password
Format
curl --header "Content-Type: application/json" \
    --request POST \
    --data '{"username":"username","password":"password"}' \
    http://localhost:5000/auth/login
1. Response: 200
Headers
  1. content-type: application/json
Body
  1. auth_token
  2. message
  3. status
Format
{
  "auth_token": a_token, 
  "message": "Successfully logged in.", 
  "status": "success"
}
2. Response: 404

If the user does not exits.

Headers
  1. content-type: application/json
Body
  1. message
  2. status
Format
{
  "message": "User does not exist.", 
  "status": "fail"
}
3. Response: 500

Any type of errors.

Headers
  1. content-type: application/json
Body
  1. message
  2. status
Format
{
  "message": "Try again", 
  "status": "fail"
}

Clone this wiki locally