---
title: "Query"
description: "Query"
url: "https://www.contentstack.com/docs/developers/sdks/content-delivery-sdk/ios/reference/query"
product: "Contentstack"
doc_type: "guide"
audience:
  - developers
  - admins
version: "current"
last_updated: "2026-09-22"
---

# Query

## Query

An initializer is responsible for creating Query object.

## setHeader:forKey:

Set a header for Query

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" <span>environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query setHeader:@"MyValue" forKey:@"My-Custom-Header"];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.setHeader("MyValue", forKey: "My-Custom-Header")
```

The header value

The header key

## addHeadersWithDictionary:

Set a header for Query

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query addHeadersWithDictionary:@{@"My-Custom-Header": @"MyValue"}];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.addHeadersWithDictionary(["My-Custom-Header":"MyValue"])
```

The headers as dictionary which needs to be added to the application.

## removeHeaderForKey:

Removes a header from this Query.

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" <span>environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query removeHeaderForKey:@"key"];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.removeHeaderForKey("key")
```

The header key that needs to be removed.

## locale:

This method provides all the entries for the specified language in the response.

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];

Query * query = [contentType query];
[query locale:@“en-us”];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")

let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.locale(“en-us”)
```

Language enum for all language available.

## tags:

This method provides only the entries that contain tags matching the ones mentioned in the function.

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];

Query * query = [contentType query];
[query tags:@[@"phone", @"laptop"]];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")

let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.tags(["phone", "laptop"])
```

An array of tags that are to be included for the key

## orWithSubqueries:

This method performs the OR operation on the specified query objects and provides only the matching entries.

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];

Query *query1 = [contentType query];
[query1 whereKey:@"total_hits" greaterThanOrEqualTo:@(800)];

Query *query2 = [contentType query];
[query2 whereKey:@"total_hits" lessThanOrEqualTo:@(1200)];

Query * query = [contentType query];
[query orWithSubqueries:@[query1, query2]];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")

var query1:Query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query1.whereKey("total_hits", greaterThanOrEqualTo:800)

var query2:Query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query2.whereKey("total_hits", equalTo:1200)

let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.orWithSubqueries([query1, query2])
```

Array of queries to be taken into consideration.

## andWithSubqueries:

This method performs the AND operation on the specified query objects and provides only the matching entries.

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];

Query *query1 = [contentType query];
[query1 whereKey:@"total_hits" greaterThanOrEqualTo:@(800)];

Query *query2 = [contentType query];
[query2 whereKey:@"total_hits" lessThanOrEqualTo:@(1200)];

Query * query = [contentType query];
[query andWithSubqueries:@[query1, query2]];
Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")

var query1:Query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query1.whereKey("total_hits", greaterThanOrEqualTo:800)

var query2:Query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query2.whereKey("total_hits", equalTo:1200)

let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.andWithSubqueries([query1, query2])
```

Array of queries to be taken into consideration.

## orderByAscending:

Sorts the provided entries in the ascending order on the basis of the specified field.

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query orderByAscending:@"updated_at"];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.orderByAscending("updated_at")
```

The field uid based on which the ordering should be done.

## orderByDescending:

Sorts the provided entries in the descending order on the basis of the specified field.

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query orderByDescending:@"updated_at"];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.orderByDescending("updated_at")
```

The field uid based on which the ordering should be done.

## objectsCount

Provides only the number of entries with values matching the specified values for a field.

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query objectsCount];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.objectsCount()
```

## includeContentType

This method also includes the contenttype for the entries returned in the response.

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query includeContentType];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.includeContentType()
```

## includeFallback

Retrieve the published content of the fallback locale entry if the entry is not localized in specified locale.

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query includeFallback];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.includeFallback()
```

## includeBranch

Retrieve the branch for the published content.

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query includeBranch];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.includeBranch()
```

## includeReferenceContentTypeUid

This method also includes the content type UIDs of the referenced entries returned in the response.

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query includeReferenceContentTypeUid];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.includeReferenceContentTypeUid()
```

## includeEmbeddedItems

Include Embedded Objects (Entries and Assets) along with entry/entries details.

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query includeEmbeddedItems];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.includeEmbeddedItems()
```

## includeCount

This method also includes the total number of entries returned in the response.

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query includeCount];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.includeCount()
```

## limitObjects:

