This is an example CRUD for a phone directory JSON API REST, it includes some of the most basic database operations like creating, reading, updating and deleting (CRUD).
Endpoint: http://crud.host
| Status code | Reason | Meaning |
|---|---|---|
| 200 | OK | Your request was successful. |
| 400 | Bad Request | Your request is invalid. |
| 401 | Unauthorized | The access token is wrong or missing. |
| 404 | Not Found | The phone number could not be found. |
| 405 | Method Not Allowed | You tried to access to a route with an invalid method. |
| 500 | Internal Server Error | We had a problem with our server. Try again later. |
POST /api/phone Create a phone numberGET /api/phone Get all phone numbersGET /api/phone/{id} Get specific phone numberPUT /api/phone/{id} Update phone numberDELETE /api/phone/{id} Delete phone numberInsert a phone number into database.
POST
http://crud.host/api/phone
| Name | Type | Optional | Description |
|---|---|---|---|
| name | string | Yes | Name of the phone number owner. |
| phone | string | Yes | Phone number of the owner. |
| POST /api/phone HTTP/1.1 |
| Authorization: Bearer [access token] |
| Content-Type: application/json |
| Accept: application/json |
|
| 200 OK HTTP/1.1 |
| Content-Type: application/json |
|
Retrieve all the phone numbers in the database.
GET
http://crud.host/api/phone
Example of response
| 200 OK HTTP/1.1 |
| Content-Type: application/json |
|
Retrieve a single phone number from the database.
GET
http://crud.host/api/phone/{id}
| Name | Type | Optional | Description |
|---|---|---|---|
| id | int | ID of the existing phone number |
Example response
| 200 OK HTTP/1.1 |
| Content-Type: application/json |
|
Edit existing phone number in database.
PUT
http://crud.host/api/phone/{id}
| Name | Type | Optional | Description |
|---|---|---|---|
| id | int | ID of the existing phone number. | |
| name | string | Name of the phone number owner. | |
| phone | string | Phone number of the owner. |
Example request
| PUT /api/phone/{id} HTTP/1.1 |
| Authorization: Bearer [access token] |
| Content-Type: application/json |
| Accept: application/json |
|
Example response
| 200 OK HTTP/1.1 |
| Content-Type: application/json |
|
Remove existing phone number from database permanently.
DELETE
http://crud.host/api/phone/{id}
| Name | Type | Optional | Description |
|---|---|---|---|
| id | int | ID of existing phone number |
Example response
| 200 OK HTTP/1.1 |
| Content-Type: application/json |
|