---
title: "Term"
description: "Term"
url: "https://www.contentstack.com/docs/developers/sdks/content-delivery-sdk/python/reference/term"
product: "Contentstack"
doc_type: "guide"
audience:
  - developers
  - admins
version: "current"
last_updated: "2026-10-15"
---

# Term

## Term

A term is one node in the hierarchy of a [taxonomy](/docs/headless-cms/about-taxonomy). Use this class to

*   read one term by its UID
*   list the localizations of that term
*   retrieve the ancestors or the descendants of that term

| Name | Type | Description |

| --- | --- | --- |

| taxonomy\_uid | str | UID of the taxonomy that holds the term. |

| term\_uid | str | UID of the term. |

stack.taxonomy('<TAXONOMY\_UID>').term('<TERM\_UID>') supplies both UIDs and returns a Term. Omit the term UID to get a TermQuery instead, which lists every term in the taxonomy. Term and TermQuery are separate classes with separate method sets. Calling find on a Term raises AttributeError, and calling fetch on a TermQuery raises AttributeError.

**Warning:** term('') returns a TermQuery, not a Term. The empty string is falsy, so it takes the no-UID branch of the factory method and the KeyError in the Term constructor never fires. A variable that is unexpectedly empty therefore produces a term listing instead of the fetch you intended. See the [term](/python-taxonomy-term) method on the Taxonomy class for the full explanation.

## ancestors

ancestors retrieves the terms above this one in the taxonomy hierarchy, up to the root.

```
The ancestor terms of this term.
Validationancestors validates nothing itself. The UID check happens earlier, in the constructor.stack.taxonomy('<TAXONOMY_UID>').term('') never reaches this method. The empty string is falsy, so the factory method returns a TermQuery, which has no ancestors, and the call raises AttributeError. See the Warning on the Term class page.ancestors raises an exception only for network failures (timeout, DNS error, dropped connection). The exception type is RequestError.An API-level rejection, including a UID that names no term, returns as a normal result with an error key. It does not raise an exception.Check the result for an error key even inside a try block.Additional Resource: Refer to Delivery API Errors for the full error code list.
BehaviorCalls GET /taxonomies/{taxonomy_uid}/terms/{term_uid}/ancestors and makes one HTTP request per call.Returns the contents of the terms key on success. Falls back to the whole response body when that key is absent. See the Class-Level Notes on the Term class page.Two return shapes reach you from that fallback. A successful call returns the list of ancestor terms, and a rejected call returns the error dictionary. 'error' in result is False for the list and True for the error body, so test it before you iterate.Chain the depth method to cap the number of levels the traversal covers. Without it the SDK sends no depth parameter and the API applies its own limit.An empty list is a valid result. Treat it as a term with no ancestors returned, not as a failure.Sends whatever locale, include_fallback, include_branch, and param recorded on the instance as well.LimitationsDoes not return this term itself. Call the fetch method for the term, or use the equal_and_above method on the Taxonomy class to match a term together with its ancestors.Does not filter entries. It returns terms. Entry filtering by term lives on the Taxonomy class.ExampleBasic usage: retrieve the ancestors of a termimport contentstack

stack = contentstack.Stack('<API_KEY>', '<DELIVERY_TOKEN>', '<ENVIRONMENT>')

try:
    result = stack.taxonomy('regions').term('paris').ancestors()
except Exception as error:
    # Raised only for network failures (timeout, DNS error, dropped connection)
    print('Request failed:', error)
else:
    if 'error' in result:
        # The Delivery API rejected the request and returned the error body
        print('Delivery API error:', result['error'])
    else:
        for term in result:
            print(term['uid'], term['name'])Capping the traversal with depthimport contentstack

stack = contentstack.Stack('<API_KEY>', '<DELIVERY_TOKEN>', '<ENVIRONMENT>')

try:
    # Return only the two nearest ancestors instead of the full path to the root.
    result = stack.taxonomy('regions').term('paris').depth(2).ancestors()
    print('ancestor count:', len(result))
except Exception as error:
    print('Request failed:', error)Edge case: handle an empty resultimport contentstack

stack = contentstack.Stack('<API_KEY>', '<DELIVERY_TOKEN>', '<ENVIRONMENT>')

try:
    result = stack.taxonomy('regions').term('europe').ancestors()

    # An empty list is a term with no ancestors returned, not a failed call.
    if isinstance(result, list) and not result:
        print('no ancestors for europe')
except Exception as error:
    print('Request failed:', error)
```

