Categories & Subcategories
Access product categories and subcategories for organization
Categories & Subcategories
Access product categories and subcategories to organize and filter products effectively.
List Categories
Get all product categories available in the system.
Endpoint
GET /api/v1/categoriesAuthentication: API Key + Secret required
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| limit | number | No | Number of results per page (default: 50) |
| page | number | No | Page number to retrieve (default: 1) |
| include_subcategories | boolean | No | Include subcategories in response (default: false) |
| active_only | boolean | No | Only return active categories (default: true) |
Response
Response Headers
HTTP/1.1 200 OK
Content-Type: application/json
X-Page: 1
X-Per-Page: 50
X-Total-Count: 15
X-Total-Pages: 1
X-Page-Size: 3
X-Has-More: falseResponse Body
[
{
"id": 1,
"name": "Gift Cards",
"slug": "gift-cards",
"description": "Digital and physical gift cards for retail stores",
"icon": "gift-card",
"is_active": true,
"product_count": 1247,
"created_at": "2023-01-01T00:00:00Z",
"updated_at": "2023-01-01T00:00:00Z"
},
{
"id": 2,
"name": "Mobile Top-up",
"slug": "mobile-topup",
"description": "Mobile phone credit and data plans",
"icon": "mobile",
"is_active": true,
"product_count": 856,
"created_at": "2023-01-01T00:00:00Z",
"updated_at": "2023-01-01T00:00:00Z"
},
{
"id": 3,
"name": "Digital Services",
"slug": "digital-services",
"description": "Online services and subscriptions",
"icon": "cloud",
"is_active": true,
"product_count": 342,
"created_at": "2023-01-01T00:00:00Z",
"updated_at": "2023-01-01T00:00:00Z"
}
]Category Object
| Field | Type | Description |
|---|---|---|
| id | number | Unique category identifier |
| name | string | Category display name |
| slug | string | URL-friendly category identifier |
| description | string | Category description |
| icon | string | Icon identifier for UI |
| is_active | boolean | Whether category is currently active |
| product_count | number | Number of products in this category |
| created_at | string | ISO 8601 timestamp |
| updated_at | string | ISO 8601 timestamp |
With Subcategories
[
{
"id": 1,
"name": "Gift Cards",
"slug": "gift-cards",
"description": "Digital and physical gift cards for retail stores",
"icon": "gift-card",
"is_active": true,
"product_count": 1247,
"subcategories": [
{
"id": 101,
"name": "Retail Stores",
"slug": "retail-stores",
"description": "Gift cards for department stores and retailers",
"product_count": 523,
"is_active": true
},
{
"id": 102,
"name": "Restaurants",
"slug": "restaurants",
"description": "Gift cards for dining and food delivery",
"product_count": 287,
"is_active": true
}
],
"created_at": "2023-01-01T00:00:00Z",
"updated_at": "2023-01-01T00:00:00Z"
}
]Examples
# Get all categories
curl -X GET "{{host}}/api/v1/categories" \
-H "X-API-Key: sk_live_abc123def456" \
-H "X-API-Secret: your-secret-here"
# Get categories with subcategories
curl -X GET "{{host}}/api/v1/categories?include_subcategories=true" \
-H "X-API-Key: sk_live_abc123def456" \
-H "X-API-Secret: your-secret-here"List Subcategories
Get all subcategories, optionally filtered by parent category.
Endpoint
GET /api/v1/subcategoriesAuthentication: API Key + Secret required
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| category_id | number | No | Filter by parent category ID |
| limit | number | No | Number of results per page (default: 50) |
| page | number | No | Page number to retrieve (default: 1) |
| active_only | boolean | No | Only return active subcategories (default: true) |
Response
Response Headers
HTTP/1.1 200 OK
Content-Type: application/json
X-Page: 1
X-Per-Page: 50
X-Total-Count: 47
X-Total-Pages: 1
X-Page-Size: 2
X-Has-More: trueResponse Body
[
{
"id": 101,
"category_id": 1,
"name": "Retail Stores",
"slug": "retail-stores",
"description": "Gift cards for department stores and retailers",
"is_active": true,
"product_count": 523,
"category": {
"id": 1,
"name": "Gift Cards",
"slug": "gift-cards"
},
"created_at": "2023-01-01T00:00:00Z",
"updated_at": "2023-01-01T00:00:00Z"
},
{
"id": 102,
"category_id": 1,
"name": "Restaurants",
"slug": "restaurants",
"description": "Gift cards for dining and food delivery",
"is_active": true,
"product_count": 287,
"category": {
"id": 1,
"name": "Gift Cards",
"slug": "gift-cards"
},
"created_at": "2023-01-01T00:00:00Z",
"updated_at": "2023-01-01T00:00:00Z"
}
]Subcategory Object
| Field | Type | Description |
|---|---|---|
| id | number | Unique subcategory identifier |
| category_id | number | Parent category ID |
| name | string | Subcategory display name |
| slug | string | URL-friendly subcategory identifier |
| description | string | Subcategory description |
| is_active | boolean | Whether subcategory is currently active |
| product_count | number | Number of products in this subcategory |
| category | object | Parent category information |
| created_at | string | ISO 8601 timestamp |
| updated_at | string | ISO 8601 timestamp |
Examples
# Get all subcategories
curl -X GET "{{host}}/api/v1/subcategories" \
-H "X-API-Key: sk_live_abc123def456" \
-H "X-API-Secret: your-secret-here"
# Get subcategories for a specific category
curl -X GET "{{host}}/api/v1/subcategories?category_id=1" \
-H "X-API-Key: sk_live_abc123def456" \
-H "X-API-Secret: your-secret-here"Category Navigation UI
React Component Example
Search and Filter
Error Responses
401 Unauthorized
{
"error": "Unauthorized",
"message": "Invalid or expired access token"
}404 Not Found
{
"error": "Not Found",
"message": "Category not found"
}500 Internal Server Error
{
"error": "Internal Server Error",
"message": "An unexpected error occurred"
}Use Cases
Product Catalog Navigation
- Build hierarchical navigation menus
- Create category-based filtering systems
- Generate breadcrumb navigation
Analytics and Reporting
- Track popular categories and subcategories
- Monitor product distribution across categories
- Generate category-based sales reports
Admin Management
- Manage product categorization
- Update category metadata
- Monitor category performance
Next Steps
- Explore Products to see how categories are used
- Learn about filtering products by category in the products API
- Use categories to organize and search your product catalog