List and Search
GET /categories
The Categories API exposes just one endpoint /categories .
Categories are expressed in a hierarchical structure, each category may have one or more child categories as-determined by the has_children property. You can retrieve the child categories of a given category by passing the parent category ID in the parent_id parameter.
To retrieve the top-level categories make a request without any parent_id . Top-level categories have their is_root=true property set to true.
The following querystring (HTTP GET) parameters allow you to refine the results returned by the Categories API.
Parameter | Required | Description |
---|---|---|
api_key | required | The API key for your account. |
id | optional | A single ID of the category to retrieve. Note that id cannot be used when parent_id or search_term are used. |
parent_id | optional | The ID of the parent category to retrieve child categories for. Note that parent_id cannot be used when id or search_term are used. |
search_term | optional | Searches the entire category hierarchy for categories containing the search_term i.e. search_term=appliances (to return only categories containing the string appliances ). Note that search_term cannot be used when id or parent_id are used. |
The Categories API returns the following properties:
Property | Type | Description |
---|---|---|
categories | array | An array of Category objects containing details of a given category. The categories array is present when either the parent_id or search_term request parameters are used.
|
current_category | object | An object with the same properties as the category objects in the categories array showing details of the current category. Note that current_category is only present when a request is made using the parent_id request parameter (i.e. when retrieving child categories for a given parent_id ). |
parent_category | object | An object with the same properties as the category objects in the categories array showing details of the parent category. Note that parent_category is only present when a request is made using the parent_id request parameter (i.e. when retrieving child categories for a given parent_id ). parent_category shows details of the category that is the parent of the category specified in parent_id . Note parent_category is not returned if the category specified in the parent_id request parameter is is_root=true . |
category | object | An object with the same properties as the category objects in the categories array showing details of the single category requested by the id parameter. Note that category is only present when a request is made using the id request parameter (i.e. when retrieving details of a single category). |
In the example below we retrieve all top-level (root) categories:
The Categories API responds with the top-level (root) categories in the categories property.
In the example below we retrieve child categories for a parent category with ID 7C1CC4ED255D79EFAECC18C1D4DE912C77C00401 :
The Categories API responds with the child categories for parent category with ID 7C1CC4ED255D79EFAECC18C1D4DE912C77C00401 in the categories property.
Next Steps Categories API Overview