header

Magento 1.x Software Support Notice

For Magento Commerce 1, Magento is providing software support through June 2020. Depending on your Magento Commerce 1 version, software support may include both quality fixes and security patches. Please review our Magento Software Lifecycle Policy to see how your version of Magento Commerce 1 is supported.

For Magento Open Source 1.5 to 1.9, Magento is providing software security patches through June 2020 to ensure those sites remain secure and compliant. Visit our information page for more details about our software maintenance policy and other considerations for your business.

Product Categories

Edit this page on GitHub

REST API: Product Categories

URI: /products/productid/categories

Allows you to retrieve information about assigned categories, assign, and unassign a category from/to a product.

URL Structure: http://magentohost/api/rest/products/productid/categories
Version: 1

HTTP Method: GET

Description: Allows you to retrieve information about categories assigned to the specified product.

Authentication: Admin, Customer
Default Format: JSON
Parameters:
No Parameters

Example:

GET http://magentohost/api/rest/products/8/categories

Response Body:

{
     category_id: 8
}
HTTP Method: POST

Description: Allows you to assign a category to a specified product.

Authentication: Admin
Default Format: JSON
Parameters:

Name Description Required Type Example Value
category_id The category ID required int 2

Example:

POST http://magentohost/api/rest/products/8/categories

Request Body:

{
"category_id":"2"
}

As a result, the category with ID equal to 2 will be assigned to the specified product.

URI: /products/productid/categories/categoryid

HTTP Method: DELETE

Description: Allows you to unassign a category from a specified product.

Authentication: Admin
Default Format: JSON
Parameters:
No Parameters

Example:

DELETE http://magentohost/api/rest/products/8/categories/2

Possible HTTP Status Codes

Status Code Message Description
400 Product <product ID> is already assigned to category <category ID> The message is returned when the required category is already assigned to the product
400 Category not found The specified category is not found
405 Resource method not implemented yet The specified method is not implemented yet