## depth

depth caps the number of hierarchy levels a traversal covers.

```
The same term, for chaining.
ValidationThere is no client-side validation. depth accepts 0, a negative integer, or a value that is not an integer, and records it as given.Omitting the argument raises TypeError immediately, because depth is a positional parameter with no default.Errors that do occur come from the read call that follows, ancestors(), descendants(), locales(), or fetch(), not from depth().Those calls raise an exception only for network failures (timeout, DNS error, dropped connection).An API-level rejection returns as a normal result with an error key. It does not raise an exception.Check the result for an error key even inside a try block.Additional Resource: Refer to Delivery API Errors for the full error code list.
BehaviorClient-side only. depth records the depth query parameter and makes no request. The read method that follows sends the value.The limit governs the hierarchy traversal that the ancestors method and the descendants method perform.Not calling depth sends no depth parameter, and the API applies its own traversal limit. The SDK sets no default of its own.Every read method sends the value, including fetch, because the SDK keeps one query-parameter store per instance. See the Class-Level Notes on the Term class page.Calling depth twice replaces the first value. The SDK holds it under a single key.Term.depth and TermQuery.depth are separate methods on separate objects. Setting the depth on one instance does not affect the other.ExampleBasic usage: cap a descendant traversal at two levelsimport contentstack

stack = contentstack.Stack('<API_KEY>', '<DELIVERY_TOKEN>', '<ENVIRONMENT>')

try:
    result = stack.taxonomy('regions').term('europe').depth(2).descendants()
except Exception as error:
    # Raised only for network failures (timeout, DNS error, dropped connection)
    print('Request failed:', error)
else:
    if 'error' in result:
        # The Delivery API rejected the request and returned the error body
        print('Delivery API error:', result['error'])
    else:
        print('terms returned:', len(result))Capping an ancestor traversalimport contentstack

stack = contentstack.Stack('<API_KEY>', '<DELIVERY_TOKEN>', '<ENVIRONMENT>')

try:
    # Return the nearest ancestor only, rather than the full path to the root.
    result = stack.taxonomy('regions').term('paris').depth(1).ancestors()
    print([term['uid'] for term in result])
except Exception as error:
    print('Request failed:', error)Edge case: the value travels on every call made from the same instanceimport contentstack

stack = contentstack.Stack('<API_KEY>', '<DELIVERY_TOKEN>', '<ENVIRONMENT>')

try:
    term = stack.taxonomy('regions').term('europe').depth(2)

    # Both calls send depth=2, including the single-term read.
    children = term.descendants()
    detail = term.fetch()

    # Build a fresh instance to send a request without the depth parameter.
    plain = stack.taxonomy('regions').term('europe').fetch()
except Exception as error:
    print('Request failed:', error)
```

Maximum number of hierarchy levels to traverse.

## descendants

descendants retrieves the terms below this one in the taxonomy hierarchy.

