GET /wp-json/content-api/v1/product-categories/
Retrieves all product categories in a hierarchical structure.
Authentication
This endpoint requires a Bearer token in the Authorization
header. To authenticate:
- Go to Content API > Settings in your WordPress admin panel.
- Set a secure token in the “Token” field and save it.
- Include the token in your request header as follows:
Authorization: Bearer <your-token-here>
Replace <your-token-here>
with the token you configured.
Parameters
No parameters are required for this endpoint.
Example Request
GET /wp-json/content-api/v1/product-categories/
Example Response
{
"success": true,
"categories": [
{
"id": 15,
"name": "Clothing",
"slug": "clothing",
"children": [
{
"id": 16,
"name": "T-Shirts",
"slug": "t-shirts",
"children": []
}
]
}
]
}
Possible Errors
Code | Message | Description | HTTP Status |
---|---|---|---|
not_authorized | Not Authorized | The provided Bearer token is invalid or does not match the configured token. | 401 |
fetch_failed | Failed to fetch categories | An error occurred while retrieving the categories. | 500 |