Term
Term
The Term class represents a single published term within a taxonomy. It provides methods to fetch the term, its localized versions, ancestors, and descendants.
Note There's no public constructor. Obtain a Term only through stack.Taxonomies(uid).Term(termUid), which already guarantees valid taxonomy and term UIDs.
SetLocale
The SetLocale method sets the locale for the term fetch request. Passing a null or empty value is treated as a no-op. Chain this method before calling Fetch.
| Name | Type | Description |
|---|---|---|
| locale | string | Locale code (for example, "hi-in" or "en-us") |
Validation
No exception is thrown for a null or empty locale. It's treated as a no-op.
Behavior
Client-side only. Sets a pending query parameter. No HTTP call is made until Fetch is called.
Example
ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment");
var term = await stack.Taxonomies("taxonomy_uid").Term("term_uid").SetLocale("hi-in").Fetch<MyTerm>();IncludeFallback
The IncludeFallback method falls back to the master locale when the term is not published in the requested locale. It can be used with or without SetLocale. Chain this method before calling Fetch.
Validation
Takes no parameters, so there's nothing to validate.
Behavior
Client-side only. Unconditionally sets include_fallback=true as a pending query parameter. No HTTP call is made until Fetch is called.
Example
ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment");
var term = await stack.Taxonomies("taxonomy_uid").Term("term_uid").SetLocale("hi-in").IncludeFallback().Fetch<MyTerm>();AddParam
The AddParam method adds a custom query parameter to the term fetch request. Chain this method before calling Fetch.
| Name | Type | Description |
|---|---|---|
| key (required) | string | Query parameter key |
| value (required) | string | Query parameter value |
Validation
No SDK-level null check is performed on key or value.
Behavior
Client-side only. Sets an arbitrary pending query parameter. No HTTP call is made until Fetch is called.
Example
ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment");
var term = await stack.Taxonomies("taxonomy_uid").Term("term_uid").AddParam("include_branch", "true").Fetch<MyTerm>();Depth
The Depth method limits the depth of the term hierarchy returned by Ancestors and Descendants. Depth(1) returns only immediate parents or children, higher values include deeper levels. Chain this method before calling Ancestors or Descendants.
| Name | Type | Description |
|---|---|---|
| depth (required) | int | Maximum number of hierarchy levels to include |
Validation
No SDK-level validation is performed on depth.
Behavior
Client-side only. Sets a pending query parameter. No HTTP call is made until Ancestors or Descendants is called.
Example
ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment");
var children = await stack.Taxonomies("taxonomy_uid").Term("term_uid").Depth(1).Descendants<JsonNode>();IncludeBranch
The IncludeBranch method includes branch information in the response for this term. Chain this method before calling Fetch, Ancestors, or Descendants.
Validation
Takes no parameters, so there's nothing to validate.
Behavior
Client-side only. Unconditionally sets include_branch=true as a pending query parameter. No HTTP call is made until Fetch, Ancestors, or Descendants is called.
Example
ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment");
var term = await stack.Taxonomies("taxonomy_uid").Term("term_uid").IncludeBranch().Fetch<MyTerm>();Fetch
The Fetch method fetches the published term from the CDA. It requires initialization via stack.Taxonomies("uid").Term("term_uid"). Use SetLocale, IncludeFallback, and AddParam to configure the request before calling Fetch.
Validation
No additional validation is performed. The taxonomy and term UIDs were already guaranteed non-empty when this Term was constructed through Taxonomy.Term(termUid). See Delivery API Errors for general request errors.
Behavior
Makes one HTTP GET request to /taxonomies/{uid}/terms/{termUid}. The response is unwrapped at the $.term JSON token before deserializing to T.
Example
ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment");
var term = await stack.Taxonomies("taxonomy_uid").Term("term_uid").Fetch<MyTerm>();
var localized = await stack.Taxonomies("taxonomy_uid").Term("term_uid").SetLocale("hi-in").Fetch<MyTerm>();
var withFallback = await stack.Taxonomies("taxonomy_uid").Term("term_uid").SetLocale("hi-in").IncludeFallback().Fetch<MyTerm>();Locales
The Locales method returns all locale versions in which this term has been published.
Validation
No additional validation is performed, the same construction-time guarantee as Fetch applies. See Delivery API Errors for general request errors.
Behavior
Makes one HTTP GET request to /taxonomies/{uid}/terms/{termUid}/locales. The response is unwrapped at the $.terms JSON token.
Note SetLocale, IncludeFallback, and AddParam set on this Term instance do not apply to Locales. Locale and fallback filtering doesn't make sense for "list every locale this term has." Locales always returns every published locale version, regardless of any modifiers chained on the Term.
Example
ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment");
var locales = await stack.Taxonomies("taxonomy_uid").Term("term_uid").Locales<JsonNode>();Ancestors
The Ancestors method returns all ancestor terms of this term up to the root of the taxonomy.
Validation
No additional validation is performed, the same construction-time guarantee as Fetch applies. See Delivery API Errors for general request errors.
Behavior
Makes one HTTP GET request to /taxonomies/{uid}/terms/{termUid}/ancestors. The response is unwrapped at the $.terms JSON token. Unlike Locales, this method does forward SetLocale, IncludeFallback, Depth, IncludeBranch, and AddParam set on the Term instance.
Example
ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment");
var ancestors = await stack.Taxonomies("taxonomy_uid").Term("term_uid").Ancestors<JsonNode>();
var localizedAncestors = await stack.Taxonomies("taxonomy_uid").Term("term_uid").SetLocale("hi-in").IncludeFallback().Depth(2).Ancestors<JsonNode>();Descendants
The Descendants method returns all child terms beneath this term in the taxonomy hierarchy.
Validation
No additional validation is performed, the same construction-time guarantee as Fetch applies. See Delivery API Errors for general request errors.
Behavior
Makes one HTTP GET request to /taxonomies/{uid}/terms/{termUid}/descendants. The response is unwrapped at the $.terms JSON token. Unlike Locales, this method does forward SetLocale, IncludeFallback, Depth, IncludeBranch, and AddParam set on the Term instance.
Example
ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment");
var descendants = await stack.Taxonomies("taxonomy_uid").Term("term_uid").Descendants<JsonNode>();
var directChildren = await stack.Taxonomies("taxonomy_uid").Term("term_uid").Depth(1).Descendants<JsonNode>();