This method limits the response by providing only the specified number of entries.

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query limitObjects:@(5)];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.limitObjects(NSNumber(int:5))
```

Number of entries to be returned

## skipObjects:

This method provide response by skipping only the specified number of entries.

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query skipObjects:@(5)];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.skipObjects(NSNumber(int:5))
```

Number of entries to be skipped before returned.

## addQueryWithKey:andValue:

Include custom query using a key and a value.

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query  addQueryWithKey:@"key_name" andValue:@"MyValue"];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.addQueryWithKey("key_name", andValue:"MyValue")
```

The name of the key to be added.

The value for the query key.

## addQueryParams:

A custom dictionary can be provided to a query that can specify the conditions for retrieving objects.

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query addQueryParams:@{@"Query_Key":@"Query Value"}];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.addQueryParams(["Query_Key":"Query Value"])
```

A dictionary with all the necessary conditions for retrieving objects.

## removeQueryWithKey:

Removes custom query.

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query removeQueryWithKey:@"Query_Key"];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.removeQueryWithKey("Query_Key")
```

The name of the query.

## whereKey:equalTo:

This method provides only the entries matching the specified value for a field.

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query  whereKey:@"title" equalTo:@"Welcome"];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.whereKey("title", equalTo:"Welcome")
```

Uid of the field that is to be taken into consideration

The value used to match or compare

## whereKey:notEqualTo:

This method provides only the entries with values not equal to the specified value for a field.

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query  whereKey:@"title" notEqualTo:@"Welcome"];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.whereKey("title", notEqualTo:"Welcome")
```

Uid of the field that is to be taken into consideration

The value used to match or compare

## whereKey:lessThan:

This method provides only the entries with a values less than the specified value for a field.

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query whereKey:@"created_at" lessThan:@"2015-03-12"];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.whereKey("created_at", lessThan:"2015-03-12")
```

Uid of the field that is to be taken into consideration

The value used to match or compare

## whereKey:greaterThan:

This method provides only the entries with values greater than the specified value for a field.

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query whereKey:@"created_at" greaterThan:@"2015-03-12"];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.whereKey("created_at", greaterThan:"2015-03-12")
```

Uid of the field that is to be taken into consideration

The value used to match or compare

## whereKey:lessThanOrEqualTo:

This method provides only the entries with values less than or equal to the specified value for a field.

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query whereKey:@"created_at" lessThanOrEqualTo:@"2015-03-12"];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.whereKey("created_at", lessThanOrEqualTo:"2015-03-12")
```

Uid of the field that is to be taken into consideration

The value used to match or compare

## whereKey:greaterThanOrEqualTo:

This method provides only the entries with values greater than or equal to the specified value for a field.

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query  whereKey:@"created_at" greaterThanOrEqualTo:@"2015-03-12"];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.whereKey("created_at", greaterThanOrEqualTo:"2015-03-12")
```

Uid of the field that is to be taken into consideration

The value used to match or compare

## whereKey:containedIn:

This method provides only the entries with values matching the specified values for a field.

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query whereKey:@"title" containedIn:@["Demo", @"Welcome"]];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.whereKey("title", containedIn:["Demo", "Welcome"])
```

Uid of the field that is to be taken into consideration

An array of values that are to be used to match or compare

## whereKey:notContainedIn:

This method provides only the entries that do not contain values matching the specified values for a field.

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query whereKey:@"title" notContainedIn:@["Demo", @"Welcome"]];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.whereKey("title", notContainedIn:["Demo", "Welcome"])
```

Uid of the field that is to be taken into consideration

An array of values that are to be used to match or compare

## whereKeyExists:

This method provides only the entries that contains the field matching the specified field uid.

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query whereKeyExists:@"introduction"];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.whereKeyExists("introduction")
```

Uid of the field that is to be taken into consideration

## whereKeyDoesNotExist:

This method provides only the entries that do not contain the field matching the specified field uid.

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query whereKeyDoesNotExist:@"introduction"];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.whereKeyDoesNotExist("introduction")
```

Uid of the field that is to be taken into consideration

## whereKey:matchesRegex:

This method provides only the entries matching the regular expression for the specified field.

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query whereKey:@"title" matchesRegex:@"^wel"];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.whereKey("title", matchesRegex:"^wel")
```

Uid of the field that is to be taken into consideration

The value used to match or compare

## whereKey:matchesRegex:modifiers:

