Appearance
Response structure
Explore the structure of our API, let's look at some status responses and errors codes.
Success response
Success response comes with HTTP status 2xx
, and its structure is like below :
json
{
"status": "success",
"data" : [...],
"meta" : {
"pagination" : {
"total": 100,
"count": 10,
"per_page": 10,
"current_page": 1,
"total_pages": 1,
"links": {
"next": "<baseUrl>/<version>/<endpoint>?page=2",
"previous": null,
"first": "<baseUrl>/<version>/<endpoint>?page=1",
"last": "<baseUrl>/<version>/<endpoint>?page=10",
}
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
The success response is organized into three parts: "status" indicates success, "data" holds the requested information, and "meta" offers extra details.
Meta
In success response "meta" provides extra details such as pagination
Pagination
Pagination details comes in meta object with pagination information's :
Field | Description |
---|---|
total | Total number of items in the dataset. |
count | Number of items on the current page. |
per_page | Number of items per page. |
current_page | The current page number being viewed. |
total_pages | Total number of pages based on page size. |
links.next | Link to the next page of results, if available. |
links.previous | Link to the previous page of results, if available. |
links.first | Link to the first page. |
links.last | Link to the last page. |
Error response
Error response comes with HTTP status 3xx
, 4xx
, 5xx
and its structure is like below :
json
{
"status": "error",
"message" : "error message",
"code" : "XXX"
}
1
2
3
4
5
2
3
4
5
The error response consists of three parts: "status" marks the error, "message" explains the issue, and "code" provides a unique identifier for swift resolution.
Custom errors
In some contexts, the API may return errors with specific codes, below some examples
Error Code | Description |
---|---|
10005 | Currency was not found |
20000 | lead already exists in the system |