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

# TermQuery

## TermQuery

A [taxonomy](/docs/headless-cms/about-taxonomy) holds its terms in a hierarchy. Use this class to

*   list the published terms of one taxonomy
*   cap the hierarchy levels and the page size the listing covers
*   request the listing in a specific locale

| Name | Type | Description |

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

| taxonomy\_uid | str | UID of the taxonomy whose terms the query lists. |

stack.taxonomy('<TAXONOMY\_UID>').term() supplies the taxonomy UID and returns a TermQuery. Pass a term UID to get a Term instead, which reads that one term. TermQuery and Term are separate classes with separate method sets. Calling fetch on a TermQuery raises AttributeError, and calling find on a Term raises AttributeError. skip, limit, and include\_count belong to this class alone, because a Term addresses one item and carries no pagination.

**Warning:** term('') returns a TermQuery rather than a Term, so a variable that is unexpectedly empty produces a term listing instead of the single-term fetch you intended. See the [term](/python-taxonomy-term) method on the Taxonomy class for the full explanation.

## depth

depth caps the number of hierarchy levels the term listing covers.

```
The same query, 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 find() call that follows, not from depth().find() raises 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. find sends the value on that call.The limit governs how far down the taxonomy hierarchy the listing reaches. A shallow depth returns the terms near the root and leaves their descendants out.Not calling depth sends no depth parameter, and the API applies its own traversal limit. The SDK sets no default of its own.Calling depth twice replaces the first value. The SDK holds it under a single key.TermQuery.depth and Term.depth are separate methods on separate objects. This one bounds a listing across the taxonomy, while the depth method on the Term class bounds a traversal from one term.ExampleBasic usage: list the terms two levels deepimport contentstack

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

try:
    result = stack.taxonomy('regions').term().depth(2).find()
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.get('terms', [])))Comparing two depths on the same taxonomyimport contentstack

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

try:
    # A fresh query per depth, because one instance holds its parameters.
    top = stack.taxonomy('regions').term().depth(1).find()
    deeper = stack.taxonomy('regions').term().depth(3).find()

    print('one level:', len(top.get('terms', [])))
    print('three levels:', len(deeper.get('terms', [])))
except Exception as error:
    print('Request failed:', error)Edge case: a second call replaces the first depthimport contentstack

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

try:
    # Both calls write the 'depth' key, so this request sends depth=4.
    result = stack.taxonomy('regions').term().depth(2).depth(4).find()
except Exception as error:
    print('Request failed:', error)
```

Maximum number of hierarchy levels to traverse.

## find

find lists the published terms of one taxonomy.

```
The terms published in the taxonomy.
Validationfind validates nothing. It serializes whatever the query holds, including a negative limit or a locale code that names no locale, and sends it.find raises an exception only for network failures (timeout, DNS error, dropped connection). The exception type is RequestError.An API-level rejection, for example a taxonomy UID that names no taxonomy, 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 and makes one HTTP request per call. There is one endpoint, so nothing you chain changes the path.Returns the whole parsed response body: a terms list, plus a count key when you chain the include_count method. See the Class-Level Notes on the TermQuery class page.Sends whatever depth, skip, limit, locale, include_fallback, include_branch, include_count, and param recorded on the instance. Calling find twice on one instance repeats the same request.Sends no query string when you chain no modifier. find appends the encoded parameters only when the dictionary holds something.LimitationsDoes not return every term when you omit limit. The API applies its own page size. Chain the include_count method and compare count against the length of the returned list to detect a truncated page.Does not page automatically. Combine the skip method and the limit method to retrieve one page at a time.Does not accept a filter condition on a term field. TermQuery exposes no filter methods, so use the param method to send a Delivery API query parameter the SDK has no method for.ExampleBasic usage: list the terms of a taxonomyimport contentstack

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

try:
    result = stack.taxonomy('regions').term().find()
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.get('terms', []):
            print(term['uid'], term['name'])All modifiers: depth, locale, fallback, branch, pagination, count, and an extra parameterimport contentstack

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

try:
    result = stack.taxonomy('regions').term() \
        .depth(2) \
        .locale('fr-fr') \
        .include_fallback() \
        .include_branch() \
        .skip(0) \
        .limit(25) \
        .include_count() \
        .param('include_referenced_entries_count', 'true') \
        .find()
    print('total:', result.get('count'), 'returned:', len(result.get('terms', [])))
except Exception as error:
    print('Request failed:', error)Error handling: an unknown taxonomy UID does not raiseimport contentstack

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

try:
    result = stack.taxonomy('no_such_taxonomy').term().find()
except Exception as error:
    print('Request failed:', error)
else:
    # A missing taxonomy 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: read every page in orderimport contentstack

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

page_size = 50
offset = 0

try:
    while True:
        # A fresh query per page, because one instance holds its parameters.
        result = stack.taxonomy('regions').term() \
            .skip(offset) \
            .limit(page_size) \
            .include_count() \
            .find()
        for term in result.get('terms', []):
            print(term['uid'])
        offset += page_size
        # count is the total, not the page length, so compare against the offset.
        if offset >= result.get('count', 0):
            break
except Exception as error:
    print('Request failed:', error)
```

