Beehexa will show you How to create and retrieve a category; you can create and retrieve a category with all the information you want using Postman.
I. Creates a Category.
Use this endpoint when an API only works with categories of a default BigCommerce storefront (channel_id=1). Use the Create Categories endpoint when an API works with categories across different category trees that belong to different storefront channels.
Note: There are Limits related to the category:
- 16,000 categories per store limit.
- 1,000 categories per product limit.
- 50 characters category name length.
- 8 levels of category depth limit.
- 65,642 characters category description length limit.
We will create a category in BigCommerce using Postman.
So, Log in Postman account and then choose a workspace
Now, we are ready to create a category using Postman.
Select POST and paste the URL:
https://api.bigcommerce.com/stores/{store_hash}/v3/catalog/categories
Replace {store_hash} with your store_hash generated on BigCommerce from the API path.
- In the Header section, you need to declare the information :
- Accept : application/json
- Content-Type : application/json
- X-Auth-Token: Access token
- X-Auth-Client: Client ID
- In the Body section
Click on โrawโ to fill in the data; remember to change the โtextโ to โJSON.โ
Remember, a category can be created with an existing catalog product or a custom product.
Required Fields:
- parent_id:
- To create a child category, set the parent_id to the parent category.
- To create a top-level category, set the parent_id to 0.
- name:
I will show you our example below, and you can create your category
{
"name": "HexaSync",
"description": "<p>Integration Platform</p>",
"views": 28,
"sort_order": 3,
"meta_keywords": [],
"layout_file": "category.html",
"is_visible": true,
"default_product_sort": "use_store_settings",
"image_url": "",
"parent_id": 0,
"custom_url": {
"url": "/hexasync/",
"is_customized":true
}
}
Code language: JSON / JSON with Comments (json)
Response: The API will return the data like this.
"id": 29,
"parent_id": 0,
"name": "HexaSync",
"description": "<p>Integration Platform</p>",
"views": 28,
"sort_order": 3,
"page_title": "",
"meta_keywords": [
""
],
"meta_description": "",
"layout_file": "category.html",
"image_url": "",
"is_visible": true,
"search_keywords": "",
"default_product_sort": "use_store_settings",
"custom_url": {
"url": "/hexasync/",
"is_customized": true
}
}
],
"meta": {
"pagination": {
"total": 9,
"count": 9,
"per_page": 50,
"current_page": 1,
"total_pages": 1,
"links": {
"current": "?page=1&limit=50"
}
}
}
}
Code language: JavaScript (javascript)
II. Retrieve all categories
First of all, select GET and paste the URL:
https://api.bigcommerce.com/stores/{store_hash}/v3/catalog/categories
If you want to retrieve just one product data, past the URL with the structure:
https://api.bigcommerce.com/stores/{store_hash}/v3/catalog/categories
Replace {store_hash} with your store hash generated on BigCommerce from the API path.
Replace {category_id} with the category ID you get when you create the category
In the Header section, you need to declare the information:
- X-Auth-Token: Access token
Then click send.
Response: The API will return the data like this.
{
"data": [
{
"id": 18,
"parent_id": 0,
"name": "Bath",
"description": "",
"views": 0,
"sort_order": 1,
"page_title": "",
"meta_keywords": [
""
],
"meta_description": "",
"layout_file": "category_with_facets.html",
"image_url": "",
"is_visible": true,
"search_keywords": "",
"default_product_sort": "use_store_settings",
"custom_url": {
"url": "/bath/",
"is_customized": false
}
},
{
"id": 19,
"parent_id": 0,
"name": "Garden",
"description": "",
"views": 0,
"sort_order": 2,
"page_title": "",
"meta_keywords": [
""
],
"meta_description": "",
"layout_file": "category_with_facets.html",
"image_url": "",
"is_visible": true,
"search_keywords": "",
"default_product_sort": "use_store_settings",
"custom_url": {
"url": "/garden/",
"is_customized": false
}
},
{
"id": 20,
"parent_id": 0,
"name": "Publications",
"description": "",
"views": 0,
"sort_order": 4,
"page_title": "",
"meta_keywords": [
""
],
"meta_description": "",
"layout_file": "category_with_facets.html",
"image_url": "",
"is_visible": true,
"search_keywords": "",
"default_product_sort": "use_store_settings",
"custom_url": {
"url": "/publications/",
"is_customized": false
}
},
{
"id": 21,
"parent_id": 0,
"name": "Kitchen",
"description": "",
"views": 0,
"sort_order": 3,
"page_title": "",
"meta_keywords": [
""
],
"meta_description": "",
"layout_file": "category_with_facets.html",
"image_url": "",
"is_visible": true,
"search_keywords": "",
"default_product_sort": "use_store_settings",
"custom_url": {
"url": "/kitchen/",
"is_customized": false
}
},
{
"id": 22,
"parent_id": 0,
"name": "Utility",
"description": "",
"views": 0,
"sort_order": 5,
"page_title": "",
"meta_keywords": [
""
],
"meta_description": "",
"layout_file": "category_with_facets.html",
"image_url": "",
"is_visible": true,
"search_keywords": "",
"default_product_sort": "use_store_settings",
"custom_url": {
"url": "/utility/",
"is_customized": false
}
},
{
"id": 23,
"parent_id": 0,
"name": "Shop All",
"description": "",
"views": 0,
"sort_order": 0,
"page_title": "",
"meta_keywords": [
""
],
"meta_description": "",
"layout_file": "category_with_facets.html",
"image_url": "",
"is_visible": true,
"search_keywords": "",
"default_product_sort": "use_store_settings",
"custom_url": {
"url": "/shop-all/",
"is_customized": false
}
},
{
"id": 24,
"parent_id": 23,
"name": "test_category",
"description": "<p>it's cheap plastic with minimal toxic fumes</p>",
"views": 105,
"sort_order": 3,
"page_title": "",
"meta_keywords": [
""
],
"meta_description": "",
"layout_file": "category.html",
"image_url": "",
"is_visible": true,
"search_keywords": "",
"default_product_sort": "use_store_settings",
"custom_url": {
"url": "/test_category/",
"is_customized": false
}
},
{
"id": 26,
"parent_id": 23,
"name": "chau_category",
"description": "<p>it's cheap plastic with minimal toxic fumes</p>",
"views": 150,
"sort_order": 3,
"page_title": "",
"meta_keywords": [
""
],
"meta_description": "",
"layout_file": "category.html",
"image_url": "",
"is_visible": true,
"search_keywords": "",
"default_product_sort": "use_store_settings",
"custom_url": {
"url": "/chau_category/",
"is_customized": false
}
},
{
"id": 29,
"parent_id": 0,
"name": "HexaSync",
"description": "<p>Integration Platform</p>",
"views": 28,
"sort_order": 3,
"page_title": "",
"meta_keywords": [
""
],
"meta_description": "",
"layout_file": "category.html",
"image_url": "",
"is_visible": true,
"search_keywords": "",
"default_product_sort": "use_store_settings",
"custom_url": {
"url": "/hexasync/",
"is_customized": true
}
}
],
"meta": {
"pagination": {
"total": 9,
"count": 9,
"per_page": 50,
"current_page": 1,
"total_pages": 1,
"links": {
"current": "?page=1&limit=50"
}
}
}
}
Code language: JSON / JSON with Comments (json)
In conclusion, the above are all steps to create and retrieve a category on BigCommerce with Postman. Please comment below or refer to our BigCommerce API documentation if you have any questions.
Finally, I hope you can achieve it!
You can see these steps visually in the video below: