Skip to content

anggidast/gotodo-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

89 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Todo API Documentation

API URL: https://gotodo-api.herokuapp.com/

Method Route Description
POST /users/register Create new user account to access Go Todo
POST /users/login User login to access Go Todo
POST /todos Add new todo to Go Todo
GET /todos Show all todos in Go Todo
GET /todos/:id Show todo in Go Todo by ID
PUT /todos/:id Update all todo field in Go Todo
PATCH /todos/:id Update only todo status field in Go Todo
DELETE /todos/:id Delete todo from Go Todo

Demo Account

email: demo@user.com

password: demouser


Register

Create new user account to access Go Todo

  • URL

    /users/register

  • Method:

    POST

  • URL Params: none

  • Data Params: none

  • Request Body

     { "email": "<user email>", "password": "<user password>" } ``` 
  • Success Response:

    • Code: 201
      Content:
      { "success": true, "user": { "id": "<user ID>", "email": "<user email>" } },
  • Error Response:

    • Code: 400 BAD REQUEST
      Content: "message": "Email <user email> is already registered"

      OR

    • Code: 400 BAD REQUEST
      Content: "message": "Email cannot be empty/null"

      OR

    • Code: 400 BAD REQUEST
      Content: "message": "Email format is wrong"

      OR

    • Code: 400 BAD REQUEST
      Content: "message": "Password cannot be empty/null"

      OR

  • Code: 500 INTERNAL SERVER ERROR
    Content: "message": "Internal server error

  • Sample Call:

    Request body:

    { "email": "user1@mail.com", "password": "password1" }

    Response:

    { "success": true, "user": { "id": 14, "email": "user1" } }
  • Notes: none


Login

Login to access Go Todo

  • URL

    /users/login

  • Method:

    POST

  • URL Params: none

  • Data Params: none

  • Request Body

     { "email": "<user email>", "password": "<user password>" } ``` 
  • Success Response:

    • Code: 201
      Content:
      { "success": true, "access_token": "<access token>" },
  • Error Response:

    • Code: 403 FORBIDDEN
      Content: "message": "Email is not registered"

    OR

    • Code: 403 FORBIDDEN
      Content: "message": "Wrong password"

      OR

    • Code: 400 BAD REQUEST
      Content: "message": "Email cannot be empty/null"

      OR

    • Code: 400 BAD REQUEST
      Content: "message": "Email format is wrong"

      OR

    • Code: 400 BAD REQUEST
      Content: "message": "Password cannot be empty/null"

      OR

    • Code: 500 INTERNAL SERVER ERROR
      Content: "message": "Internal server error

  • Sample Call:

    Request body:

    { "email": "user1", "password": "password1" }

    Response:

    { "success": true, "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwiaWF0IjoxNjIyMjEyMzk5fQ.aWfNArS1JYnNYkDxrIyqFBqWuwxEKfEmFYs65t0bcjs" }
  • Notes: none


Add Todo

