API Documentation - adefirmanf/message_board_api GitHub Wiki

The API currently has 5 endpoints: Auth, User, Message, Comment, and Vote. In order to use the API, each endpoint using authorization except; Login and Create user.

This token is used to authenticate and is passed through as an Authorization Token header in calls made to the API. The API will always respond in JSON.

In this documentation, you will see these columns

Private Description
F Token doesn't required ( False )
T Token is required ( True )

Table of contents

Authentication

For all api calls except create user, the following headers are expected:

  • “Authorization: Bearer <API_TOKEN>
  • "Content-Type: application/json"

To retrieve the token, you can call this API

Command Method Route Description Private
Auth POST /auth/login Get token F

Payload

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

Response

{
    "message": String,
    "data": {
        "user_id": String,
        "username": String,
        "token": String
    }
}

If you using Postman, you can copy the token and set the Authorization mode to Bearer token

You can get the username & password by creating the user.

User

Get All User

Command Method Route Description Private
Get All User GET /user - T

Response

{
    "message": String,
    "data": {
        "uuid_": String,
        "username": String,
        "created_at": Date,
        "updated_at" : Date
    }
}

Get Specific User By Id

Command Method Route Description Private
Get Specific User GET /user/:id - T

Response

{
    "message": String,
    "data": {
        "uuid_": String,
        "username": String,
        "created_at": Date,
        "updated_at" : Date
    }
}

Create User

Command Method Route Description Private
Create User POST /user/ - F

Payload

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

Response

{
    "message": String,
    "data": {
        "target": String,
        "redirect": Boolean
    }
}

Message

Get All Message

Command Method Route Description Private
Get All Message GET /message - T

Response

{
"status": String,
    "data": [
        {
            "id": Int,
            "user_uuid": String,
            "value": String,
            "total_vote": Int,
            "created_at": Date,
            "updated_at": Date
        }
      ]
}

Get Specific Message By Id

Command Method Route Description Private
Get Specific Message GET /message/:id/ - T

Response

{
"status": String,
    "data": [
        {
            "id": Int,
            "user_uuid": String,
            "value": String,
            "total_vote": Int,
            "created_at": Date,
            "updated_at": Date
        }
      ]
}

Create Message

Command Method Route Description Private
Create Message POST /message - T

Payload

{
   "message" : String
}

Response

{
    "message": String,
    "data": {
        "id": Int,
        "message": String
    }
}

Comment

Get all Comments

Command Method Route Description Private
Get All Comments GET /comment/ - T

Response

{
    "message": String,
    "data": [{
        "id": Int,
        "message_id": String,
        "user_uuid" : String, 
        "value": String,
        "total_vote" : Int,
        "created_at" : Date,
        "updated_at" : Date
    }]
}

Get Comment By Message Id

Command Method Route Description Private
Get Comment By Id GET /comment/message/:id - T

Response

{
    "message": String,
    "data": [{
        "id": Int,
        "message_id": String,
        "user_uuid" : String, 
        "value": String,
        "total_vote" : Int,
        "created_at" : Date,
        "updated_at" : Date
    }]
}

Create Comment by Message Id

Command Method Route Description Private
Create Comment POST /comment/message/:id - T

Payload

{
   "comment" : String
}

Response

{
    "message": String,
    "data": {
        "id": Int,
        "comment": String
    }
}

Vote

Vote Message Up

Command Method Route Description Private
Vote Message Up POST /vote/message/:id/up - T

Response

{
    "message": String,
    "data": {
        "total_vote" : Int
    }
}

Vote Message Down

Command Method Route Description Private
Vote Message Down POST /vote/message/:id/down - T

Response

{
    "message": String,
    "data": {
        "total_vote" : Int
    }
}

Vote Comment Up

Command Method Route Description Private
Vote Comment Up POST /vote/comment/:id/up - T

Response

{
    "message": String,
    "data": {
        "total_vote" : Int
    }
}

Vote Comment Down

Command Method Route Description Private
Vote Comment Down POST /vote/comment/:id/down - T

Response

{
    "message": String,
    "data": {
        "total_vote" : Int
    }
}
⚠️ **GitHub.com Fallback** ⚠️