```
The descendant terms of this term.
Validationdescendants validates nothing itself. The UID check happens earlier, in the constructor.stack.taxonomy('<TAXONOMY_UID>').term('') never reaches this method. The empty string is falsy, so the factory method returns a TermQuery, which has no descendants, and the call raises AttributeError. See the Warning on the Term class page.descendants raises an exception only for network failures (timeout, DNS error, dropped connection). The exception type is RequestError.An API-level rejection, including a UID that names no term, returns as a normal result with an error key. It does not raise an exception.Check the result for an error key even inside a try block.Additional Resource: Refer to Delivery API Errors for the full error code list.
BehaviorCalls GET /taxonomies/{taxonomy_uid}/terms/{term_uid}/descendants and makes one HTTP request per call.Returns the contents of the terms key on success. Falls back to the whole response body when that key is absent. See the Class-Level Notes on the Term class page.Two return shapes reach you from that fallback. A successful call returns the list of descendant terms, and a rejected call returns the error dictionary. 'error' in result is False for the list and True for the error body, so test it before you iterate.Chain the depth method to cap the number of levels the traversal covers. Without it the SDK sends no depth parameter and the API applies its own limit.Returns the response as the API sends it. The SDK does no post-processing, so it neither sorts the terms nor reshapes them into a nested structure.Offers no pagination. skip and limit belong to TermQuery, not to this class, so a term with many descendants returns whatever the API sends in one response. Cap the traversal with the depth method instead.Sends whatever locale, include_fallback, include_branch, and param recorded on the instance as well.LimitationsDoes not return this term itself. Call the fetch method for the term, or use the equal_and_below method on the Taxonomy class to match a term together with its descendants.Does not return the entries tagged with those terms. Entry filtering by term lives on the Taxonomy class.ExampleBasic usage: retrieve the descendants of a termimport contentstack

stack = contentstack.Stack('<API_KEY>', '<DELIVERY_TOKEN>', '<ENVIRONMENT>')

try:
    result = stack.taxonomy('regions').term('europe').descendants()
except Exception as error:
    # Raised only for network failures (timeout, DNS error, dropped connection)
    print('Request failed:', error)
else:
    if 'error' in result:
        # The Delivery API rejected the request and returned the error body
        print('Delivery API error:', result['error'])
    else:
        for term in result:
            print(term['uid'], term['name'])Capping the traversal with depthimport contentstack

stack = contentstack.Stack('<API_KEY>', '<DELIVERY_TOKEN>', '<ENVIRONMENT>')

try:
    # depth caps the traversal at one level of descendants.
    result = stack.taxonomy('regions').term('europe').depth(1).descendants()
    print('children:', [term['uid'] for term in result])
except Exception as error:
    print('Request failed:', error)Localized descendants with a fallbackimport contentstack

stack = contentstack.Stack('<API_KEY>', '<DELIVERY_TOKEN>', '<ENVIRONMENT>')

try:
    result = stack.taxonomy('regions').term('europe') \
        .locale('fr-fr') \
        .include_fallback() \
        .descendants()
    print('term count:', len(result))
except Exception as error:
    print('Request failed:', error)
```

## fetch

fetch retrieves one published taxonomy term by its UID.

