---
title: "Taxonomy"
description: "Taxonomy"
url: "https://www.contentstack.com/docs/developers/sdks/content-delivery-sdk/swift/reference/taxonomy"
product: "Contentstack"
doc_type: "guide"
audience:
  - developers
  - admins
version: "current"
last_updated: "2026-09-13"
---

# Taxonomy

## Taxonomy

[Taxonomy](/docs/headless-cms/about-taxonomy) helps you categorize pieces of content within your stack to facilitate easy navigation and retrieval of information.

## Taxonomy(stack:)

The Taxonomy(stack:) method initializes a new instance of the Taxonomy class.

```
Example:

let stack = Contentstack.stack( apiKey: "your_api_key", deliveryToken: "your_delivery_token", environment:"your_environment" ) 
let taxonomy = Taxonomy(stack: stack)
```

The Stack instance for making API requests

## query()

The query() method creates a new Query instance for retrieving taxonomy entries.

```
Example:
let stack = Contentstack.stack(apiKey: "api_key", deliveryToken: "delivery_token", environment: "environment") 
let taxonomy = Taxonomy(stack: stack) 
let query = taxonomy.query() 
query.where(valueAtKey: "taxonomies.test_taxonomy", .equals("test_term"))
query.limit(10)
query.skip(0)
```

## fetch()

The fetch() method retrieves taxonomy data from Contentstack.

```
Example:
let stack = Contentstack.stack(apiKey: "api_key", deliveryToken: "delivery_token", environment: "environment") 
let taxonomy = Taxonomy(stack: stack)
let query = taxonomy.query() query.whereKey("title", .equals("Sample Taxonomy")) 
query.fetch { (result:Result<TaxonomyModel, Error>, response) in 
switch result { 
case .success(let taxonomyModel): print("Found taxonomy: \(taxonomyModel.title)") 
case .failure(let error): print("Query error: \(error.localizedDescription)")
 } 
}
```

## where(valueAtKey:operation:)

The where(valueAtKey:operation:) method adds a constraint to the query.

```
Example:
let stack = Contentstack.stack(apiKey: "api_key", deliveryToken: "delivery_token", environment: "environment") 
let taxonomy = Taxonomy(stack: stack) 
let query = taxonomy.query()
query.where(valueAtKey: "taxonomies.test_taxonomy", .equals("test_term"))
```

The field key to query on

The operation to perform

## operator()

The where(valueAtKey:operation:) method adds a constraint to the query.

```
Example:
let query1 = taxonomy.query().where(valueAtKey: "taxonomies.test_taxonomy", .equals("term1"))
let query2 = taxonomy.query().where(valueAtKey: "taxonomies.test_taxonomy", .equals("term2"))
query.operator(.or([query1, query2]))
```

The logical operation (.and/.or) with array of queries

## Query Operations

Following are the available Query Operations:

**Operations**

**Description**

**Example**

**.equals()**

Performs an exact match.

.equals("test\_term")

**.includes()**

Checks if the value exists in the array.

.includes(\["term1", "term2"\])

**.below()**

Matches terms below (excluding) the specified value.

.below("parent\_term")

**.eqBelow()**

Matches terms below (including) the specified value.

.eqBelow("parent\_term")

**.above()**

Matches terms above (excluding) the specified value.

.above("child\_term")

**.eqAbove()**

Matches terms above (including) the specified value.

.eqAbove("child\_term")

**.or()**

Combines queries using OR logic

.operator(.or(\[query1, query2\]))

**.and()**

Combines queries using AND logic

.operator(.and(\[query1, query2\]))

## Taxonomy | Swift Delivery SDK | Contentstack

Taxonomy helps you categorize content within your stack for easy navigation and retrieval in the Contentstack Swift Delivery SDK.