## include_branch

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

```
The same query, for chaining.
ValidationThere is nothing to validate. include_branch takes no arguments and cannot fail.Errors that do occur come from the find() call that follows, not from include_branch().find() raises 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. find sends the flag on that call.The flag reports which branch served the terms. 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.Every term in the listing carries the field, so the value repeats across the whole response.ExampleBasic usage: confirm which branch served the termsimport contentstack

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

try:
    result = stack.taxonomy('regions').term().include_branch().find()
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.get('terms', []):
            print(term['uid'], term.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().include_branch().find()
    served = {term.get('_branch') for term in result.get('terms', [])}
    print('requested release-2, served:', served)
except Exception as error:
    print('Request failed:', error)Edge case: the flag survives every later call on the same queryimport contentstack

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

try:
    query = stack.taxonomy('regions').term().include_branch()

    # Both requests send include_branch=true, because nothing clears the flag.
    first = query.limit(10).find()
    second = query.skip(10).limit(10).find()
except Exception as error:
    print('Request failed:', error)
```

## include_count

include\_count adds the total number of terms in the taxonomy to the response.

```
The same query, for chaining.
ValidationThere is nothing to validate. include_count takes no arguments and cannot fail.Errors that do occur come from the find() call that follows, not from include_count().find() raises 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_count=true as a string and makes no request. find sends the flag on that call.The count key holds the total number of terms in the taxonomy, not the number returned in this page. Compare it against the length of the terms list to find out whether more remain.Without the flag the response carries no count key, so read it with a default rather than by index.Pair the flag with the skip method and the limit method to know when a paging loop has read everything. See Pagination on the TermQuery class page.ExampleBasic usage: detect a truncated term listimport contentstack

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

try:
    result = stack.taxonomy('regions').term().limit(10).include_count().find()
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:
        returned = len(result.get('terms', []))
        total = result.get('count', 0)
        print(f'showing {returned} of {total}')
        if returned < total:
            print('more pages remain, raise skip to read them')Reading the total without the termsimport contentstack

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

try:
    # A limit of 1 keeps the payload small when only the total matters.
    result = stack.taxonomy('regions').term().limit(1).include_count().find()
    print('terms in this taxonomy:', result.get('count'))
except Exception as error:
    print('Request failed:', error)Edge case: the count is absent without the flagimport contentstack

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

try:
    result = stack.taxonomy('regions').term().limit(10).find()

    # count is missing here, so the default guards against a KeyError.
    print('count key present:', 'count' in result)
    print('total:', result.get('count', 'not requested'))
except Exception as error:
    print('Request failed:', error)
```

## include_fallback

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

```
The same query, for chaining.
ValidationThere is nothing to validate. include_fallback takes no arguments and cannot fail.Errors that do occur come from the find() call that follows, not from include_fallback().find() raises 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. find sends the flag on that call.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 flag applies to the whole listing, because find sends one query string for every term it returns. You cannot enable the fallback for part of a page.The response does not report whether a fallback happened for the listing as a whole. Compare the locale on each term against the one you asked for when that difference matters.ExampleBasic usage: accept an earlier locale for the terms that lack a French versionimport contentstack

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

try:
    result = stack.taxonomy('regions').term() \
        .locale('fr-fr') \
        .include_fallback() \
        .find()
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.get('terms', [])))Edge case: detect a fallback term by termimport contentstack

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

requested = 'fr-fr'

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

    # Each term carries the locale the API served it in, so compare them.
    for term in result.get('terms', []):
        served = term.get('locale')
        if served and served != requested:
            print(f"{term['uid']}: no {requested} version, served {served} instead")
except Exception as error:
    print('Request failed:', error)Comparing the listing with and without the flagimport contentstack

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

try:
    strict = stack.taxonomy('regions').term().locale('fr-fr').find()
    with_fallback = stack.taxonomy('regions').term() \
        .locale('fr-fr') \
        .include_fallback() \
        .find()

    print('French only:', len(strict.get('terms', [])))
    print('with fallback:', len(with_fallback.get('terms', [])))
except Exception as error:
    print('Request failed:', error)
```

## limit

limit caps the number of terms the response contains.

