API Documentation
Ade Firman F edited this page Apr 2, 2020
·
2 revisions
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 ) |
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 |
{
"username" : String,
"password" : String
}
{
"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.
Command | Method | Route | Description | Private |
---|---|---|---|---|
Get All User | GET | /user | - | T |
{
"message": String,
"data": {
"uuid_": String,
"username": String,
"created_at": Date,
"updated_at" : Date
}
}
Command | Method | Route | Description | Private |
---|---|---|---|---|
Get Specific User | GET | /user/:id | - | T |
{
"message": String,
"data": {
"uuid_": String,
"username": String,
"created_at": Date,
"updated_at" : Date
}
}
Command | Method | Route | Description | Private |
---|---|---|---|---|
Create User | POST | /user/ | - | F |
{
"username" : String,
"password" : String
}
{
"message": String,
"data": {
"target": String,
"redirect": Boolean
}
}
Command | Method | Route | Description | Private |
---|---|---|---|---|
Get All Message | GET | /message | - | T |
{
"status": String,
"data": [
{
"id": Int,
"user_uuid": String,
"value": String,
"total_vote": Int,
"created_at": Date,
"updated_at": Date
}
]
}
Command | Method | Route | Description | Private |
---|---|---|---|---|
Get Specific Message | GET | /message/:id/ | - | T |
{
"status": String,
"data": [
{
"id": Int,
"user_uuid": String,
"value": String,
"total_vote": Int,
"created_at": Date,
"updated_at": Date
}
]
}
Command | Method | Route | Description | Private |
---|---|---|---|---|
Create Message | POST | /message | - | T |
{
"message" : String
}
{
"message": String,
"data": {
"id": Int,
"message": String
}
}
Command | Method | Route | Description | Private |
---|---|---|---|---|
Get All Comments | GET | /comment/ | - | T |
{
"message": String,
"data": [{
"id": Int,
"message_id": String,
"user_uuid" : String,
"value": String,
"total_vote" : Int,
"created_at" : Date,
"updated_at" : Date
}]
}
Command | Method | Route | Description | Private |
---|---|---|---|---|
Get Comment By Id | GET | /comment/message/:id | - | T |
{
"message": String,
"data": [{
"id": Int,
"message_id": String,
"user_uuid" : String,
"value": String,
"total_vote" : Int,
"created_at" : Date,
"updated_at" : Date
}]
}
Command | Method | Route | Description | Private |
---|---|---|---|---|
Create Comment | POST | /comment/message/:id | - | T |
{
"comment" : String
}
{
"message": String,
"data": {
"id": Int,
"comment": String
}
}
Command | Method | Route | Description | Private |
---|---|---|---|---|
Vote Message Up | POST | /vote/message/:id/up | - | T |
{
"message": String,
"data": {
"total_vote" : Int
}
}
Command | Method | Route | Description | Private |
---|---|---|---|---|
Vote Message Down | POST | /vote/message/:id/down | - | T |
{
"message": String,
"data": {
"total_vote" : Int
}
}
Command | Method | Route | Description | Private |
---|---|---|---|---|
Vote Comment Up | POST | /vote/comment/:id/up | - | T |
{
"message": String,
"data": {
"total_vote" : Int
}
}
Command | Method | Route | Description | Private |
---|---|---|---|---|
Vote Comment Down | POST | /vote/comment/:id/down | - | T |
{
"message": String,
"data": {
"total_vote" : Int
}
}