Add new todo to Go Todo

  • URL

    /todos

  • Method:

    POST

  • Authentication:

    REQUIRED: access_token (JWT)

  • URL Params: none

  • Data Params: none

  • Request Body

     { "title": "<todo title>", "description": "<todo description>", "status": "<todo status: done/undone>", "due_date": "<todo due date, format: YYYY-MM-DD>" } ``` 
  • Success Response:

    • Code: 201
      Content:
      { "message": created "data": { "id": "<id number>", "title": "<todo title>", "description": "<todo description>", "status": "<todo status: done/undone>", "due_date": "<todo due date>", "createdAt": "2021-05-24T15:01:21.735Z", "updatedAt": "2021-05-24T15:01:21.735Z" } },
  • Error Response:

    • Code: 400 BAD REQUEST
      Content: "message": "Validation error: Due date cannot be the day before today"

      OR

    • Code: 500 INTERNAL SERVER ERROR
      Content: "message": "Internal server error

  • Sample Call:

    Request body:

    { "title": "REST API", "description": "learning about REST API", "status": "undone", "due_date": "2021-05-26" }

    Response:

    { "id": 1, "title": "REST API", "description": "learning about REST API", "status": "undone", "due_date": "2021-05-26T00:00:00.000Z", "createdAt": "2021-05-24T15:01:21.735Z", "updatedAt": "2021-05-24T15:01:21.735Z" }
  • Notes: none


Show All Todos

Show all todos in Go Todo

  • URL

    /todos

  • Method:

    GET

  • Authentication:

    REQUIRED: access_token (JWT)

  • URL Params: none

  • Data Params: none

  • Success Response:

    • Code: 200
      Content:
      [ { "id": "<id number>", "title": "<todo title>", "description": "<todo description>", "status": "<todo status: done/undone>", "due_date": "<todo due date>", "createdAt": "2021-05-24T15:01:21.735Z", "updatedAt": "2021-05-24T15:01:21.735Z" }, { "id": "<id number>", "title": "<todo title>", "description": "<todo description>", "status": "<todo status: done/undone>", "due_date": "<todo due date>", "createdAt": "2021-05-24T15:01:21.735Z", "updatedAt": "2021-05-24T15:01:21.735Z" } ]
  • Error Response:

    • Code: 500 INTERNAL SERVER ERROR
      Content: "message": "Internal server error
  • Notes: none


Show Todo by ID

Show todo in Go Todo by ID

  • URL

    /todos/:id

  • Method:

    GET

  • Authentication:

    REQUIRED: access_token (JWT)

  • URL Params

    /:id

    Required:

    id=[integer]

  • Data Params: none

  • Success Response:

    • Code: 200
      Content:
      { "id": "<id number>", "title": "<todo title>", "description": "<todo description>", "status": "<todo status: done/undone>", "due_date": "<todo due date>", "createdAt": "2021-05-24T15:01:21.735Z", "updatedAt": "2021-05-24T15:01:21.735Z" }
  • Error Response:

    • Code: 404 NOT FOUND
      Content: "message": "Todo not found"
  • Notes: none


Update Todo

Update all todo field in Go Todo

  • URL

    /todos/:id

  • Method:

    PUT

  • Authentication:

    REQUIRED: access_token (JWT)

  • URL Params

    /:id

    Required:

    id=[integer]

  • Data Params: none

  • Request Body

     { "title": "<todo title>", "description": "<todo description>", "status": "<todo status: done/undone>", "due_date": "<todo due date, format: YYYY-MM-DD>" } ``` 
  • Success Response:

    • Code: 200
      Content:
      { "id": "<id number>", "title": "<todo title>", "description": "<todo description>", "status": "<todo status: done/undone>", "due_date": "<todo due date>", "createdAt": "2021-05-24T15:01:21.735Z", "updatedAt": "2021-05-24T15:01:21.735Z" }
  • Error Response:

    • Code: 400 BAD REQUEST
      Content: "message": "Validation error: Due date cannot be the day before today"

      OR

    • Code: 404 NOT FOUND
      Content: "message": "Todo not found"

      OR

    • Code: 500 INTERNAL SERVER ERROR
      Content: "message": "Internal server error"

  • Notes: none


Update Todo Status

Update only todo status field in Go Todo

  • URL

    /todos/:id

  • Method:

    PATCH

  • Authentication:

    REQUIRED: access_token (JWT)

  • URL Params

    /:id

    Required:

    id=[integer]

  • Data Params: none

  • Request Body

     { "status": "<todo status: done/undone>" } ``` 
  • Success Response:

    • Code: 200
      Content:
      { "id": "<id number>", "title": "<todo title>", "description": "<todo description>", "status": "<todo status: done/undone>", "due_date": "<todo due date>", "createdAt": "2021-05-24T15:01:21.735Z", "updatedAt": "2021-05-24T15:01:21.735Z" }
  • Error Response:

    • Code: 400 BAD REQUEST
      Content: "message": "Validation error: Due date cannot be the day before today"

      OR

    • Code: 404 NOT FOUND
      Content: "message": "Todo not found"

      OR

    • Code: 500 INTERNAL SERVER ERROR
      Content: "message": "Internal server error"

  • Notes: none


Delete Todo

Delete todo from Go Todo

  • URL

    /todos/:id

  • Method:

    DELETE

  • Authentication:

    REQUIRED: access_token (JWT)

  • URL Params

    /:id

    Required:

    id=[integer]

  • Data Params: none

  • Success Response:

    • Code: 200
      Content:
      { "message": "todo deleted", "deletedData": { "id": "<id number>", "title": "<todo title>", "description": "<todo description>", "status": "<todo status: done/undone>", "due_date": "<todo due date>", "createdAt": "2021-05-24T15:01:21.735Z", "updatedAt": "2021-05-24T15:01:21.735Z" } }
  • Error Response:

  • Code: 404 NOT FOUND
    Content: "message": "Todo not found"

    OR

  • Code: 500 INTERNAL SERVER ERROR
    Content: "message": "Internal server error"

  • Notes: none

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors