Skip to content

Latest commit

 

History

History
646 lines (365 loc) · 8.13 KB

endpoints.md

File metadata and controls

646 lines (365 loc) · 8.13 KB

Rest Api Slim PHP

Example of REST API with Slim PHP micro framework.

This simple API allows you to manage resources such as: users, tasks and notes.

Indices


Info

Get information about API.

1. Get Help

Get help about this api.

Endpoint:

Method: GET
Type: 
URL: {{domain-api-rest-slimphp}}

Responses:

Status: Get Help | Code: 200

{
    "code": 200,
    "status": "success",
    "message": {
        "endpoints": {
            "tasks": "http://localhost:8080/api/v1/tasks",
            "users": "http://localhost:8080/api/v1/users",
            "notes": "http://localhost:8080/api/v1/notes",
            "docs": "http://localhost:8080/docs/index.html",
            "status": "http://localhost:8080/status",
            "this help": "http://localhost:8080"
        },
        "version": "2.13.0",
        "timestamp": 1624812953
    }
}

2. Get Status

Get status of this api.

Endpoint:

Method: GET
Type: 
URL: {{domain-api-rest-slimphp}}/status

Responses:

Status: Get Status | Code: 200

{
    "code": 200,
    "status": "success",
    "message": {
        "stats": {
            "tasks": 8,
            "users": 42,
            "notes": 63
        },
        "MySQL": "OK",
        "Redis": "Disabled",
        "version": "2.12.0",
        "timestamp": 1624808196
    }
}

Login

1. Login

Login and get a JWT Token Authorization Bearer to use this api.

Endpoint:

Method: POST
Type: RAW
URL: {{domain-api-rest-slimphp}}/login

Headers:

Key Value Description
Content-Type application/json

Body:

{
    "email": "[email protected]",
    "password": "OnePass1"
}

Responses:

Status: Login OK | Code: 200

{
    "code": 200,
    "status": "success",
    "message": {
        "Authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMSIsImVtYWlsIjoibUBiLmNvbS5hciIsIm5hbWUiOiJNTkIiLCJpYXQiOjE1NTg1NTMwNTIsImV4cCI6MTU1OTE1Nzg1Mn0.OQyICWlGW0oSUB-ANrYL2OJTdC2v0OQQO3RQQ3W_KLo"
    }
}

Status: Login Failed | Code: 400

{
    "message": "Login failed: Email or password incorrect.",
    "class": "UserException",
    "status": "error",
    "code": 400
}

Notes

Manage Notes.

1. Get All Notes

Endpoint:

Method: GET
Type: 
URL: {{domain-api-rest-slimphp}}/api/v1/notes

Query params:

Key Value Description
page 1 Number of the page
perPage 10 Quantity of items per page
name Search by name
description Search by description

2. Get One Note

Endpoint:

Method: GET
Type: 
URL: {{domain-api-rest-slimphp}}/api/v1/notes/3

3. Create Note

Endpoint:

Method: POST
Type: RAW
URL: {{domain-api-rest-slimphp}}/api/v1/notes

Headers:

Key Value Description
Content-Type application/json

Body:

{
  "name": "New Soccer Note",
  "description": "Magic Goal..."
}

4. Update Note

Endpoint:

Method: PUT
Type: RAW
URL: {{domain-api-rest-slimphp}}/api/v1/notes/4

Headers:

Key Value Description
Content-Type application/json

Body:

{
  "name": "My Note Number 433333",
  "description": "Free Note?!?!?!"
}

5. Delete Note

Endpoint:

Method: DELETE
Type: FORMDATA
URL: {{domain-api-rest-slimphp}}/api/v1/notes/22

Tasks

Manage Tasks.

1. Get All Tasks

Get all tasks of a user.

Endpoint:

Method: GET
Type: 
URL: {{domain-api-rest-slimphp}}/api/v1/tasks

Headers:

Key Value Description
Authorization {{jwt}}

Query params:

Key Value Description
page 1 Number of the page
perPage 5 Quantity of items per page
name Search by name
description Search by description
status Search by status

2. Get One Task

Get one task of a user.

Endpoint:

Method: GET
Type: 
URL: {{domain-api-rest-slimphp}}/api/v1/tasks/13

Headers:

Key Value Description
Authorization {{jwt}}

3. Create Task

Create a task.

Endpoint:

Method: POST
Type: RAW
URL: {{domain-api-rest-slimphp}}/api/v1/tasks

Headers:

Key Value Description
Content-Type application/json
Authorization {{jwt}}

Body:

{
  "name": "Go To Sleep",
  "description": "It's too late, go to sleep man ;-)",
  "status": 0
}

4. Update Task

Update a task of a user.

Endpoint:

Method: PUT
Type: RAW
URL: {{domain-api-rest-slimphp}}/api/v1/tasks/29

Headers:

Key Value Description
Content-Type application/json
Authorization {{jwt}}

Body:

{
  "name": "Go To Sleep NOW!!",
  "description": "It's too late, go to sleep man haha...",
  "status": 1
}

5. Delete Task

Delete a task of a user.

Endpoint:

Method: DELETE
Type: FORMDATA
URL: {{domain-api-rest-slimphp}}/api/v1/tasks/29

Headers:

Key Value Description
Authorization {{jwt}}

Users

Manage Users.

1. Get All Users

Endpoint:

Method: GET
Type: 
URL: {{domain-api-rest-slimphp}}/api/v1/users

Headers:

Key Value Description
Authorization {{jwt}}

Query params:

Key Value Description
page 1 Number of the page
perPage 10 Quantity of items per page
name Search by name
email Search by email

2. Get One User

Endpoint:

Method: GET
Type: 
URL: {{domain-api-rest-slimphp}}/api/v1/users/8

Headers:

Key Value Description
Authorization {{jwt}}

3. Create User

Register a new user.

Endpoint:

Method: POST
Type: RAW
URL: {{domain-api-rest-slimphp}}/api/v1/users

Headers:

Key Value Description
Content-Type application/json

Body:

{
  "name": "John User",
  "email": "[email protected]",
  "password": "OnePass1"
}

4. Update User

Update a user.

Endpoint:

Method: PUT
Type: RAW
URL: {{domain-api-rest-slimphp}}/api/v1/users/12

Headers:

Key Value Description
Content-Type application/json
Authorization {{jwt}}

Body:

{
    "name": "John The User 22",
    "email": "[email protected]"
}

5. Delete User

Delete a user.

Endpoint:

Method: DELETE
Type: FORMDATA
URL: {{domain-api-rest-slimphp}}/api/v1/users/112

Headers:

Key Value Description
Authorization {{jwt}}

Back to top

Made with ♥ by thedevsaddam | Generated at: 2021-06-27 14:36:22 by docgen