Subcategories
List product subcategories or retrieve a single subcategory by ID
GET /api/v1/subcategories
Returns all active product subcategories. Requires the vouchers feature to be enabled.
Request
curl {{host}}/api/v1/subcategories \
-H "Authorization: Bearer <token>"package main
import (
"encoding/json"
"fmt"
"net/http"
)
type SubCategory struct {
ID int `json:"id"`
Name string `json:"name"`
}
func main() {
req, _ := http.NewRequest("GET", "{{host}}/api/v1/subcategories", nil)
req.Header.Set("Authorization", "Bearer <token>")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
var subcategories []SubCategory
json.NewDecoder(resp.Body).Decode(&subcategories)
for _, s := range subcategories {
fmt.Printf("%d: %s\n", s.ID, s.Name)
}
}No query parameters.
Response
[
{
"id": 1,
"name": "Steam"
},
{
"id": 2,
"name": "PlayStation"
}
]Response Fields
| Key | Type | Description |
|---|---|---|
id | integer | Unique subcategory identifier |
name | string | Subcategory name |
Only active subcategories are returned.
Errors
400 Bad Request — Vouchers feature is not enabled for your client.
{
"error": {
"name": "BadRequestError",
"code": "INVALID_FEATURE",
"message": "The requested feature is not enabled for this client"
}
}403 Forbidden — Request IP not in whitelist.
{
"error": {
"name": "ForbiddenError",
"code": "FORBIDDEN",
"message": "IP address not authorized"
}
}500 Internal Server Error — Database query failed.
{
"error": {
"name": "InternalServerError",
"code": "INTERNAL_SERVER_ERROR",
"message": "Failed to retrieve subcategories"
}
}GET /api/v1/subcategories/:id
Returns a single subcategory by its ID. Requires the vouchers feature.
Request
curl {{host}}/api/v1/subcategories/1 \
-H "Authorization: Bearer <token>"req, _ := http.NewRequest("GET", "{{host}}/api/v1/subcategories/1", nil)
req.Header.Set("Authorization", "Bearer <token>")
resp, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer resp.Body.Close()
var sub SubCategory
json.NewDecoder(resp.Body).Decode(&sub)
fmt.Printf("%d: %s\n", sub.ID, sub.Name)Request Parameters
| Key | Type | Required | Description |
|---|---|---|---|
id | integer | Yes | Subcategory ID (path parameter) |
Response
{
"id": 1,
"name": "Steam"
}Response fields are identical to the list endpoint above.
Errors
400 Bad Request — Vouchers feature is not enabled for your client.
{
"error": {
"name": "BadRequestError",
"code": "INVALID_FEATURE",
"message": "The requested feature is not enabled for this client"
}
}404 Not Found — No active subcategory exists with this ID.
{
"error": {
"name": "NotFoundError",
"code": "NOT_FOUND",
"message": "Subcategory not found"
}
}Returned when the ID is invalid, the subcategory does not exist, or the subcategory is inactive.
403 Forbidden — Request IP not in whitelist.
{
"error": {
"name": "ForbiddenError",
"code": "FORBIDDEN",
"message": "IP address not authorized"
}
}