Relationships

You can use the Categories API to associate categories with each other in a hierarchical tree structure. The relationship between Categories is known as parents and children.

get
Get the Categories tree

https://api.moltin.com/v2/categories/tree
Request
Response
Headers
Authorization
required
string
The Bearer token to grant access to the API
200: OK
{
"data": [
{
"id": "a636c261-0259-4975-ac8e-77246ec9cfe0",
"type": "category",
"status": "live",
"name": "Unique",
"slug": "unique",
"description": "Unique Category"
},
{
"id": "b8fac5c9-8605-48d0-bcf7-e6ada1a8c6bd",
"type": "category",
"status": "live",
"name": "Modern",
"slug": "modern",
"description": "Modern Category"
},
{
"id": "521e6029-0e0e-4704-b9a5-9777047ada04",
"type": "category",
"status": "live",
"name": "Bright",
"slug": "bright",
"description": "Bright Category"
}
]
}
cURL
JavaScript SDK
Swift SDK
curl -X GET https://api.moltin.com/v2/categories/tree \
-H "Authorization: Bearer XXXX"
const MoltinGateway = require('@moltin/sdk').gateway
const Moltin = MoltinGateway({
client_id: 'X'
})
Moltin.Categories.Tree().then(categories => {
// Do something
})
let moltin = Moltin(withClientID: "<your client ID>")
moltin.category.tree { result in
switch result {
case .success(let response):
print(response)
case .failure(let error):
print(error)
}
}