Example of REST API with Slim PHP micro framework.
This simple API allows you to manage resources such as: users, tasks and notes.
Get information about API.
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
}
}Get status of this api.
Endpoint:
Method: GET
Type:
URL: {{domain-api-rest-slimphp}}/statusResponses:
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 and get a JWT Token Authorization Bearer to use this api.
Endpoint:
Method: POST
Type: RAW
URL: {{domain-api-rest-slimphp}}/loginHeaders:
| Key | Value | Description |
|---|---|---|
| Content-Type | application/json |
Body:
{
"email": "super.email@host.com",
"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
}Manage Notes.
Endpoint:
Method: GET
Type:
URL: {{domain-api-rest-slimphp}}/api/v1/notesQuery 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 |
Endpoint:
Method: GET
Type:
URL: {{domain-api-rest-slimphp}}/api/v1/notes/3Endpoint:
Method: POST
Type: RAW
URL: {{domain-api-rest-slimphp}}/api/v1/notesHeaders:
| Key | Value | Description |
|---|---|---|
| Content-Type | application/json |
Body:
{
"name": "New Soccer Note",
"description": "Magic Goal..."
}Endpoint:
Method: PUT
Type: RAW
URL: {{domain-api-rest-slimphp}}/api/v1/notes/4Headers:
| Key | Value | Description |
|---|---|---|
| Content-Type | application/json |
Body:
{
"name": "My Note Number 433333",
"description": "Free Note?!?!?!"
}Endpoint:
Method: DELETE
Type: FORMDATA
URL: {{domain-api-rest-slimphp}}/api/v1/notes/22Manage Tasks.
Get all tasks of a user.
Endpoint:
Method: GET
Type:
URL: {{domain-api-rest-slimphp}}/api/v1/tasksHeaders:
| 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 |
Get one task of a user.
Endpoint:
Method: GET
Type:
URL: {{domain-api-rest-slimphp}}/api/v1/tasks/13Headers:
| Key | Value | Description |
|---|---|---|
| Authorization | {{jwt}} |
Create a task.
Endpoint:
Method: POST
Type: RAW
URL: {{domain-api-rest-slimphp}}/api/v1/tasksHeaders:
| 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
}Update a task of a user.
Endpoint:
Method: PUT
Type: RAW
URL: {{domain-api-rest-slimphp}}/api/v1/tasks/29Headers:
| 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
}Delete a task of a user.
Endpoint:
Method: DELETE
Type: FORMDATA
URL: {{domain-api-rest-slimphp}}/api/v1/tasks/29Headers:
| Key | Value | Description |
|---|---|---|
| Authorization | {{jwt}} |
Manage Users.
Endpoint:
Method: GET
Type:
URL: {{domain-api-rest-slimphp}}/api/v1/usersHeaders:
| 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 | |
| Search by email |
Endpoint:
Method: GET
Type:
URL: {{domain-api-rest-slimphp}}/api/v1/users/8Headers:
| Key | Value | Description |
|---|---|---|
| Authorization | {{jwt}} |
Register a new user.
Endpoint:
Method: POST
Type: RAW
URL: {{domain-api-rest-slimphp}}/api/v1/usersHeaders:
| Key | Value | Description |
|---|---|---|
| Content-Type | application/json |
Body:
{
"name": "John User",
"email": "super.email@host.com",
"password": "OnePass1"
}Update a user.
Endpoint:
Method: PUT
Type: RAW
URL: {{domain-api-rest-slimphp}}/api/v1/users/12Headers:
| Key | Value | Description |
|---|---|---|
| Content-Type | application/json | |
| Authorization | {{jwt}} |
Body:
{
"name": "John The User 22",
"email": "super.email@host.com.br"
}Delete a user.
Endpoint:
Method: DELETE
Type: FORMDATA
URL: {{domain-api-rest-slimphp}}/api/v1/users/112Headers:
| Key | Value | Description |
|---|---|---|
| Authorization | {{jwt}} |
Made with ♥ by thedevsaddam | Generated at: 2021-06-27 14:36:22 by docgen