Category API
Use the REST API to interact with EverShop categories.
Create a category
Use this endpoint to create a category.
Request Schema (application/json)
Field Name | Field Type | Required |
---|---|---|
name | string | Yes |
description | string | Yes |
image | string | No |
meta_title | string | Yes |
meta_description | string | Yes |
meta_keywords | string | No |
url_key | string | Yes |
status | integer or string (0, 1, '0', '1') | Yes |
include_in_nav | integer or string (0, 1, '0', '1') | No |
parent_id | string or integer | No |
position | string or integer | No |
POST/api/categories
- cURL
- JavaScript
curl
-H "Accept: application/json"
-H "Cookie: asid=<your admin cookie>"
https://<your domain>/api/categories
fetch('https://<your domain>/api/categories', {
headers: {
'Accept': 'application/json',
'Cookie': 'asid=<your admin cookie>'
}
})
.then(response => response.json())
.then(data => {
if(data.error) {
// Handle the error
} else {
// Handle the data
}
})
.catch(error => {
// Handle the error
});
Sample Of Response
{
"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": "2sl0ifz1declc91p67h",
"short_description": null,
"description": "2sl0ifz1declc91p67i",
"image": "2sl0ifz1declc91p67j",
"meta_title": "2sl0ifz1declc91p67k",
"meta_keywords": "2sl0ifz1declc91p67m",
"meta_description": "2sl0ifz1declc91p67l",
"url_key": "2sl0ifz1declc91p67n",
"links": [
{
"rel": "categoryGrid",
"href": "/admin/categories",
"action": "GET",
"types": [
"text/xml"
]
},
{
"rel": "view",
"href": "/category/2sl0ifz1declc91p67n",
"action": "GET",
"types": [
"text/xml"
]
},
{
"rel": "edit",
"href": "/admin/categories/edit/9ab75946a63211edb46b60d819134f39",
"action": "GET",
"types": [
"text/xml"
]
}
]
}
}
Update a category
Use this endpoint to update a category.
Request Schema (application/json)
Field Name | Field Type | Required |
---|---|---|
name | string | No |
description | string | No |
image | string | No |
meta_title | string | No |
meta_description | string | No |
meta_keywords | string | No |
url_key | string | No |
status | integer or string (0, 1, '0', '1') | No |
include_in_nav | integer or string (0, 1, '0', '1') | No |
parent_id | string or integer | No |
position | string or integer | No |
PATCH/api/categories/{id}
- cURL
- JavaScript
curl
-H "Accept: application/json"
-H "Cookie: asid=<your admin cookie>"
https://<your domain>/api/categories/{id}
fetch('https://<your domain>/api/categories/{id}', {
headers: {
'Accept': 'application/json',
'Cookie': 'asid=<your admin cookie>'
}
})
.then(response => response.json())
.then(data => {
if(data.error) {
// Handle the error
} else {
// Handle the data
}
})
.catch(error => {
// Handle the error
});
Sample Of Response
{
"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": "2sl0ifz1declc91p67h",
"short_description": null,
"description": "2sl0ifz1declc91p67i",
"image": "2sl0ifz1declc91p67j",
"meta_title": "2sl0ifz1declc91p67k",
"meta_keywords": "2sl0ifz1declc91p67m",
"meta_description": "2sl0ifz1declc91p67l",
"url_key": "2sl0ifz1declc91p67n",
"links": [
{
"rel": "categoryGrid",
"href": "/admin/categories",
"action": "GET",
"types": [
"text/xml"
]
},
{
"rel": "view",
"href": "/category/2sl0ifz1declc91p67n",
"action": "GET",
"types": [
"text/xml"
]
},
{
"rel": "edit",
"href": "/admin/categories/edit/9ab75946a63211edb46b60d819134f39",
"action": "GET",
"types": [
"text/xml"
]
}
]
}
}
Delete a category
Use this endpoint to delete a category.
Request Schema (application/json)
No request body requiredDELETE/api/categories/{id}
- cURL
- JavaScript
curl
-H "Accept: application/json"
-H "Cookie: asid=<your admin cookie>"
https://<your domain>/api/categories/{id}
fetch('https://<your domain>/api/categories/{id}', {
headers: {
'Accept': 'application/json',
'Cookie': 'asid=<your admin cookie>'
}
})
.then(response => response.json())
.then(data => {
if(data.error) {
// Handle the error
} else {
// Handle the data
}
})
.catch(error => {
// Handle the error
});
Sample Of Response
{
"data": {
"category_id": 103,
"uuid": "9ab75946a63211edb46b60d819134f39",
"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
}
}