Skip to main content

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)​

ParameterTypeDescription
pageintegerThe page number to retrieve for pagination. Defaults to 1.
per_pageintegerThe 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)​

FieldTypeDescription
idintegerUnique identifier for the category.
nameobjectContains the category name in different languages.
name.arstringCategory name in Arabic.
name.enstringCategory name in English.
parentobject(Optional) Information about the parent category, if this is a subcategory.
parent.idintegerUnique identifier of the parent category.
parent.nameobjectContains the parent category name in different languages.
parent.name.arstringParent category name in Arabic.
parent.name.enstringParent category name in English.

Response Fields (meta object)​

FieldTypeDescription
current_pageintegerThe current page number being displayed.
fromintegerThe index of the first item on the current page.
last_pageintegerThe total number of pages available.
per_pageintegerThe maximum number of items returned per page.
tointegerThe index of the last item on the current page.
totalintegerThe total number of categories available across all pages.

Error Responses​

401 Unauthorized - Authentication issues

{
"status": "error",
"message": "Unauthenticated."
}
500 Internal Server Error
{
"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.