Get subcategory by ID
Retrieve a single subcategory by ID. Use the include parameter to also receive the subcategory’s direct children and/or its ancestor breadcrumb chain. Accepts both publishable and secret API keys.
curl --request GET \
--url https://api.tybritelabs.com/v1/subcategories/{id} \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.tybritelabs.com/v1/subcategories/{id}"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.tybritelabs.com/v1/subcategories/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.tybritelabs.com/v1/subcategories/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.tybritelabs.com/v1/subcategories/{id}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.tybritelabs.com/v1/subcategories/{id}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tybritelabs.com/v1/subcategories/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"id": "6dbda630-ad89-4659-a5ef-3b0aae0dba7b",
"category_id": "7bf671dd-f49e-492c-b89f-a2892931f88f",
"parent_id": "c62e2103-7bf1-4dc3-996d-22f937d42147",
"name": "Keyboards",
"image": "https://images.unsplash.com/photo-1587829741301-dc798b83add3?w=800&q=80",
"active": true
}Authorizations
API Key Authentication
Use your API key in the Authorization header:
Authorization: Bearer tybrite_sk_live_YOUR_KEY
Key Types:
Secret Keys (Server-Side Only):
- Format:
tybrite_sk_live_*(production) ortybrite_sk_test_*(sandbox) - Full read/write access to all endpoints
- ⚠️ NEVER expose in client-side code or public repositories
- Required for: every write a shopper does not make for themselves, authentication, payment verification, AI recommendations
Publishable Keys (Client-Safe):
- Format:
tybrite_pk_live_*(production) ortybrite_pk_test_*(sandbox) - Catalogue reads, plus the actions a shopper takes for themselves
- ✅ Safe for client-side JavaScript, mobile apps, and public code
- Allowed for: browsing products, search, CMS content, pricing queries, cart and wishlist, reviews, storefront events, and the Agent API's quotes, cart drafts and checkout intents
Endpoint-Specific Requirements:
- Authentication endpoints (
/v1/auth/*): Secret key required - Payment verification (
POST /v1/payments/verify): Secret key required - AI Recommendations (
POST /v1/recommendations): Secret key required - Semantic Search (
POST /v1/search): Both key types allowed (read-only operation) - Shopper actions (cart, wishlist, reviews, storefront events, Agent API quotes, cart drafts and checkout intents): Both key types allowed
- All other write operations: Secret key required
- All read operations: Both key types allowed
Using a publishable key for restricted operations returns 403 Forbidden.
Path Parameters
Query Parameters
Comma-separated list of related data to nest on the response. Supported values: children (the subcategory's direct, one-level-down child subcategories, as a children array) and ancestors (the breadcrumb chain as an ancestors array ordered root-first). The trail begins with the owning category and continues down to the immediate parent, so a top-level subcategory returns a single entry: its category. Each entry carries a type of category or subcategory, because the two are different resources — a category is addressed on /v1/categories and a subcategory on /v1/subcategories — and a client linking a crumb needs to know which it holds. Combine them, e.g. include=ancestors,children. Omit for a flat subcategory object.
"ancestors,children"
Comma-separated list of fields to include in the response.
Response
Success
ID of the parent subcategory, or null for a top-level subcategory directly under its category. Subcategories can be nested to arbitrary depth (e.g. Shoes → Men's → Sneakers).
"Keyboards"
URL-safe identifier for the subcategory, stable across renames. Unique within its store, category and parent; where two names in that scope would produce the same slug, a numeric suffix is appended.
"keyboards"
URL of the subcategory image
Whether the subcategory is active
Nested child subcategories. Only included when listing subcategories with tree=true, or when fetching a single subcategory with include=children; omitted otherwise.
Ancestor breadcrumb chain, ordered root-first. Begins with the owning category and continues down to the immediate parent, so a top-level subcategory returns one entry: its category. Each entry carries a type of category or subcategory — the two are addressed on different endpoints, so a client linking a crumb needs to know which it holds. Only included when fetching a single subcategory with include=ancestors.
Which level of the taxonomy this entry is. Present on entries of an ancestors chain, where both levels appear; omitted on an ordinary subcategory object.
category, subcategory curl --request GET \
--url https://api.tybritelabs.com/v1/subcategories/{id} \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.tybritelabs.com/v1/subcategories/{id}"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.tybritelabs.com/v1/subcategories/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.tybritelabs.com/v1/subcategories/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.tybritelabs.com/v1/subcategories/{id}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.tybritelabs.com/v1/subcategories/{id}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.tybritelabs.com/v1/subcategories/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"id": "6dbda630-ad89-4659-a5ef-3b0aae0dba7b",
"category_id": "7bf671dd-f49e-492c-b89f-a2892931f88f",
"parent_id": "c62e2103-7bf1-4dc3-996d-22f937d42147",
"name": "Keyboards",
"image": "https://images.unsplash.com/photo-1587829741301-dc798b83add3?w=800&q=80",
"active": true
}
