API
Categories
List the category facets of your catalog
# Categories > List the category facets of your catalog - Page: https://tbit.app/docs/api/categories - Base URL: `https://rest-api.tbit.app/v1` - Authentication: `X-API-Key` header with your key on every request (the examples read it from the `TBIT_API_KEY` environment variable) ## Overview Categories are facets derived from the category_tags of your active products. Each category includes the number of products tagged with it. Use the category name as the tag parameter when listing products. ## Endpoints | Method | Path | Description | | --- | --- | --- | | `GET` | `/v1/categories` | List category facets | ## List Categories `GET /v1/categories` ```bash curl "https://rest-api.tbit.app/v1/categories" \ -H "X-API-Key: $TBIT_API_KEY" ``` ## Response Format Categories with their product counts, plus the total number of active items in the catalog: ```json { "data": { "categories": [ { "name": "fiestas", "count": 42 }, { "name": "infantil", "count": 27 }, { "name": "decoracion", "count": 18 } ], "total_items": 134 } } ```Categories are facets derived from the category_tags of your active products. Each category includes the number of products tagged with it. Use the category name as the tag parameter when listing products.
| Method | Path | Description |
|---|---|---|
| GET | /v1/categories | List category facets |
/v1/categoriescurl "https://rest-api.tbit.app/v1/categories" \
-H "X-API-Key: $TBIT_API_KEY"const response = await fetch('https://rest-api.tbit.app/v1/categories', {
headers: {
'X-API-Key': process.env.TBIT_API_KEY,
},
});
const data = await response.json();import axios from 'axios';
const { data } = await axios.get(
'https://rest-api.tbit.app/v1/categories',
{
headers: {
'X-API-Key': process.env.TBIT_API_KEY,
},
},
);import os
import requests
response = requests.get(
'https://rest-api.tbit.app/v1/categories',
headers={'X-API-Key': os.environ['TBIT_API_KEY']},
)
data = response.json()<?php
$ch = curl_init('https://rest-api.tbit.app/v1/categories');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'X-API-Key: ' . getenv('TBIT_API_KEY'),
],
]);
$data = json_decode(curl_exec($ch), true);
curl_close($ch);Categories with their product counts, plus the total number of active items in the catalog:
{
"data": {
"categories": [
{ "name": "fiestas", "count": 42 },
{ "name": "infantil", "count": 27 },
{ "name": "decoracion", "count": 18 }
],
"total_items": 134
}
}