```
The requested term.
Validationfetch validates nothing itself. The UID check happens earlier, in the constructor.stack.taxonomy('<TAXONOMY_UID>').term('') never reaches this method. The empty string is falsy, so the factory method returns a TermQuery, which has no fetch, and the call raises AttributeError. See the Warning on the Term class page.Constructing Term directly with an empty or None term UID raises KeyError with the message "Invalid key or value. Provide valid values and try again." because the SDK cannot build the term URL without an identifier.fetch raises an exception only for network failures (timeout, DNS error, dropped connection). The exception type is RequestError.An API-level rejection, including a UID that names no term, returns as a normal result with an error key. It does not raise an exception.Check the result for an error key even inside a try block.Additional Resource: Refer to Delivery API Errors for the full error code list.
BehaviorCalls GET /taxonomies/{taxonomy_uid}/terms/{term_uid} and makes one HTTP request per call.Returns the contents of the term key on success, not the response envelope around it. Falls back to the whole response body when that key is absent. See the Class-Level Notes on the Term class page.Sends whatever locale, include_fallback, include_branch, depth, and param recorded on the instance. Calling fetch twice on one instance repeats the same request.LimitationsDoes not return the term's position in the hierarchy. Use the ancestors method or the descendants method to retrieve the related terms.ExampleBasic usage: read one term by UIDimport contentstack

stack = contentstack.Stack('<API_KEY>', '<DELIVERY_TOKEN>', '<ENVIRONMENT>')

try:
    result = stack.taxonomy('regions').term('europe').fetch()
except Exception as error:
    # Raised only for network failures (timeout, DNS error, dropped connection)
    print('Request failed:', error)
else:
    if 'error' in result:
        # The Delivery API rejected the request and returned the error body
        print('Delivery API error:', result['error'])
    else:
        print(result['uid'], result['name'])All modifiers: locale, fallback, branch, and an extra parameterimport contentstack

stack = contentstack.Stack('<API_KEY>', '<DELIVERY_TOKEN>', '<ENVIRONMENT>')

try:
    result = stack.taxonomy('regions').term('europe') \
        .locale('fr-fr') \
        .include_fallback() \
        .include_branch() \
        .param('include_referenced_entries_count', 'true') \
        .fetch()
    print('branch:', result.get('_branch'))
except Exception as error:
    print('Request failed:', error)Error handling: an unknown UID does not raiseimport contentstack

stack = contentstack.Stack('<API_KEY>', '<DELIVERY_TOKEN>', '<ENVIRONMENT>')

try:
    result = stack.taxonomy('regions').term('no_such_term').fetch()
except Exception as error:
    print('Request failed:', error)
else:
    # A missing term arrives as an ordinary return value, not an exception.
    if 'error' in result:
        print('code:', result.get('error_code'), 'message:', result.get('error_message'))Edge case: an empty UID returns the wrong objectimport contentstack

stack = contentstack.Stack('<API_KEY>', '<DELIVERY_TOKEN>', '<ENVIRONMENT>')

term_uid = ''

try:
    result = stack.taxonomy('regions').term(term_uid).fetch()
except AttributeError as error:
    # Fires because the empty string returned a TermQuery, which has no fetch.
    print('Guard the term UID before calling fetch:', error)
```

## include_branch

include\_branch adds the \_branch field to the term in the response.

```
The same term, for chaining.
ValidationThere is nothing to validate. include_branch takes no arguments and cannot fail.Errors that do occur come from the read call that follows, fetch(), locales(), ancestors(), or descendants(), not from include_branch().Those calls raise an exception only for network failures (timeout, DNS error, dropped connection).An API-level rejection returns as a normal result with an error key. It does not raise an exception.Check the result for an error key even inside a try block.Additional Resource: Refer to Delivery API Errors for the full error code list.
BehaviorClient-side only. Records include_branch=true as a string and makes no request. The read method that follows sends the flag.The flag reports which branch served the term. It does not select one. Pass branch to Stack to choose the branch a request targets.A stack with no branches enabled returns no _branch field even with the flag set, so read the key defensively.ExampleBasic usage: confirm which branch served the termimport contentstack

stack = contentstack.Stack('<API_KEY>', '<DELIVERY_TOKEN>', '<ENVIRONMENT>')

try:
    result = stack.taxonomy('regions').term('europe').include_branch().fetch()
except Exception as error:
    # Raised only for network failures (timeout, DNS error, dropped connection)
    print('Request failed:', error)
else:
    if 'error' in result:
        # The Delivery API rejected the request and returned the error body
        print('Delivery API error:', result['error'])
    else:
        print('served from branch:', result.get('_branch', 'branches not enabled'))Selecting a branch, which this method does not doimport contentstack

stack = contentstack.Stack(
    '<API_KEY>', '<DELIVERY_TOKEN>', '<ENVIRONMENT>', branch='release-2'
)

try:
    # branch on Stack picks the branch. include_branch only reports it back.
    result = stack.taxonomy('regions').term('europe').include_branch().fetch()
    print('requested release-2, served:', result.get('_branch'))
except Exception as error:
    print('Request failed:', error)The flag applies to a traversal as wellimport contentstack

stack = contentstack.Stack('<API_KEY>', '<DELIVERY_TOKEN>', '<ENVIRONMENT>')

try:
    # Every read method sends the flag, so each descendant carries _branch.
    result = stack.taxonomy('regions').term('europe').include_branch().descendants()
    print([term.get('_branch') for term in result])
except Exception as error:
    print('Request failed:', error)
```