```
The same query, for chaining.
ValidationThere is no client-side validation. The SDK records and sends a negative or non-integer value as given.Omitting the argument raises TypeError immediately, because limit is a positional parameter with no default.Errors that do occur come from the find() call that follows, not from limit().find() raises an exception only for network failures (timeout, DNS error, dropped connection).An API-level rejection (for example, an invalid limit value) 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. limit records the limit query parameter and makes no request. find sends the value on that call.Omitting limit does not return every term. The API applies its own page size instead. See Pagination on the TermQuery class page for how to detect a truncated list and read the rest.Calling limit twice replaces the first value. The SDK holds it under a single key.The cap counts terms, not hierarchy levels. Use the depth method to bound how far down the hierarchy the listing reaches.ExampleBasic usage: return at most ten termsimport contentstack

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

try:
    result = stack.taxonomy('regions').term().limit(10).find()
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('returned', len(result.get('terms', [])), 'terms')Detecting a truncated listimport contentstack

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

try:
    result = stack.taxonomy('regions').term().limit(10).include_count().find()

    returned = len(result.get('terms', []))
    total = result.get('count', 0)
    if returned < total:
        print(f'showing {returned} of {total}, raise skip to read the rest')
except Exception as error:
    print('Request failed:', error)Edge case: a limit and a depth bound different thingsimport contentstack

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

try:
    # At most 5 terms come back, drawn from the first two hierarchy levels.
    result = stack.taxonomy('regions').term().depth(2).limit(5).find()
    print([term['uid'] for term in result.get('terms', [])])
except Exception as error:
    print('Request failed:', error)
```

Maximum number of terms to return.

## locale

locale sets the language the API returns the terms in.

```
The same query, 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 find() call that follows, not from locale().find() raises 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. find sends the value on that call.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.The setting applies to the whole listing, because find sends one query string for every term it returns. There is no per-term locale.Chain the include_fallback method when a term in the taxonomy may carry no localization in the requested locale.Taxonomy.locale and TermQuery.locale are separate methods on separate objects. Setting the locale on the taxonomy does not carry it down to the query. See the Class-Level Notes on the TermQuery class page.ExampleBasic usage: list the terms in Frenchimport contentstack

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

try:
    result = stack.taxonomy('regions').term().locale('fr-fr').find()
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.get('name') for term in result.get('terms', [])])Filling the gaps with a fallbackimport contentstack

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

try:
    # Terms with no French version come back in an earlier locale instead.
    result = stack.taxonomy('regions').term() \
        .locale('fr-fr') \
        .include_fallback() \
        .find()
    print('terms returned:', len(result.get('terms', [])))
except Exception as error:
    print('Request failed:', error)Edge case: the taxonomy locale does not reach the queryimport contentstack

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

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

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

Locale code to request, for example fr-fr.

## param

param adds an arbitrary query parameter to the request.

```
The same query, 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 find() 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 find() call that follows.find() raises 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('limit', 5) and limit(5) write to the same place, so whichever call comes last wins.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.Calling param twice with the same key replaces the first value. Two different keys coexist, because each occupies its own entry.The SDK encodes the parameters before sending them, so a value containing a space or an ampersand needs no encoding from you. A list value expands into one repeated parameter per element.param on a TermQuery and param on a Term 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() \
        .param('include_referenced_entries_count', 'true') \
        .find()
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.get('terms', [])))All parameters: both arguments on one term listingimport 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() \
        .param('locale', 'fr-fr') \
        .find()
    print([term.get('name') for term in result.get('terms', [])])
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() \
        .param(user_supplied_key, 'true') \
        .find()
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 'limit' key, so the later call wins and this sends limit=5.
    result = stack.taxonomy('regions').term().limit(10).param('limit', 5).find()
except Exception as error:
    print('Request failed:', error)
```

Query parameter name to send.

Value for that query parameter.

## skip

skip omits a number of terms from the start of the response.

```
The same query, for chaining.
ValidationThere is no client-side validation. The SDK records and sends a negative or non-integer value as given.Omitting the argument raises TypeError immediately, because skip is a positional parameter with no default.Errors that do occur come from the find() call that follows, not from skip().find() raises 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. skip records the skip query parameter and makes no request. find sends the value on that call.The SDK sets no default. Omitting skip sends no skip parameter, and the API starts from the first term.Calling skip twice replaces the first value. The SDK holds it under a single key.Pair skip with the limit method to page through the full list. See Pagination on the TermQuery class page.The offset counts terms in the order the API returns them. TermQuery exposes no sort method, so the order is the API's.ExampleBasic usage: read the second page of twenty termsimport contentstack

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

try:
    result = stack.taxonomy('regions').term().skip(20).limit(20).find()
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('page 2 holds', len(result.get('terms', [])), 'terms')Pagination: read every page in orderimport contentstack

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

page_size = 20
offset = 0

try:
    while True:
        result = stack.taxonomy('regions').term() \
            .skip(offset) \
            .limit(page_size) \
            .include_count() \
            .find()
        for term in result.get('terms', []):
            print(term['uid'])
        offset += page_size
        # count is the total, not the page length, so compare against the offset.
        if offset >= result.get('count', 0):
            break
except Exception as error:
    print('Request failed:', error)Edge case: an offset larger than the term countimport contentstack

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

try:
    # Nothing rejects an offset larger than the term count, so guard the length.
    result = stack.taxonomy('regions').term().skip(10000).find()
    if not result.get('terms'):
        print('no terms at this offset, lower the skip value')
except Exception as error:
    print('Request failed:', error)
```

Number of terms to omit from the start.

## TermQuery | Python Delivery SDK | Contentstack

The TermQuery class in the Python Delivery SDK lists the published terms of one taxonomy, with locale, depth, and pagination modifiers.