Get Categories
Retrieve a list of all available item categories and subcategories within the Presto system.
Overview
This endpoint allows you to fetch the category hierarchy that can be used when creating or updating items. Understanding the available categories helps ensure items are classified correctly.
Endpoint Details
Method: GET
URL: /api/developer/v1/categories
Authentication: Bearer Token Required
Pagination
This endpoint supports pagination. Check the meta object in the response for pagination details (current_page, last_page, per_page, total). You can use query parameters like ?page=2 to fetch subsequent pages.
Request Specification
Query Parameters (Optional)
| Parameter | Type | Description |
|---|---|---|
page | integer | The page number to retrieve for pagination. Defaults to 1. |
per_page | integer | The number of categories to return per page. Defaults may apply. |
Example Request
GET /api/developer/v1/categories?page=1
Authorization: Bearer <your-token>
Accept: application/json
Response Specification
Success Response (200 OK)
{
"data": [
{
"id": 816,
"name": {
"ar": "سناك",
"en": "Snack"
}
},
{
"id": 817,
"name": {
"ar": "سناك امريكي",
"en": "American Snack"
},
"parent": {
"id": 816,
"name": {
"ar": "سناك",
"en": "Snack"
}
}
},
// ... more categories
],
"meta": {
"current_page": 1,
"from": 1,
"last_page": 2,
"per_page": 100,
"to": 100,
"total": 140
}
}
Response Fields (data array objects)
| Field | Type | Description |
|---|---|---|
id | integer | Unique identifier for the category. |
name | object | Contains the category name in different languages. |
name.ar | string | Category name in Arabic. |
name.en | string | Category name in English. |
parent | object | (Optional) Information about the parent category, if this is a subcategory. |
parent.id | integer | Unique identifier of the parent category. |
parent.name | object | Contains the parent category name in different languages. |
parent.name.ar | string | Parent category name in Arabic. |
parent.name.en | string | Parent category name in English. |
Response Fields (meta object)
| Field | Type | Description |
|---|---|---|
current_page | integer | The current page number being displayed. |
from | integer | The index of the first item on the current page. |
last_page | integer | The total number of pages available. |
per_page | integer | The maximum number of items returned per page. |
to | integer | The index of the last item on the current page. |
total | integer | The total number of categories available across all pages. |
Error Responses
401 Unauthorized - Authentication issues
{
"status": "error",
"message": "Unauthenticated."
}
{
"status":"error",
"message": "An unexpected error occurred on the server"
}
Implementation Tips
- Cache the category list locally if it doesn't change frequently to reduce API calls.
- When creating items, use the appropriate category ids obtained from this endpoint.
- Handle pagination correctly if you have a large number of categories.