Category API
Overview
The Category API provides endpoints for managing product categories in your EverShop store. Categories help organize your product catalog into a hierarchical structure, improving navigation and product discoverability for your customers.
Endpoints
Create a Category
Creates a new product category in the system. Categories can be organized in a hierarchical structure by specifying a parent category.
| Field Name | Field Type | Required | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| name | string | Yes | ||||||||||||||||||||||||||||||
| description | array of object | Yes | ||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||
| image | string | No | ||||||||||||||||||||||||||||||
| meta_title | string | Yes | ||||||||||||||||||||||||||||||
| meta_description | string | Yes | ||||||||||||||||||||||||||||||
| meta_keywords | string | No | ||||||||||||||||||||||||||||||
| url_key | string (^\S+$) | No | ||||||||||||||||||||||||||||||
| status | integer or string (0, 1, '0', '1') | Yes | ||||||||||||||||||||||||||||||
| include_in_nav | integer or string (0, 1, '0', '1') | No | ||||||||||||||||||||||||||||||
| parent_id | string or number or null | No | ||||||||||||||||||||||||||||||
| position | string or integer | No | ||||||||||||||||||||||||||||||
- cURL
- JavaScript
curl
-H "Accept: application/json"
-H "Authorization: Bearer <admin JWT token>"
--data-raw '<JSON DATA>'
https://<your domain>/api/categories
fetch('https://<your domain>/api/categories', {
headers: {
'Accept': 'application/json',
'Authorization': 'Bearer <admin JWT token>'
},
body: <JSON DATA>
})
.then(response => response.json())
.then(data => {
if(data.error) {
// Handle the error
} else {
// Handle the data
}
})
.catch(error => {
// Handle the error
});
{
"data": {
"category_id": 103,
"uuid": "9ab75946a63211edb46b60d819134f39",
"status": 1,
"parent_id": 16,
"include_in_nav": 0,
"position": 22,
"created_at": "2023-02-07 00:01:47",
"updated_at": "2023-02-07 00:01:47",
"category_description_id": 82,
"category_description_category_id": 103,
"name": "Athletic Shoes",
"short_description": null,
"description": "High-performance athletic shoes for sports and training",
"image": "/assets/catalog/categories/athletic-shoes.jpg",
"meta_title": "Athletic Shoes | Performance Footwear",
"meta_keywords": "athletic shoes, running shoes, training footwear",
"meta_description": "Shop our selection of high-performance athletic shoes for all your training needs",
"url_key": "athletic-shoes",
"links": [
{
"rel": "categoryGrid",
"href": "/admin/categories",
"action": "GET",
"types": [
"text/xml"
]
},
{
"rel": "view",
"href": "/category/athletic-shoes",
"action": "GET",
"types": [
"text/xml"
]
},
{
"rel": "edit",
"href": "/admin/categories/edit/9ab75946a63211edb46b60d819134f39",
"action": "GET",
"types": [
"text/xml"
]
}
]
}
}
Update a Category
Modifies an existing product category. You can update any of the category attributes, including its hierarchical position in the catalog.
| Field Name | Field Type | Required | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| name | string | Yes | ||||||||||||||||||||||||||||||
| description | array of object | Yes | ||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||
| image | string | No | ||||||||||||||||||||||||||||||
| meta_title | string | Yes | ||||||||||||||||||||||||||||||
| meta_description | string | Yes | ||||||||||||||||||||||||||||||
| meta_keywords | string | No | ||||||||||||||||||||||||||||||
| url_key | string (^\S+$) | No | ||||||||||||||||||||||||||||||
| status | integer or string (0, 1, '0', '1') | Yes | ||||||||||||||||||||||||||||||
| include_in_nav | integer or string (0, 1, '0', '1') | No | ||||||||||||||||||||||||||||||
| parent_id | string or number or null | No | ||||||||||||||||||||||||||||||
| position | string or integer | No | ||||||||||||||||||||||||||||||
- cURL
- JavaScript
curl
-H "Accept: application/json"
-H "Authorization: Bearer <admin JWT token>"
--data-raw '<JSON DATA>'
https://<your domain>/api/categories/433ba97f-8be7-4be9-be3f-a9f341f2b89f
fetch('https://<your domain>/api/categories/433ba97f-8be7-4be9-be3f-a9f341f2b89f', {
headers: {
'Accept': 'application/json',
'Authorization': 'Bearer <admin JWT token>'
},
body: <JSON DATA>
})
.then(response => response.json())
.then(data => {
if(data.error) {
// Handle the error
} else {
// Handle the data
}
})
.catch(error => {
// Handle the error
});
{
"data": {
"category_id": 103,
"uuid": "9ab75946a63211edb46b60d819134f39",
"status": 1,
"parent_id": 16,
"include_in_nav": 1,
"position": 22,
"created_at": "2023-02-07 00:01:47",
"updated_at": "2023-02-07 00:01:47",
"category_description_id": 82,
"category_description_category_id": 103,
"name": "Athletic Shoes",
"short_description": null,
"description": "High-performance athletic shoes for sports and training",
"image": "/assets/catalog/categories/athletic-shoes.jpg",
"meta_title": "Athletic Shoes | Performance Footwear",
"meta_keywords": "athletic shoes, running shoes, training footwear",
"meta_description": "Shop our selection of high-performance athletic shoes for all your training needs",
"url_key": "athletic-shoes",
"links": [
{
"rel": "categoryGrid",
"href": "/admin/categories",
"action": "GET",
"types": [
"text/xml"
]
},
{
"rel": "view",
"href": "/category/athletic-shoes",
"action": "GET",
"types": [
"text/xml"
]
},
{
"rel": "edit",
"href": "/admin/categories/edit/433ba97f-8be7-4be9-be3f-a9f341f2b89f",
"action": "GET",
"types": [
"text/xml"
]
}
]
}
}
Delete a Category
Permanently removes a product category from the system. Note that this does not automatically delete associated products.
- cURL
- JavaScript
curl
-H "Accept: application/json"
-H "Authorization: Bearer <admin JWT token>"
https://<your domain>/api/categories/433ba97f-8be7-4be9-be3f-a9f341f2b89f
fetch('https://<your domain>/api/categories/433ba97f-8be7-4be9-be3f-a9f341f2b89f', {
headers: {
'Accept': 'application/json',
'Authorization': 'Bearer <admin JWT token>'
}
})
.then(response => response.json())
.then(data => {
if(data.error) {
// Handle the error
} else {
// Handle the data
}
})
.catch(error => {
// Handle the error
});
{
"data": {
"category_id": 103,
"uuid": "433ba97f-8be7-4be9-be3f-a9f341f2b89f",
"status": 0,
"parent_id": 16,
"include_in_nav": 0,
"position": 22,
"created_at": "2023-02-07 00:01:47",
"updated_at": "2023-02-07 00:01:48",
"category_description_id": null,
"category_description_category_id": null,
"name": null,
"short_description": null,
"description": null,
"image": null,
"meta_title": null,
"meta_keywords": null,
"meta_description": null,
"url_key": null
}
}
Get Category Data with GraphQL
EverShop uses GraphQL for querying category data. For detailed information on how to query categories, refer to the GraphQL API documentation.