## include_fallback

include\_fallback returns an earlier locale in the hierarchy when the term has no localization in the requested one.

```
The same term, for chaining.
ValidationThere is nothing to validate. include_fallback takes no arguments and cannot fail.Errors that do occur come from the read call that follows, fetch(), locales(), ancestors(), or descendants(), not from include_fallback().Those calls raise an exception only for network failures (timeout, DNS error, dropped connection).An API-level rejection returns as a normal result with an error key. It does not raise an exception.Check the result for an error key even inside a try block.Additional Resource: Refer to Delivery API Errors for the full error code list.
BehaviorClient-side only. Records include_fallback=true as a string and makes no request. The read method that follows sends the flag.The flag alone changes nothing. Chain the locale method as well, because the fallback only applies when the requested locale differs from the master locale.The API resolves the fallback, not the SDK. It returns the nearest earlier locale in the hierarchy that holds a published version.The response does not report whether a fallback happened. Compare the returned locale against the one you asked for when that difference matters.ExampleBasic usage: accept an earlier locale when the French version is missingimport contentstack

stack = contentstack.Stack('<API_KEY>', '<DELIVERY_TOKEN>', '<ENVIRONMENT>')

try:
    result = stack.taxonomy('regions').term('europe') \
        .locale('fr-fr') \
        .include_fallback() \
        .fetch()
except Exception as error:
    # Raised only for network failures (timeout, DNS error, dropped connection)
    print('Request failed:', error)
else:
    if 'error' in result:
        # The Delivery API rejected the request and returned the error body
        print('Delivery API error:', result['error'])
    else:
        print('name:', result.get('name'))Edge case: detect a fallbackimport contentstack

stack = contentstack.Stack('<API_KEY>', '<DELIVERY_TOKEN>', '<ENVIRONMENT>')

requested = 'fr-fr'

try:
    result = stack.taxonomy('regions').term('europe') \
        .locale(requested) \
        .include_fallback() \
        .fetch()

    # The response carries the locale it actually served, so compare the two.
    served = result.get('locale')
    if served and served != requested:
        print(f'no {requested} version, served {served} instead')
except Exception as error:
    print('Request failed:', error)The flag applies to a traversal as wellimport contentstack

stack = contentstack.Stack('<API_KEY>', '<DELIVERY_TOKEN>', '<ENVIRONMENT>')

try:
    # Every read method sends the flag, so a descendant traversal falls back too.
    result = stack.taxonomy('regions').term('europe') \
        .locale('fr-fr') \
        .include_fallback() \
        .descendants()
    print('terms returned:', len(result))
except Exception as error:
    print('Request failed:', error)
```

## locale

locale sets the language the API returns the term in.

