This document outlines the expected response formats for successful and error responses from the API.
The API responses follow a common schema:
There are two main types of successful responses: with pagination and without pagination. Both responses share a common structure with slight variations.
{
"status": 200,
"message": "success",
"data": {
"products": [
{
"id": 1,
"name": "Product A",
"price": 10.99
},
{
"id": 2,
"name": "Product B",
"price": 15.5
},
{
"id": 3,
"name": "Product C",
"price": 7.25
}
],
"meta": {
"current_page": 1,
"per_page": 3,
"total_pages": 10,
"total_count": 30
}
},
"errors": {}
}{
"status": 200,
"message": "Product created sucessfully",
"data": {
"product": {
"id": 1,
"name": "Product A",
"price": 10.99
}
},
"errors": {}
}{
"status": 400,
"message": "Validation failed",
"errors": {
"name": [
"Name cannot be empty"
],
"price": [
"Price must be a number"
]
},
"data": {}
}{
"status": 401,
"message": "You are not authorized to access this resource. Please login or check your credentials."
}