---
title: "Taxonomy"
description: "Taxonomy"
url: "https://www.contentstack.com/docs/developers/sdks/content-delivery-sdk/ios/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.

## initWithStack

The initWithStack method initializes a new instance of the Taxonomy class using the specified Stack.

```
Objective C:
Stack *stack = [Contentstack stackWithAPIKey:@"api_key" 
                             deliveryToken:@"delivery_token" 
                              environment:@"environment"];
Taxonomy *taxonomy = [[Taxonomy alloc] initWithStack:stack];Swift:
let stack = Contentstack.stack(apiKey: "api_key",
                             deliveryToken: "delivery_token",
                             environment: "environment")
let taxonomy = Taxonomy(stack: stack)
```

The stack instance for making API requests

## query

The querymethod generates a new Query instance for the taxonomy.

```
Objective C:
Taxonomy *taxonomy = [[Taxonomy alloc] initWithStack:stack]; 
Query *query = [taxonomy query]; Swift:
let taxonomy = Taxonomy(stack: stack) 
let query = taxonomy.query()
```

## whereKey:equalTo:

The whereKey:equalTo: method adds a condition to filter entries where the specified key matches the provided value.

```
Objective C:
Taxonomy *taxonomy = [[Taxonomy alloc] initWithStack:stack]; 
Query *query = [taxonomy query]; 
[query whereKey:@"title" equalTo:@"Sample Taxonomy"];Swift:
let taxonomy = Taxonomy(stack: stack) 
let query = taxonomy.query() 
query.whereKey("title", equalTo: "Sample Taxonomy")
```

The key of the field to query for the desired data.

The value to match

## fetch:completion:

The whereKey:equalTo: method adds a condition to filter entries where the specified key matches the provided value.

```
Objective C:
NSDictionary *params = @{ @"include_count":@(true), @"include_global_field_schema": @(true) }; 
[taxonomy fetch:params completion:^(NSDictionary *entries, NSError *error) { 
if (error) 
     { NSLog(@"Error: %@", error.localizedDescription); 
 return; 
     }
 NSLog(@"Fetched entries: %@", entries); 
     }];Swift:
let params = [ "include_count": true, "include_global_field_schema": true ] as [String : Any] 
taxonomy.fetch(params) { (entries, error) in 
if let error = error { 
print("Error: \(error.localizedDescription)") 
return } 
if let entries = entries {
print("Fetched entries: \(entries)") 
  } 
}
```

Optional parameters for the request

Completion handler with result or error

## findTaxonomy:

The findTaxonomy: method executes a query to fetch taxonomy entries that match specified query conditions.

```
Objective C:
Query *query = [taxonomy query];
[query whereKey:@"taxonomies.one" equalTo:@"term_one"];
[query findTaxonomy:^(ResponseType type, QueryResult *result, NSError *error) {
if (error) {
   NSLog(@"Error: %@", error.localizedDescription); 
   return; 
 } 
 NSArray *entries = [result getResult];
 NSLog(@"Fetched entries: %@", entries);
}];
Swift:
let query = taxonomy.query()
query.whereKey("taxonomies.one", equalTo: "term_one")
query.findTaxonomy { (type, result, error) in
    if let error = error {
        print("Error: \(error.localizedDescription)")
        return
    }
    if let entries = result?.getResult() {
        print("Fetched entries: \(entries)")
    }
}
```

Returns (ResponseType, QueryResult\*, NSError\*)

## orWithSubqueries:

The orWithSubqueries method combines multiple queries using AND condition.

```
Objective C:
Query *query1 = [taxonomy query]; 
[query1 whereKey:@"taxonomies.one" equalTo:@"term_one"]; 
Query *query2 =[taxonomy query]; 
[query2 whereKey:@"taxonomies.two" equalTo:@"term_two"]; 
Query *mainQuery = [taxonomy query]; 
[mainQuery orWithSubqueries:@[query1, query2]];Swift:
let query1 = taxonomy.query() 
query1.whereKey("taxonomies.one", equalTo: "term_one") 
let query2 = taxonomy.query()
query2.whereKey("taxonomies.two", equalTo: "term_two")
let mainQuery = taxonomy.query()
mainQuery.orWithSubqueries([query1, query2])
```

Array of Query objects to combine with OR

## andWithSubqueries:

The andWithSubqueries: method combines multiple queries using AND condition.

```
Objective C:
Query *query1 = [taxonomy query]; 
[query1 whereKey:@"taxonomies.one" equalTo:@"term_one"]; 
Query *query2 =[taxonomy query]; 
[query2 whereKey:@"taxonomies.two" equalTo:@"term_two"]; 
Query *mainQuery = [taxonomy query]; 
[mainQuery andWithSubqueries:@[query1, query2]];
Swift:
let query1 = taxonomy.query() 
query1.whereKey("taxonomies.one", equalTo: "term_one") 
let query2 = taxonomy.query()
query2.whereKey("taxonomies.two", equalTo: "term_two")
let mainQuery = taxonomy.query()
mainQuery.andWithSubqueries([query1, query2])
```

Array of Query objects to combine with AND

## Taxonomy | iOS Delivery SDK | Contentstack

Taxonomy lets you categorize stack content for easy navigation and retrieval using the Contentstack iOS Delivery SDK.