```
The same term, for chaining.
ValidationThere is no client-side validation. locale accepts an empty string or a code that names no locale and records it as given.Omitting the argument raises TypeError immediately, because locale is a positional parameter with no default.Errors that do occur come from the read call that follows, fetch(), locales(), ancestors(), or descendants(), not from locale().Those calls raise an exception only for network failures (timeout, DNS error, dropped connection).An API-level rejection returns as a normal result with an error key. It does not raise an exception.Check the result for an error key even inside a try block.Additional Resource: Refer to Delivery API Errors for the full error code list.
BehaviorClient-side only. locale records the locale query parameter and makes no request. The read method that follows sends the value.The SDK sets no default. Not calling locale sends no locale parameter, and the API returns the stack's master locale.Calling locale twice replaces the first value. The SDK holds it under a single key.A term that has no localization in the requested locale comes back empty unless you also chain the include_fallback method.Taxonomy.locale and Term.locale are separate methods on separate objects. Setting the locale on the taxonomy does not carry it down to the term. See the Class-Level Notes on the Term class page.ExampleBasic usage: read a term in Frenchimport contentstack

stack = contentstack.Stack('<API_KEY>', '<DELIVERY_TOKEN>', '<ENVIRONMENT>')

try:
    result = stack.taxonomy('regions').term('europe').locale('fr-fr').fetch()
except Exception as error:
    # Raised only for network failures (timeout, DNS error, dropped connection)
    print('Request failed:', error)
else:
    if 'error' in result:
        # The Delivery API rejected the request and returned the error body
        print('Delivery API error:', result['error'])
    else:
        print('localized name:', result.get('name'))The locale applies to a traversal as wellimport contentstack

stack = contentstack.Stack('<API_KEY>', '<DELIVERY_TOKEN>', '<ENVIRONMENT>')

try:
    # Every read method sends the locale, so the descendants arrive localized too.
    result = stack.taxonomy('regions').term('europe').locale('fr-fr').descendants()
    print([term.get('name') for term in result])
except Exception as error:
    print('Request failed:', error)Edge case: the taxonomy locale does not reach the termimport contentstack

stack = contentstack.Stack('<API_KEY>', '<DELIVERY_TOKEN>', '<ENVIRONMENT>')

try:
    # This term request carries no locale, so the API returns the master locale.
    unlocalized = stack.taxonomy('regions').locale('fr-fr').term('europe').fetch()

    # Set the locale again on the Term instance to get the French version.
    localized = stack.taxonomy('regions').term('europe').locale('fr-fr').fetch()
except Exception as error:
    print('Request failed:', error)
```

Locale code to request, for example fr-fr.

## locales

locales retrieves the published localized versions of this term.

```
The localizations of this term.
Validationlocales validates nothing itself. The UID check happens earlier, in the constructor.stack.taxonomy('<TAXONOMY_UID>').term('') never reaches this method. The empty string is falsy, so the factory method returns a TermQuery, which has no locales, and the call raises AttributeError. See the Warning on the Term class page.locales raises an exception only for network failures (timeout, DNS error, dropped connection). The exception type is RequestError.An API-level rejection, including a UID that names no term, returns as a normal result with an error key. It does not raise an exception.Check the result for an error key even inside a try block.Additional Resource: Refer to Delivery API Errors for the full error code list.
BehaviorCalls GET /taxonomies/{taxonomy_uid}/terms/{term_uid}/locales and makes one HTTP request per call.Returns the contents of the terms key on success. Falls back to the whole response body when that key is absent. See the Class-Level Notes on the Term class page.The signature annotates the return value as dict, while ancestors and descendants annotate the same terms key as list. The SDK enforces neither annotation, so check the type of the result before you index into it.Sends whatever locale, include_fallback, include_branch, depth, and param recorded on the instance. Chaining the locale method therefore sends a locale parameter on this request, and the API decides what that means for a localization listing.Calling locales twice on one instance repeats the same request.LimitationsDoes not list the locales configured on the stack. It reports only the locales this term exists in.ExampleBasic usage: list the localizations of one termimport contentstack

stack = contentstack.Stack('<API_KEY>', '<DELIVERY_TOKEN>', '<ENVIRONMENT>')

try:
    result = stack.taxonomy('regions').term('europe').locales()
except Exception as error:
    # Raised only for network failures (timeout, DNS error, dropped connection)
    print('Request failed:', error)
else:
    if 'error' in result:
        # The Delivery API rejected the request and returned the error body
        print('Delivery API error:', result['error'])
    else:
        print('localizations:', result)Edge case: guard the return type before indexingimport contentstack

stack = contentstack.Stack('<API_KEY>', '<DELIVERY_TOKEN>', '<ENVIRONMENT>')

try:
    result = stack.taxonomy('regions').term('europe').locales()

    # The signature says dict, and the terms key can hold a list, so branch on it.
    if isinstance(result, list):
        for localization in result:
            print(localization.get('locale'))
    elif isinstance(result, dict) and 'error' not in result:
        print(result)
except Exception as error:
    print('Request failed:', error)Chained modifiers travel on this request tooimport contentstack

stack = contentstack.Stack('<API_KEY>', '<DELIVERY_TOKEN>', '<ENVIRONMENT>')

try:
    # locale and include_branch both reach the /locales endpoint.
    result = stack.taxonomy('regions').term('europe') \
        .locale('fr-fr') \
        .include_branch() \
        .locales()
    print(result)
except Exception as error:
    print('Request failed:', error)
```