This method provides only the entries matching the regular expression for the specified field.

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query whereKey:@"title" matchesRegex:@"^wel" modifiers:@"i"];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")
let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.whereKey("title", matchesRegex:"^wel", modifiers:"i")
```

Uid of the field that is to be taken into consideration

The value used to match or compare

Modifiers for regex options. Specify ‘i’ as the option to ignore the case.

## whereKey:in:

This method provides only the entries matching the Query.

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];

Query * reference = [contentType query];
[reference whereKey:@"name" equalTo:@"Author"];

[query whereKey:@"author" in:reference];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")

let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()

var reference:Query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
reference.whereKey("name", equalTo:"Author")

query.whereKey("author", in:reference)
```

Reference Uid of the field that is to be taken into consideration.

Query to be taken into consideration

## whereKey:notIn:

This method provides only the entries matching the Query.

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];

Query * reference = [contentType query];
[reference whereKey:@"name" equalTo:@"Author"];

[query whereKey:@"author" notIn:reference];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")

let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()

var reference:Query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
reference.whereKey("name", equalTo:"Author")

query.whereKey("author", notIn:reference)
```

Reference Uid of the field that is to be taken into consideration.

Query to be taken into consideration

## onlyFields:

This method provides only the entries that match the specified field uids and corresponding values.

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query onlyFields:@[@"attachments"]];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")

let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.onlyFields(["attachments"])
```

An array of values that are to be included for the key

## exceptFields:

This method provides all entries except those that match the specified field uids and corresponding values.

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query exceptFields:@[@"attachments"]];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")

let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.exceptFields(["attachments"])
```

An array of values that are to be included for the key

## includeReferenceFieldWithKey:

This method provides all entries that also contain data from the referred entry in the specified field.

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query includeReferenceFieldWithKey:@"entry_a"];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")

let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.includeReferenceFieldWithKey(@"entry_a")
```

Uid of the reference field that is to be taken into consideration

## includeReferenceFieldWithKey:onlyFields:

This method provides all entries including referred entry containing only specified fields.

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query includeReferenceFieldWithKey:@"entry_a" onlyFields:@[@"attachments"]];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")

let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.includeReferenceFieldWithKey(@"entry_a", onlyFields:["attachments"])
```

Uid of the reference field that is to be taken into consideration

Uid of the reference field that is to be taken into consideration

## includeReferenceFieldWithKey:excludingFields:

This method provides all entries including referred entry containing all fields except specified fields.

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query includeReferenceFieldWithKey:@"entry_a" excludingFields:@[@"attachments"]];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")

let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.includeReferenceFieldWithKey(@"entry_a", excludingFields:["attachments"])
```

Uid of the reference field that is to be taken into consideration

Uid of the reference field that is to be taken into consideration

## addParamKey:andValue:

This method provides all the entries from a specified ContentType.

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query addParamKey:@"key" andValue:@"value"];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")

let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.addParamKey("key", andValue:"value")
```

The key as string which needs to be added to the Query

The value as string which needs to be added to the Query

## find:

This method provides all the entries from a specified ContentType.

**Note:** By default, the limit for response details per request is 100, with the maximum limit set at 250.

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query find:^(ResponseType type, Entry *entry, NSError *error){

}];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")

let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.find({(responseType, entry!, error!) ->  in

})
```

Block to be called once operation is done.

## findOne:

This method provides the first entry from a specified ContentType.

```
Obj-C
Stack *stack = [Contentstack stackWithAPIKey:@"API_KEY" accessToken:@"DELIVERY_TOKEN" environmentName:@"ENVIRONMENT"];
ContentType *contentType = [stack contentTypeWithName:@"CONTENT_TYPE_UID"];
Query * query = [contentType query];
[query findOne:^(ResponseType type, Entry *entry, NSError *error){

}];Swift
let stack:Stack = Contentstack.stackWithAPIKey("API_KEY",accessToken:"DELIVERY_TOKEN", environmentName:@"ENVIRONMENT")

let query = stack.contentTypeWithName("CONTENT_TYPE_UID").query()
query.findOne({(responseType, entry!, error!) ->  in

})
```

Block to be called once operation is done.

The property to assign cache policy like CACHE\_THEN\_NETWORK, NETWORK\_ELSE\_CACHE, NETWORK\_ONLY, etc.

## Query | iOS Delivery SDK | Contentstack

Query lets you build and run content queries to filter and retrieve entries in the Contentstack iOS Delivery SDK.