Skip to content

Latest commit

 

History

History
232 lines (172 loc) · 5.58 KB

01_REST_API_DOC.md

File metadata and controls

232 lines (172 loc) · 5.58 KB

MENU README | How to run locally | REST API doc | Web app screenshots

✨ Solid Rails App

REST API documentation (cURL examples).

📚 Table of contents

Set the following environment variables to use the examples below:

export API_HOST="http://localhost:3000"
export API_TOKEN="MY_USER_TOKEN"

You can get the API_TOKEN by:

  1. Using the below User / Registration request.
  2. or performing the below User / Authentication request.
  3. or copying the user token from Sign In >> Settings >> API page.

⬆ back to top

User

Registration

curl -X POST "$API_HOST/api/v1/user/registrations" \
  -H "Content-Type: application/json" \
  -d '{
    "user": {
      "email": "[email protected]",
      "password": "123123123",
      "password_confirmation": "123123123"
    }
  }'

⬆ back to top

Authentication

curl -X POST "$API_HOST/api/v1/user/sessions" \
  -H "Content-Type: application/json" \
  -d '{
    "user": {
      "email": "[email protected]",
      "password": "123123123"
    }
  }'

⬆ back to top

Account deletion

curl -X DELETE "$API_HOST/api/v1/user/registrations" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $API_TOKEN"

⬆ back to top

API token updating

curl -X PUT "$API_HOST/api/v1/user/tokens" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $API_TOKEN"

⬆ back to top

Password updating

curl -X PUT "$API_HOST/api/v1/user/passwords" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $API_TOKEN" \
  -d '{
    "user": {
      "current_password": "123123123",
      "password": "321321321",
      "password_confirmation": "321321321"
    }
  }'

⬆ back to top

Password resetting - Link to change the password

curl -X POST "$API_HOST/api/v1/user/passwords/reset" \
  -H "Content-Type: application/json" \
  -d '{"user": {"email": "[email protected]"}}'

⬆ back to top

Password resetting - Change the password

curl -X PUT "$API_HOST/api/v1/user/passwords/reset" \
  -H "Content-Type: application/json" \
  -d '{
    "user": {
      "token": "TOKEN_RETRIEVED_BY_EMAIL",
      "password": "123123123",
      "password_confirmation": "123123123"
    }
  }'

⬆ back to top

Task List

Listing

curl -X GET "$API_HOST/api/v1/task/lists" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $API_TOKEN"

⬆ back to top

Creation

curl -X POST "$API_HOST/api/v1/task/lists" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $API_TOKEN" \
  -d '{"task_list": {"name": "My Task List"}}'

⬆ back to top

Updating

curl -X PUT "$API_HOST/api/v1/task/lists/2" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $API_TOKEN" \
  -d '{"task_list": {"name": "My List"}}'

⬆ back to top

Deletion

curl -X DELETE "$API_HOST/api/v1/task/lists/2" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $API_TOKEN"

⬆ back to top

Task

Listing

# ?filter=completed | incomplete

curl -X GET "$API_HOST/api/v1/task/lists/1/items" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $API_TOKEN"

⬆ back to top

Creation

curl -X POST "$API_HOST/api/v1/task/lists/1/items" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $API_TOKEN" \
  -d '{"task": {"name": "My Task"}}'

⬆ back to top

Updating

# "completed": true | 1 | false | 0

curl -X PUT "$API_HOST/api/v1/task/lists/1/items/1" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $API_TOKEN" \
  -d '{"task": {"name": "My Task", "completed": true}}'

⬆ back to top

Deletion

curl -X DELETE "$API_HOST/api/v1/task/lists/1/items/1" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $API_TOKEN"

⬆ back to top