## param

param adds an arbitrary query parameter to the request.

```
The same term, for chaining.
ValidationPassing None as either argument raises KeyError with the message "Invalid key or value arguments. Provide valid values and try again." A null key or value would produce a malformed query string. This is the only method on this class that rejects its own arguments.The raise happens on the call itself, not on the read call that follows. Wrap param in its own try when the key or value comes from user input.An empty string passes the check. None is the only rejected value, so param('', '') records a parameter with no name.Omitting either argument raises TypeError immediately, because both are positional parameters with no default.Any remaining errors come from the read call that follows, fetch(), locales(), ancestors(), or descendants().Those calls raise an exception only for network failures (timeout, DNS error, dropped connection).An API-level rejection, for example a parameter name the endpoint refuses, returns as a normal result with an error key. It does not raise an exception.Check the result for an error key even inside a try block.Additional Resource: Refer to Delivery API Errors for the full error code list.
BehaviorClient-side only. param records the pair in the query parameters and makes no request.The key shares one namespace with the dedicated modifiers. param('depth', 5) and depth(5) write to the same place, so whichever call comes last wins.Every read method sends the pair, so a parameter meant for one endpoint also travels to the next call on that instance. See the Class-Level Notes on the Term class page.Use param to reach a Delivery API query parameter the SDK exposes no method for. Prefer the dedicated method when one exists, because it documents the intent.The SDK encodes the parameters before sending them, so a value containing a space or an ampersand needs no encoding from you.param on a Term and param on a TermQuery are separate methods. Each writes to its own instance.ExampleBasic usage: send a query parameter the SDK has no method forimport contentstack

stack = contentstack.Stack('<API_KEY>', '<DELIVERY_TOKEN>', '<ENVIRONMENT>')

try:
    result = stack.taxonomy('regions').term('europe') \
        .param('include_referenced_entries_count', 'true') \
        .fetch()
except Exception as error:
    # Raised only for network failures (timeout, DNS error, dropped connection)
    print('Request failed:', error)
else:
    if 'error' in result:
        # The Delivery API rejected the request and returned the error body
        print('Delivery API error:', result['error'])
    else:
        print('term:', result.get('uid'))All parameters: both arguments on a descendant traversalimport contentstack

stack = contentstack.Stack('<API_KEY>', '<DELIVERY_TOKEN>', '<ENVIRONMENT>')

try:
    # key is the parameter name, value is what the SDK sends for it.
    result = stack.taxonomy('regions').term('europe') \
        .param('locale', 'fr-fr') \
        .descendants()
    print('terms returned:', len(result))
except Exception as error:
    print('Request failed:', error)Error handling: a null key raises at the call siteimport contentstack

stack = contentstack.Stack('<API_KEY>', '<DELIVERY_TOKEN>', '<ENVIRONMENT>')

user_supplied_key = None

try:
    result = stack.taxonomy('regions').term('europe') \
        .param(user_supplied_key, 'true') \
        .fetch()
except KeyError as error:
    # Fires on param itself, before any request goes out.
    print('Invalid query parameter:', error)Edge case: a dedicated method and param collideimport contentstack

stack = contentstack.Stack('<API_KEY>', '<DELIVERY_TOKEN>', '<ENVIRONMENT>')

try:
    # Both write the 'depth' key, so the later call wins and this sends depth=5.
    result = stack.taxonomy('regions').term('europe') \
        .depth(2) \
        .param('depth', 5) \
        .descendants()
except Exception as error:
    print('Request failed:', error)
```

Query parameter name to send.

Value for that query parameter.

## Term | Python Delivery SDK | Contentstack

The Term class in the Python Delivery SDK reads one published taxonomy term, lists its localizations, and retrieves its ancestors and descendants.