---
title: "Contentstack Delivery Swift SDK"
description: "Documentation for Swift Delivery SDK"
url: "https://www.contentstack.com/docs/developers/sdks/content-delivery-sdk/swift/reference"
product: "Contentstack"
doc_type: "guide"
audience:
  - developers
  - admins
version: "current"
last_updated: "2026-03-28"
---

# Contentstack Delivery Swift SDK

## Contentstack - Swift SDK

## Overview

CocoaPods is planned to move to a read-only state and may not support future SDK updates. [Install the Swift CDA SDK](/docs/developers/sdks/content-delivery-sdk/ios/get-started-with-swift-sdk#sdk-installation-and-setup) using Swift Package Manager to ensure continued access to updates. For more details, refer to the [CocoaPods Trunk Read-Only Plan](https://blog.cocoapods.org/CocoaPods-Specs-Repo/?utm_source=chatgpt.com) announcement.

## Swift Delivery SDK for Contentstack

Contentstack is a headless CMS with an API-first approach. It is a CMS that developers can use to build powerful cross-platform applications in their favorite languages. Build your application frontend, and Contentstack will take care of the rest. [Read More](https://www.contentstack.com/).

Contentstack provides Swift Delivery SDK to build application on top of Swift. Given below is the detailed guide and helpful resources to get started with our Swift Delivery SDK.

The Swift Delivery SDK can also be used to create iOS, Apple TV and Mac applications.

## Prerequisite

Latest Xcode and Mac OS X

## Setup and Installation

To use this SDK on iOS platform, you will have to install the SDK according to the steps given below.

**CocoaPods**

*   Add the following line to your Podfile

```
pod ‘ContentstackSwift’
```

*   Run pod install, and you should now have the latest Contentstack release.

**Import Header/Module**

```
import ContentstackSwift
```

## Quickstart in 5 mins

## Initializing your SDK

To start using the SDK in your application, you will need to initialize the stack by providing the required keys and values associated with them:

```
let stack:Stack = Contentstack.stack(apiKey: API_KEY, deliveryToken: DELIVERY_TOKEN, environment: ENVIRONMENT)
```

To get the api credentials mentioned above, you need to log into your Contentstack account and then in your top panel navigation, go to Settings -> Stack to view both your API Key and your Delivery Token

The stack object that is returned is a Contentstack client object, which can be used to initialize different modules and make queries against our Content Delivery API. The initialization process for each module is explained in the following section.

## Querying content from your stack

To fetch all entries of of a content type, use the query given below:

```
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")stack.contentType(uid: contentTypeUID).entry().query().find { (result: Result<ContentstackResponse<EntryModel>, Error>, response: ResponseType) in      switch result {      case .success(let contentstackResponse):      case .failure(let error):      } }
```

To fetch a specific entry from a content type, use the following query:

```
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")stack.contentType(uid: contentTypeUID).entry(uid: UID).fetch { (result: Result<EntryModel, Error>, response: ResponseType) in     switch result {     case .success(let model):     case .failure(let error):     } }
```

## Paginating Responses

In a single instance, the Get Multiple Entries query will retrieve only the first 100 items of the specified content type. You can paginate and retrieve the rest of the items in batches using the **skip** and **limit** parameters in subsequent requests.

```
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")stack.contentType(uid: contentTypeUID).query().skip(20).limit(20).find { (result: Result<ContentstackResponse<EntryModel>, Error>, response: ResponseType) in      switch result {      case .success(let contentstackResponse):      case .failure(let error):      }}
```

## Querying Assets from your stack

To get a single asset, you need to specify the UID of the asset.

```
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")stack.asset(uid: "<ASSET_UID>").fetch { (result: Result<AssetModel, Error>, response: ResponseType) in   switch result {   case .success(let model):   case .failure(let error):   }}
```

To retrieve multiple assets. You can also specify search parameters to filter results.

```
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")stack.asset().query().find { (result: Result<ContentstackResponse<AssetModel>, Error>, response: ResponseType) in    switch result {    case .success(let contentstackResponse):    case .failure(let error):    }}
```

## Contentstack

Create a new Stack instance with stack’s apikey, deliveryToken, environment name and config.

## stack(apiKey:deliveryToken:environment:region:host:apiVersion:branch:config:)

Create a new Stack instance with stack’s API key, delivery token, environment name and config.

```
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")
```

stack apiKey.

stack delivery token.

environment name in which to perform action.

Contentstack region

Name of Contentstack api server.

API version of Contentstack api server.

Config of stack.

## Contentstack | Swift Delivery SDK | Contentstack

Contentstack lets you create a new Stack instance using your API key, delivery token, environment, and config in the Swift SDK.

## ContentstackConfig

## setEarlyAccess

With the setEarlyAccess header support, you can access features that are part of the early access program.

```
Example:

var config = ContentstackConfig()
let earlyAccess : [String] = ["Taxonomy","Teams"]
config.setEarlyAccess(earlyAccess)
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")
```

An optional configuration to override the date decoding strategy that is provided by the the SDK.

An optional configuration to override the TimeZone the SDK will use to decode Date instances. The SDK will use a TimeZone with 0 seconds offset from GMT if this configuration is omitted.

The configuration for the URLSession. Note that HTTP headers will be overwritten internally by the SDK so that requests can be authorized correctly.

## ContentstackRegion

Contentstack Regions.

*   us: This region is for AWS NA cloud
*   eu: This region is for AWS EU cloud
*   au: This region is for AWS AU cloud
*   azure\_na: This region is for Azure-NA cloud
*   azure\_eu: This region is for Azure-EU cloud
*   gcp\_na: This region is for GCP-NA cloud
*   gcp-eu: This region is for GCP-EU cloud

This region is for US Cloud.

This region is for EU Cloud.

This region is for AU Cloud.

This region is for AZURE-NA Cloud.

This region is for AZURE-EU Cloud

This region is for GCP-NA cloud

This region is for GCP-EU cloud

## ContentstackRegion | Swift Delivery SDK | Contentstack

ContentstackRegion defines the available data center regions, including US, EU, AU, Azure, and GCP, in the Swift Delivery SDK.

## ContentstackResponse

This is the result of any request of collection from Contentstack.

The resources which are part of the array response.

The maximum number of resources originally requested.

The number of elements skipped when performing the request.

The total number of resources which matched the original request.

The dictionary of fields from the response that are included in API request.

## ContentstackResponse | Swift Delivery SDK | Contentstack

ContentstackResponse holds the result of any collection request made through the Contentstack Swift Delivery SDK.

## Stack

Stack is instance for performing Contentstack Delivery API request.

## contentType(uid:)

Get instance of ContentType to fetch content-types and schema or fetch entries of specific content-type.

```
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.contentType()

stack.contentType(uid: "<CONTENT_TYPE_UID>")
```

The UId of ContentType you want to fetch data,

## asset(uid:)

Get instance of Asset to fetch Assets or fetch specific Asset.

```
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.asset()

stack.asset(uid: "<ASSET_UID>")
```

The UId of Asset you want to fetch data.

## sync(_:syncTypes:then:)

The Initial Sync request performs a complete sync of your app data. It returns all the published entries and assets of the specified stack in response. The response also contains a sync\_token, which you get in SyncStack, since this token is used to get subsequent delta updates later.

```
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")
stack.sync { (result: Result<SyncStack, Error>) in
    switch result {
    case .success(let syncStack):

    case .failure(let error):

    }
}
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

let syncStack = SyncStack(paginationToken: paginationToken)
stack.sync(syncStack, then: { (result: Result<SyncStack, Error>) in
    switch result {
    case .success(let syncStack):

    case .failure(let error):

    }
}
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

let syncStack = SyncStack(syncToken: syncToken)
stack.sync(syncStack, then: { (result: Result<SyncStack, Error>) in
    switch result {
    case .success(let syncStack):

    case .failure(let error):

    }
}
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")
stack.sync(syncTypes: [.publishType(.assetPublished)], then: { (result: Result<SyncStack, Error>) in
    switch result {
    case .success(let syncStack):

    case .failure(let error):

    }
}
```

The relevant SyncStack to perform the subsequent sync on. Defaults to a new empty instance of SyncStack.

SyncableTypes that can be sync.

A handler which will be called on completion of the operation.

API Key is a unique key assigned to each stack.

Delivery Token is a read-only credential that you can create for different environments of your stack.

Environment can be defined as one or more content delivery destinations

The domain host to perform requests against.

Region refers to the location of the data centers where your organization’s data resides.

Stack api version point.

Branch for the stack to get data from.

CachePolicy allows you to cache request

The JSONDecoder that the receiving client instance uses to deserialize JSON. The SDK will inject information about the locales to this decoder and use this information to normalize the fields dictionary of entries and assets.

## Stack | Swift Delivery SDK | Contentstack

Stack is the instance used to perform Contentstack Delivery API requests in the Swift Delivery SDK.

## CachePolicy

The cache policies allow you to define the source from where the SDK will retrieve the content.

The SDK retrieves data through a network call, and saves the retrieved data in the cache. This is set as the default policy.

The SDK gets data from the cache.

The SDK gets data from the cache. However, if it fails to retrieve data from the cache, it makes a network call.

The SDK gets data using a network call. However, if the call fails, it retrieves data from cache.

The SDK gets data from cache, and then makes a network call. (A success callback will be invoked twice.

## CachePolicy | Swift Delivery SDK | Contentstack

The CachePolicy enum in the Swift Delivery SDK defines the source from which the SDK retrieves content, letting you control caching behavior for requests.

## SyncStack

A container for the synchronized state of a Stack

## init(syncToken:paginationToken:)

Initialization method for the SyncStack.

The syncToken from the previous syncronization.

The paginationToken to fetch next batch of data.

You can use the sync\_token later to perform subsequent sync, which fetches only new changes through delta updates.

If there are more than 100 records, you get a pagination\_token in response. This token can be used to fetch the next batch of data.

The total number of resources which matched the original request.

The resources which are part of the array response.

## SyncStack | Swift Delivery SDK | Contentstack

SyncStack is a container that holds the synchronized state of a stack in the Contentstack Swift Delivery SDK.

## SyncableTypes

This enable to sync entity with condition.

Sync all assets and all entries of all content types.

Enter content type UIDs. e.g., products. This retrieves published entries of specified content type.

Enter locale codes. e.g., en-us This retrieves published entries of specific locale.

Enter the start date. e.g., Date() This retrieves published entries starting from a specific date.

If you do not specify any value from PublishType, it will bring all published entries and published assets. You can pass multiple types as comma-separated values.

## SyncableTypes | Swift Delivery SDK | Contentstack

SyncableTypes lets you sync entities with specific conditions in the Contentstack Swift Delivery SDK.

## PublishType

This enable to sync entity with Published type.

To sync only Published Entries.

To sync only Published Assets.

To sync only Unpublished Entries.

To sync only Unpublished Assets.

To sync only Deleted Entries.

To sync only Deleted Assets.

To sync only only deleted content type Entries.

## PublishType | Swift Delivery SDK | Contentstack

PublishType lets you sync entities filtered by their published type in the Contentstack Swift Delivery SDK.

## ImageTransform

The Image Delivery API is used to retrieve, manipulate and/or convert image files of your Contentstack account and deliver it to your web or mobile properties.

## auto()

The auto parameter lets you enable the functionality that automates certain image optimization features.

```
let urlString = "<IMAGE_URL_TO_TRANSFORM>"
let transform = ImageTransform().auto()
let result = urlString.url(with: transform)
```

## quality(_:)

The quality parameter lets you control the compression level of images that have Lossy file format. The value for this parameters can be entered in any whole number (taken as a percentage) between 1 and 100.

```
let urlString = "<IMAGE_URL_TO_TRANSFORM>"
let transform = ImageTransform().quality(10)
let result = urlString.url(with: transform)
```

## format(_:)

The format parameter lets you converts a given image from one format to another.

```
let urlString = "<IMAGE_URL_TO_TRANSFORM>"
let transform = ImageTransform().format(Format.gif)
let result = urlString.url(with: transform)
```

## resize(_:)

The width parameter lets you dynamically resize the width of the image by specifying pixels or percentage. The height parameter lets you dynamically resize the height of the image by specifying pixels or percentage. The disable parameter disables the functionality that is enabled by default.

```
let urlString = "<IMAGE_URL_TO_TRANSFORM>"
let transform = ImageTransform().resize(Resize(size: Size(width: width)))
let result = urlString.url(with: transform)
```

## crop(_:)

The crop parameter allows you to remove pixels from an image.

```
let urlString = "<IMAGE_URL_TO_TRANSFORM>"
let transform = ImageTransform().crop(.offset(width: 100, height: 100, xOffset: 0.5, yOffset: 0.7))
let result = urlString.url(with: transform)
```

## canvas(_:)

The canvas parameter allows you to increase the size of the canvas that surrounds an image.

```
let urlString = "<IMAGE_URL_TO_TRANSFORM>"
let transform = ImageTransform().canvas(.offset(width: 100, height: 100, xOffset: 0.5, yOffset: 0.7))
let result = urlString.url(with: transform)
```

## fit(_:)

The fit parameter enables you to fit the given image properly within the specified height and width. You need to provide values for the height, width and fit parameters.

```
let urlString = "<IMAGE_URL_TO_TRANSFORM>"
let transform = ImageTransform().fit(.bounds(Size(width: 100, height: 100)))
let result = urlString.url(with: transform)
```

## trim(_:)

The trim parameter lets you trim an image from the edges.

```
let urlString = "<IMAGE_URL_TO_TRANSFORM>"
let transform = ImageTransform().trim(NSEdgeInsets(top: 50, left: 20, bottom: 50, right: 20))
let result = urlString.url(with: transform)
```

## orient(_:)

The orient parameter lets you control the cardinal orientation of the given image.

```
let urlString = "<IMAGE_URL_TO_TRANSFORM>"
let transform = ImageTransform().orient(.default)
let result = urlString.url(with: transform)
```

## overlay(relativeUrl:overlayTypes:)

The overlay parameter allows you to put one image on top of another. You need to specify the relative URL of the image as value for this parameter.

```
let urlString = "<IMAGE_URL_TO_TRANSFORM>"
let relativeUrl = "<RELATIVE_URL>"
let transform = ImageTransform().overlay(relativeUrl: relativeUrl, 
                 overlayTypes: [
                    .align(.left),
                    .repeat(.both),
                    .size(Size(width: width, height: height))
                 ]))
let result = urlString.url(with: transform)
```

## overlay(relativeUrl:padding:)

The overlay-pad parameter allows you to add padding pixels to the edges of an overlay image. You need to specify the relative URL of the image as value for this parameter.

```
let urlString = "<IMAGE_URL_TO_TRANSFORM>"
let relativeUrl = "<RELATIVE_URL>"
let transform = ImageTransform().overlay(relativeUrl: relativeUrl, padding: NSEdgeInsets(top: 50, left: 20, bottom: 50, right: 20))
let result = urlString.url(with: transform)
```

## pad(_:)

The pad parameter lets you add extra pixels to the edges of an image. This is useful if you want to add whitespace or border to an image. The value for this parameter can be given in pixels or percentage.

```
let urlString = "<IMAGE_URL_TO_TRANSFORM>"
let transform = ImageTransform().pad(NSEdgeInsets(top: 50, left: 20, bottom: 50, right: 20))
let result = urlString.url(with: transform)
let urlString = "<IMAGE_URL_TO_TRANSFORM>"
let transform = ImageTransform().pad(UIEdgeInsets(top: 50, left: 20, bottom: 50, right: 20))
let result = urlString.url(with: transform)
```

## backgroundColor(_:)

The bg-color parameter lets you set a backgroud color for the given image.

```
let urlString = "<IMAGE_URL_TO_TRANSFORM>"
let transform = ImageTransform().backgroundColor(.hex("AAFF00")))
let result = urlString.url(with: transform)
```

## dpr(_:resize:)

The dpr parameter lets you deliver images with appropriate size to devices that come with a defined device pixel ratio.

```
let urlString = "<IMAGE_URL_TO_TRANSFORM>"
let transform = ImageTransform().dpr(1000, resize: Resize(size: Size(width: 320))))
let result = urlString.url(with: transform)
```

## blur(_:)

The blur parameter allows you to decrease the focus and clarity of a given image.

```
let urlString = "<IMAGE_URL_TO_TRANSFORM>"
let transform = ImageTransform().blur(10)
let result = urlString.url(with: transform)
```

## saturation(_:)

The saturation parameter allows you to increase or decrease the intensity of the colors in a given image.

```
let urlString = "<IMAGE_URL_TO_TRANSFORM>"
let transform = ImageTransform().saturation(10)
let result = urlString.url(with: transform)
```

## contrast(_:)

The contrast parameter allows you to increase or decrease the difference between the darkest and lightest tones in a given image.

```
let urlString = "<IMAGE_URL_TO_TRANSFORM>"
let transform = ImageTransform().contrast(10)
let result = urlString.url(with: transform)
```

## brightness(_:)

The brightness parameter allows you to increase or decrease the intensity with which an image reflects or radiates perceived light.

```
let urlString = "<IMAGE_URL_TO_TRANSFORM>"
let transform = ImageTransform().brightness(10)
let result = urlString.url(with: transform)
```

## fetchFirstFrame()

The frame parameter fetches the first frame from an animated GIF (Graphics Interchange Format) file that comprises a sequence of moving images.

```
let urlString = "<IMAGE_URL_TO_TRANSFORM>"
let transform = ImageTransform().fetchFirstFrame()
let result = urlString.url(with: transform)
```

## sharpen(amount:radius:threshold:)

The sharpen parameter allows you to increase the definition of the edges of objects in an image.

```
let urlString = "<IMAGE_URL_TO_TRANSFORM>"
let transform = ImageTransform().sharpen(amount: 11, radius: 2, threshold: 100)
let result = urlString.url(with: transform)
```

## ImageTransform | Swift Delivery SDK | Contentstack

ImageTransform lets you retrieve, manipulate, and convert image files for delivery to your properties via the Swift Delivery SDK.

## Canvas

The canvas parameter allows you to increase the size of the canvas that surrounds an image.

Crop by width and height.

Crop by aspect ratio.

Crop sub region.

Crop and offset.

## Canvas | Swift Delivery SDK | Contentstack

Canvas lets you increase the size of the canvas surrounding an image using the canvas parameter.

## Color

The bg-color parameter lets you set a backgroud color for the given image.

Hexadecimal value should be 3-digit or 6-digit.

Red, Blue, Green value which defines the intensity of the corresponding color, with the value ranging anywhere between 0 and 255 for each.

Red, Blue, Green value which defines the intensity of the corresponding color, with the value ranging anywhere between 0 and 255 for each. The alpha value defines the transparency, with 0.0 being fully transparent and 1.0 being completely opaque.

## Color | Swift Delivery SDK | Contentstack

Color lets you set a background color for a given image using the bg-color parameter.

## ContentstackLogger

An enum describing the types of messages to be logged.

The type of logger used to log messages; defaults to NSLog on iOS, tvOS, watchOS, macOS. Defaults to print on other platforms.

The highest order of message types that should be logged.

## ContentstackLogger | Swift Delivery SDK | Contentstack

ContentstackLogger is an enum describing the types of messages that can be logged in the Contentstack Swift Delivery SDK.

## LogLevel

An enum describing the types of messages to be logged.

Log nothing to the console.

Only log errors to the console.

Log messages when requests are sent, and when responses are received, as well as other useful information.

## LogLevel | Swift Delivery SDK | Contentstack

LogLevel is an enum describing the types of messages that can be logged in the Contentstack Swift Delivery SDK.

## LogType

The type of logger to use.

Log using simple Swift print statements.

Log using NSLog.

Log using a custom logger.

## LogType | Swift Delivery SDK | Contentstack

LogType lets you specify which type of logger to use in the Contentstack Swift Delivery SDK.

## Fit

The fit parameter enables you to fit the given image properly within the specified height and width. You need to provide values for the height, width and fit parameters

If fit is set to bounds, it will constrain the given image into the specified height and width.

If fit is set to crop, it will crop the given image to the defined height and width.

## Fit | Swift Delivery SDK | Contentstack

Fit lets you fit an image within a specified height and width using the Contentstack Swift Delivery SDK.

## Crop

The crop parameter allows you to remove pixels from an image.

Crop by width and height.

Crop by aspect ratio.

Crop sub region.

Crop and offset.

## Crop | Swift Delivery SDK | Contentstack

Crop lets you remove pixels from an image to trim it to your needs in the Contentstack Swift Delivery SDK.

## Format

The format parameter lets you converts a given image from one format to another.

Progressive JPEG Format

JPEG format.

GIF format.

PNG format.

WEBP format.

WEBP Lossy format.

WEBP Lossless format.

## Format | Swift Delivery SDK | Contentstack

Format lets you convert a given image from one file format to another in the Contentstack Swift Delivery SDK.

## Orientation

The orient parameter lets you control the cardinal orientation of the given image.

Set image to default

Flip image horizontally.

Flip image horizontally and vertically.

Flip image vertically.

Flip image horizontally and then rotate 90 degrees towards left.

Rotate image 90 degrees towards right

Flip image horizontally and then rotate 90 degrees towards right.

Rotate image 90 degrees towards left.

## Orientation | Swift Delivery SDK | Contentstack

Orientation lets you control the cardinal orientation of a given image in the Contentstack Swift Delivery SDK.

## OverlayAlign

The overlay-align parameter lets you define the position of the overlay image.

Align the overlay image to the top of the actual image.

Align the overlay image to the bottom of the actual image.

Align the overlay image to the left of the actual image.

Align the overlay image to the right of the actual image.

Align the overlay image to the middle (vertically) of the actual image.

Align the overlay image to the center (horizontally) of the actual image.

Align the overlay image to the top-left of the actual image.

Align the overlay image to the top-right of the actual image.

Align the overlay image to the bottom-left of the actual image.

Align the overlay image to the bottom-right of the actual image.

## OverlayAlign | Swift Delivery SDK | Contentstack

OverlayAlign lets you set the position of an overlay image on a given image in the Contentstack Swift Delivery SDK.

## OverlayRepeat

The overlay-repeat parameter lets you define how the overlay image will be repeated on the given image.

The overlay-repeat parameter for both.

The overlay-repeat parameter horizontal

The overlay-repeat parameter verticle.

## OverlayRepeat | Swift Delivery SDK | Contentstack

OverlayRepeat lets you define how an overlay image repeats across a given image in the Contentstack Swift Delivery SDK.

## OverlayType

The overlay parameter allows you to put one image on top of another. You need to specify the relative URL of the image as value for this parameter. SeeOverlay Settings

The overlay-align parameter lets you define the position of the overlay image.

The overlay-repeat parameter lets you define how the overlay image will be repeated on the given image.

The overlay-width parameter lets you define the width of the overlay image. Theoverlay-height parameter lets you define the height of the overlay image.

## OverlayType | Swift Delivery SDK | Contentstack

OverlayType lets you place one image on top of another using its relative URL in the Contentstack Swift Delivery SDK.

## ResizeFilter

The resize-filter parameter allows you to use the resizing filter to increase or decrease the number of pixels in a given image.

Default to none allow not to set Resize-filter

Utilizes the values of the neighbouring translated pixels to provide smoother and quick resizing of a given image.

Utilizes a 2x2 environment of pixels on an average. This filter blends new interpolated pixels with the original image pixels to generate a larger image with more detail.

Utilizes a 4x4 environment of pixels on average. This filter maintains the innermost pixels and discards all the extra details from a given image.

Enhances the ability to identify linear features and object edges of a given image. This filter uses the sinc resampling function to reconstruct the pixelation of an image and improve its quality.

Enhances the ability to identify linear features and object edges of a given image. This filter uses the since resampling function to reconstruct the pixelation of an image and improve its quality.

## ResizeFilter | Swift Delivery SDK | Contentstack

ResizeFilter lets you apply a resizing filter to increase or decrease the pixel count of an image in the Swift Delivery SDK.

## ResponseType

The response type define the source from where the SDK retrieve the content.

This specifies response is from cache.

This specifies response is from network call.

## ResponseType | Swift Delivery SDK | Contentstack

ResponseType defines the source from which the SDK retrieves content in the Contentstack Swift Delivery SDK.

## ImageTransformError

Information regarding an error received from Contentstack’s Image Delivery API.

Error description.

## ImageTransformError | Swift Delivery SDK | Contentstack

ImageTransformError holds details about errors returned by the Contentstack Image Delivery API in the Swift Delivery SDK.

## Resize

The width parameter lets you dynamically resize the width of the image by specifying pixels or percentage. The height parameter lets you dynamically resize the height of the image by specifying pixels or percentage. The disable parameter disables the functionality that is enabled by default. See Resize Images.

The Size parameter lets you dynamically resize the width and height of the output image by specifying pixels or percentage values.

This disableUpscale ensures that even if the specified height or width is much bigger than the actual image, it will not be rendered disproportionately.

The resize-filter parameter allows you to use the r esizing filter to increase or decrease the number of pixels in a given image.

## Resize | Swift Delivery SDK | Contentstack

Resize lets you dynamically adjust an image's width and height by pixels or percentage in the Contentstack Swift Delivery SDK.

## Size

The Size parameter lets you dynamically resize the width and height of the output image by specifying pixels or percentage values.

The width parameter lets you dynamically resize the width of the output image by specifying pixels or percentage values.

The height parameter lets you dynamically resize the height of the output image by specifying pixels or percentage values.

## Size | Swift Delivery SDK | Contentstack

Size lets you dynamically resize an output image by width and height using pixel or percentage values in the Swift Delivery SDK.

## ErrorInfo

A description about detailed error information.

A pseudo identifier for the error returned by the API(s). “InvalidAPIKey” is example.

A pseudo identifier for the error returned by the API(s). “InvalidDeliveryToken” is example.

A pseudo identifier for the error returned by the API(s). “InvalidEnvironment” is example.

A pseudo identifier for the error returned by the API(s). “InvalidUID” is example.

## ErrorInfo | Swift Delivery SDK | Contentstack

ErrorInfo provides detailed information describing an error in the Contentstack Swift Delivery SDK.

## APIError

Information regarding an error received from Contentstack’s API.

Error description.

Human readable error Message

Error Code from API.

More detailed error Information.

The HTTP status code.

## APIError | Swift Delivery SDK | Contentstack

The APIError class in the Swift Delivery SDK carries information about errors received from Contentstack's API, helping you diagnose failed requests.

## SystemFields

System Fields are available fields for entities in Contentstack.

The unique identifier of the entity.

The title of the entity.

Describes the date of the entity is created.

Describes the date of the entity is last updated.

## SystemFields | Swift Delivery SDK | Contentstack

SystemFields exposes the built-in fields available for entities in the Contentstack Swift Delivery SDK.

## AssetFields

The Protocol for creating Asset model.

Describes the unique identifier of user who created the entity.

Describes the unique identifier of user who last updated the entity.

The name of the Asset.

The size of the Asset.

The file type of the Asset.

The url for the Asset.

## AssetFields | Swift Delivery SDK | Contentstack

AssetFields is the Swift Delivery SDK protocol for creating an Asset model, defining the fields used to represent media files from Contentstack.

## Asset

The Asset class represents media files (eg, images, videos, PDFs, audio, etc.) in your Contentstack repository. Use it to fetch a single asset by UID or to build an asset query.

## cachePolicy Property

The cachePolicy property defines the caching strategy for the asset request (network vs cache).

Name

Type

Required

Default

Description

cachePolicy

CachePolicy

No

.networkOnly

Defines the retrieval strategy manually set on the Asset instance to determine whether the request uses the network, cache, or both.

  

**CachePolicy values:**

Value

Description

networkOnly

Fetches data from the network and updates the cache with the results. This is the default policy.

cacheOnly

Returns data exclusively from the cache without initiating a network request.

cacheElseNetwork

Attempts to retrieve from the cache first; initiates a network call only if a cache miss or failure occurs.

networkElseCache

Prioritizes the network request; returns cached data only if the network call fails.

cacheThenNetwork

The completion handler is invoked twice: first with the cached result (response == .cache), then with the network result (response == .network). If a cache miss occurs, the first invocation returns a failure. Use the response parameter to identify which result is being processed.

  

**Example**

Assign a CachePolicy value to the Asset instance before calling fetch:

```
let stack = Contentstack.stack(apiKey: apiKey,
                              deliveryToken: deliveryToken,
                              environment: environment)
let asset = stack.asset(uid: assetUID)
asset.cachePolicy = .networkOnly   // or .cacheOnly, .cacheElseNetwork, etc.
asset.locale("en-us").fetch { (result: Result<AssetModel, Error>, response: ResponseType) in
    switch result {
    case .success(let model): // Model retrieved from API
    case .failure(let error): // Error message
    }
}
```

## locale

The locale method sets the locale code used when fetching the asset so the response is in the requested language.

```
Returns the same Asset instance with the locale set for the next request. Use it to chain more options (e.g., includeDimension()) or to call fetch.
let stack = Contentstack.stack(apiKey: apiKey,
                 deliveryToken: deliveryToken,
                 environment: environment)

     // To retrieve a single asset with a specific locale
     stack.asset(uid: assetUID).locale("en-us")
     .fetch { (result: Result<AssetModel, Error>, response: ResponseType) in
        switch result {
        case .success(let model): //Model retrieved from API
        case .failure(let error): //Error Message
        }
     }
```

## includeRelativeURL()

The includeRelativeURL() method includes the relative URLs of the assets in the response instead of absolute URLs.

```
The same Asset instance. The next fetch returns that asset with relative URLs including includeRelativeURL().
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")
stack.asset(uid: "<ASSET_UID>").includeRelativeURL()
```

## includeFallback()

The includeFallback() method includes fallback published content when the requested locale has no published content.

```
The same Asset instance to enable chaining. The next fetch returns fallback locale content if the requested locale has none including includeFallback().
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")
stack.asset(uid: "<ASSET_UID>").includeFallback()
```

## includeDimension()

The includeDimension() method includes the image's dimensions (height and width) in the response.

**Supported image types:** JPG, GIF, PNG, WebP, BMP, TIFF, SVG, PSD.

**Note:** For non-image asset types (e.g., PDF, ZIP, video, or audio), the API may omit dimension data or return null. In these cases, the SDK does not throw an error; the dimension property on the AssetModel remains available but is set to nil. It is recommended to verify asset.dimension != nil before accessing width or height properties to avoid processing errors.

```
Returns the asset instance with image dimensions (width and height) using includeDimension().
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")
stack.asset(uid: "<ASSET_UID>").includeDimension()
```

## includeMetadata()

The includeMetadata() method includes asset metadata in the response body.

```
Returns extra asset metadata fields in addition to the standard asset data using includeMetadata().
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")
stack.asset(uid: "<ASSET_UID>").includeMetadata()
```

## query()

The query() method returns an AssetQuery to retrieve multiple assets with filters and pagination.

Single Asset by UID: Use fetch.

*   Method: stack.asset(uid: "ASSET\_UID").fetch { … }.
*   Result: Returns one AssetModel.

Multiple Assets (Collection): Use query.

*   Method: stack.asset().query().
*   Result: Chain methods (e.g., where, limit) and call find { … } to get a ContentstackResponse<AssetModel>.

**Note:**

*   Calling query() on an asset initialized with a UID (e.g., stack.asset(uid: "x").query()) is valid but redundant.
*   For a single asset by UID, prefer stack.asset(uid: "ASSET\_UID").fetch().

```
An AssetQuery instance for method chaining.
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")
stack.asset().query()
```

## fetch(completion:)

The fetch(completion:) call fetches the latest version of a specific Asset of a particular stack. The result is delivered to the completion handler.

```
No value. When the request finishes, the completion handler is invoked with Result<AssetModel, Error> and ResponseType.
Name
Type
Required
Default
Description
completion
(Result<AssetModel, Error>, ResponseType) -> Void
Yes
none
Defines the callback handler manually set in .fetch() to receive either the AssetModel results or an error once the request completes.
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")
stack.asset(uid: "<ASSET_UID>")
.fetch { (result: Result<AssetModel, Error>, response: ResponseType) in
   switch result {
   case .success(let model):
   case .failure(let error):
   }
}
```

A handler which will be called on completion of the operation.

## Asset | Swift Delivery SDK | Contentstack

The Asset class in the Swift Delivery SDK represents media files like images, videos, and PDFs, letting you fetch a single asset by UID or build asset queries.

## AssetQuery

Use the AssetQuery class to fetch all or find assets. You obtain it from an initialized Stack via stack.asset().query().

**Class Overview**

Name

Type

Description

cachePolicy

CachePolicy

Defines the caching strategy for the AssetQuery request. While the Stack sets a default, you can manually override it using methods like .networkOnly to ensure the most recent data is retrieved.

stack

Stack

Identifies the parent Stack instance that owns and executes the query. This is automatically assigned by the system when you call stack.asset().query(), ensuring the request is correctly scoped to your environment.

parameters

\[String: Any\]

Contains URI-based metadata sent with the request. These are automatically populated by the system through method calls such as locale(), include(), skip(), and limit() to refine your API results.

queryParameter

\[String: Any\]

Defines the filtering logic (e.g., where) for the request. The system populates these values based on your method calls, allowing you to narrow down asset results to meet specific criteria.

headers

\[String: String\]

Manages custom HTTP headers for the request. You can manually add values via addValue(\_:forHTTPHeaderField:) to meet unique security or transport requirements.

## locale(_:)

The locale(\_:) method sets the locale used when fetching assets, so the response is in the specified language/locale.

```
The same AssetQuery instance, for chaining
let stack = Contentstack.stack(apiKey: apiKey,
                 deliveryToken: deliveryToken,
                 environment: environment)

     // To retrieve assets with a specific locale
     stack.asset().query().locale("en-us")
    .find { (result: Result<ContentstackResponse<AssetModel>, Error>, response: ResponseType) in
        switch result {
        case .success(let contentstackResponse): // Models retrieved from API
        case .failure(let error): // Error Message
        }
     }Note: If locale(_:) is not called, the SDK does not provide a default value. The request is sent without a locale parameter, and the Contentstack Delivery API applies the Stack's default locale to the results.
```

Defines the locale code (e.g., "en-us") used to fetch assets in a specific language. It is set to ensure the API returns localized content.

## where(queryableCodingKey:_:)

Use this method to apply a filter on assets using a queryable field and a query operation (e.g., equals, includes).

```
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")
stack.asset().query()
.where(queryableCodingKey: .title, .equals("Asset Title"))
.find { (result: Result<ContentstackResponse<AssetModel>, Error>, response: ResponseType) in
    switch result {
    case .success(let contentstackResponse):
    case .failure(let error):
    }
}
```

The member of your QueryableCodingKey that you are performing your select operation against.

The query operation used in the query.

## include(params:)

The include(params:) method adds optional response options (count, relative URLs, dimensions, fallback, metadata) to the asset query.

```
AssetQuery.Include options:
Option
Description
.count
Include the total count of assets in the response.
.relativeURL
Include relative URLs for assets.
.dimension
Include image dimensions (height/width). Supported types: JPG, GIF, PNG, WebP, BMP, TIFF, SVG, PSD.
.fallback
Return fallback locale content when the requested locale is not available.
.metadata
Include metadata in the response.
.all
Equivalent to [.count, .relativeURL, .dimension, .fallback, .metadata].
Examples
Include all options (.all):
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")
stack.asset().query().include(params: [.all])
.find { (result: Result<ContentstackResponse<AssetModel>, Error>, response: ResponseType) in
    switch result {
    case .success(let contentstackResponse):
    case .failure(let error):        //Error Message
    }
}Include count only (.count):
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")
stack.asset().query().include(params: [.count]) 
.find { (result: Result<ContentstackResponse<AssetModel>, Error>, response: ResponseType) in 
  switch result { 
  case .success(let contentstackResponse): 
  case .failure(let error): 
  }
}Include relative URLs (.relativeURL):
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")
stack.asset().query().include(params: [.relativeURL])
.find { (result: Result<ContentstackResponse<AssetModel>, Error>, response: ResponseType) in
    switch result {
    case .success(let contentstackResponse):
    case .failure(let error):
    }
}Include image dimensions (.dimension):
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")
stack.asset().query().include(params: [.dimension]) 
.find { (result: Result<ContentstackResponse<AssetModel>, Error>, response: ResponseType) in 
  switch result { 
  case .success(let contentstackResponse): 
  case .failure(let error): 
  }
}Include fallback locale (.fallback):
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")
stack.asset().query().include(params: [.fallback]) 
.find { (result: Result<ContentstackResponse<AssetModel>, Error>, response: ResponseType) in 
  switch result { 
  case .success(let contentstackResponse): 
  case .failure(let error): 
  }
}
```

Defines optional data you manually set in .include() to return assets with metadata or relative URLs.

## AssetQuery | Swift Delivery SDK | Contentstack

AssetQuery in the Swift Delivery SDK lets you build and execute queries to retrieve and filter assets stored in your Contentstack stack.

## AssetQuery.Include

The AssetQuery.Include is parameter for including count, relative URLs, and dimensions in result.

To include count in the response.

To include the relative URLs of the assets in the response.

To include the dimensions (height and width) of the image in the response. Supported image types: JPG, GIF, PNG, WebP, BMP, TIFF, SVG, and PSD.

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

To include all AssetQuery.Include values.

## AssetQuery.Include | Swift Delivery SDK | Contentstack

AssetQuery.Include in the Swift Delivery SDK is a parameter for including count, relative URLs, and dimensions in asset query results.

## ContentType

Content type defines the structure or schema of a page or a section of your web or mobile property.

## entry(uid:)

Get instance of Entry to fetch Entry or fetch specific Entry.

```
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.contentType(uid: "<CONTENT_TYPE_UID>").entry()
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.contentType(uid: "<CONTENT_TYPE_UID>").entry(uid: "<ENTRY_UID>")
```

## includeGlobalFields()

To include Global Fields schema in ContentType response.

```
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.contentType(uid: "<CONTENT_TYPE_UID>").includeGlobalFields()
.fetch { (result: Result<ContentTypeModel, Error>, response: ResponseType) in
   switch result {
   case .success(let model):

   case .failure(let error):

   }
}
```

## query()

To fetch all or find ContentTypes query method is used.

```
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.contentType().query()
```

## fetch(_:)

This call fetches the latest version of a specific ContentType of a particular stack.

```
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.contentType(uid: "<CONTENT_TYPE_UID>")
.fetch { (result: Result<ContentTypeModel, Error>, response: ResponseType) in
   switch result {
   case .success(let model):

   case .failure(let error):

   }
}
```

A handler which will be called on completion of the operation.

Set cache policy for the ContentType request.

## ContentType | Swift Delivery SDK | Contentstack

ContentType defines the structure or schema of a page or section of your web or mobile property in the Swift Delivery SDK.

## ContentTypeDecodable

The decodable to get schema for ContentType.

## ContentTypeDecodable | Swift Delivery SDK | Contentstack

ContentTypeDecodable is the decodable used to get a content type's schema in the Contentstack Swift Delivery SDK.

## ContentTypeQuery

To fetch all or find ContentType use ContentTypeQuery.

## where(queryableCodingKey:_:)

Use this method to do a search on ContentType which enables searching for entries based on value’s for members of referenced entries.

```
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.contentType().query()
.where(queryableCodingKey: .title, .equals("ContentType Title"))
.find { (result: Result<ContentstackResponse<ContentTypeModel>, Error>, response: ResponseType) in
    switch result {
    case .success(let contentstackResponse):
        // Contentstack response with ContentTypeModel array in items.
    case .failure(let error):
        //Error Message
    }
}
```

The member of your QueryableCodingKey that you are performing your select operation against.

The query operation used in the query.

## include(params:)

Include URI parametes to fetch ContentType with Global Fields and Count.

```
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.contentType().query().include(params: [.all])
.find { (result: Result<ContentstackResponse<ContentTypeModel>, Error>, response: ResponseType) in
    switch result {
    case .success(let contentstackResponse):
        // Contentstack response with ContentTypeModel array in items.
    case .failure(let error):
        //Error Message
    }
}
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")
stack.contentType().query().include(params: [.count]) 
.find { (result: Result<ContentstackResponse<ContentTypeModel>, Error>, response: ResponseType) in 
  switch result { 
  case .success(let contentstackResponse): 

  case .failure(let error): 
  }
}
```

The member of your ContentTypeQuery.Include that you want to include in response

## includeMetadata()

Includes ContentTypeQuery metadata along with response body

```
let stack = Contentstack.stack(apiKey: apiKey,
 deliveryToken: deliveryToken,
  environment: environment)
  
stack.contentType(uid: contentTypeUID).entry().includeMetadata().query()
```

Set cache policy for the ContentTypeQuery request.

Stack instance for ContentTypeQuery to be fetched

URI Parameters.

Query parameter

## ContentTypeQuery | Swift Delivery SDK | Contentstack

ContentTypeQuery lets you fetch all or find specific content types in the Contentstack Swift Delivery SDK.

## ContentTypeQuery.Include

The \`ContentTypeQuery.Include\` is parameter for including count, Global Fields schema in result.

To include count in the response.

To include Global Fields schema in ContentType response,

To include all \`ContentTypeQuery.Include\` values.

## ContentTypeQuery.Include | Swift Delivery SDK | Contentstack

ContentTypeQuery.Include lets you add count and global field schema to content type query results in the Swift Delivery SDK.

## Entry

An Entry is the actual piece of content created using one of the defined content types.

## query()

To fetch all or find Entries query method is used.

```
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

let query = stack.contentType(uid: "<CONTENT_TYPE_UID>").entry(uid: "<ENTRY_UID>").query()
```

## query(_:)

To fetch all or find Entries to specific model query method is used.

```
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

let query = stack.contentType(uid: "<CONTENT_TYPE_UID>").entry(uid: "<ENTRY_UID>").query(Product.self)
```

A entry type for querying on.

## fetch(_:)

This call fetches the latest version of a specific Entry of a particular stack.

```
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.contentType(uid: "<CONTENT_TYPE_UID>").entry(uid: "<ENTRY_UID>")
.fetch { (result: Result<EntryModel, Error>, response: ResponseType) in
   switch result {
   case .success(let model):

   case .failure(let error):

   }
}
```

A handler which will be called on completion of the operation.

## Variants

The variants method retrieves details of a specific entry variant or an array of entry variants based on the applied query.

When Personalize creates a variant in the CMS, it assigns a "Variant Alias" to identify that specific variant. When fetching entry variants using the Delivery API, you can pass variant aliases in place of variant UIDs in the x-cs-variant-uid header.

```
Example 1:
import Contentstack
let stack = Contentstack.stack(
    apiKey: <API_KEY>,
    deliveryToken: <DELIVERY_TOKEN>,
    environment: <ENVIRONMENT>
)

stack
.contentType(uid: <CT_UID>)
.entry(uid: <ENTRY_UID>)
.variants(uid: <VARIANT_UID/VARIANT_ALIAS>)
.fetch { (result: Result<EntryModel, Error>, response: ResponseType) in
    switch result {
        case .success(let contentstackResponse):
            // Contentstack response with variant entry data
        case .failure(let error):
            // Error Message
    }
}
Example 2:
import Contentstack
let stack = Contentstack.stack(
    apiKey: <API_KEY>,
    deliveryToken: <DELIVERY_TOKEN>,
    environment: <ENVIRONMENT>
)

stack
.contentType(uid: <CT_UID>)
.entry(uid: <ENTRY_UID>)
.variants(uids: [<VARIANT_UID_1/VARIANT_ALIAS_1>, <VARIANT_UID_2/<VARIANT_ALIAS_2>, <VARIANT_UID_3/VARIANT_ALIAS_3>])
.fetch { (result: Result<EntryModel, Error>, response: ResponseType) in
    switch result {
        case .success(let contentstackResponse):
            // Contentstack response with variant entry data
        case .failure(let error):
            // Error Message
    }
}
```

Enter the UID of the variant

Set cache policy for the entry request.

Stack instance for Entry to be fetched

URI Parameters.

Query parameter

## Entry | Swift Delivery SDK | Contentstack

Entry represents an actual piece of content created from a defined content type in the Contentstack Swift Delivery SDK.

## EntryFields

The Protocol for creating Entry model.

The code for currently selected locale.

Describes the unique identifier of user who created the entity.

Describes the unique identifier of user who last updated the entity.

## EntryFields | Swift Delivery SDK | Contentstack

EntryFields is the protocol used to create an Entry model in the Contentstack Swift Delivery SDK.

## EntryDecodable

Decodable is a powerful Swift standard library feature that developers can use to decode custom types from external representation, such as JSON.

EntryDecodable is an extension of the decodable protocol that you can use to decode the response to a specific model. By using this protocol, you can define types that will be mapped from your entries of the content type.

In this guide, we will discuss how we can use the EntryDecodable Protocol in your Swift SDK.

**EntryDecodable Example Usage**

Let’s understand how to use this protocol with the help of a few examples.

**Standard Usage**

We have a content type named Session and to fetch entries of our Session content type from the Swift SDK, we need to create a class named Session that implements the EntryDecodable protocol as follows:

**Example usage:**

```
class Session: EntryDecodable {public enum FieldKeys: String, CodingKey {     case title, uid, locale, type, speakers     case createdAt = "created_at"     case updatedAt = "updated_at"     case createdBy = "created_by"     case updatedBy = "updated_by"     case sessionId = "session_id"     case desc = "description"     case sessionTime = "session_time" } var locale: String var title: String var uid: String var createdAt: Date? var updatedAt: Date? var createdBy: String? var updatedBy: String? var sessionId: Int var desc: String var type: String var sessionTime: SessionTime var speakers: [Speaker]? public required init(from decoder: Decoder) throws {     let container   = try decoder.container(keyedBy: FieldKeys.self)     uid = try container.decode(String.self, forKey: .uid)     title = try container.decode(String.self, forKey: .title)     createdBy = try? container.decode(String.self, forKey: .createdBy)     updatedBy = try? container.decode(String.self, forKey: .updatedBy)     createdAt = try? container.decode(Date.self, forKey: .createdAt)     updatedAt = try? container.decode(Date.self, forKey: .updatedAt)     locale = try container.decode(String.self, forKey: .locale)     sessionId = try container.decode(Int.self, forKey: .sessionId)     desc = try container.decode(String.self, forKey: .desc)     type = try container.decode(String.self, forKey: .type)     sessionTime = try container.decode(DateTime.self, forKey: .sessionTime)     speakers = try container.decode([Speaker].self, forKey: .speakers)  }}
```

**Usage in Referencing**

Let’s say there is another content type in our Stack named Speaker that is referenced in our Session Content Type.

For this case, we will create a class named Speaker that implements the EntryDecodable protocol as follows: **Example usage:**

```
class Speaker: EntryDecodable {  public enum FieldKeys: String, CodingKey {    case createdAt = "created_at"    case updatedAt = "updated_at"    case createdBy = "created_by"    case updatedBy = "updated_by"    case desc = "description"  }  var locale: String  var title: String  var uid: String  var createdAt: Date?  var updatedAt: Date?  var createdBy: String?  var updatedBy: String?  var sessionId: Int  var desc: String  var name: String  public required init(from decoder: Decoder) throws {    let container = try decoder.container(keyedBy: FieldKeys.self)    uid = try container.decode(String.self, forKey: .uid)    title = try container.decode(String.self, forKey: .title)    createdBy = try? container.decode(String.self, forKey: .createdBy)    updatedBy = try? container.decode(String.self, forKey: .updatedBy)    createdAt = try? container.decode(Date.self, forKey: .createdAt)    updatedAt = try? container.decode(Date.self, forKey: .updatedAt)    locale = try container.decode(String.self, forKey: .locale)    name = try container.decode(String.self, forKey: .name)    desc = try container.decode(String.self, forKey: .desc)  }}
```

In the Session class, we have a ‘session\_time’ Global Field. To parse it, we need to create a class named SessionTime that implements the Decodable protocol as follows.

**Example:**

```
class SessionTime: Decodable {  var startTime: Date?  var endTime: Date?  public enum CodingKeys: String, CodingKey {    case startTime = "start_time"    case endTime = "end_time"  }  public required init(from decoder: Decoder) throws {    let container = try decoder.container(keyedBy: CodingKeys.self)    startTime = try? container.decode(Date.self, forKey: .startTime)    endTime = try? container.decode(Date.self, forKey: .endTime)  }}
```

**Note**: If we have fields with Modular block, JSON, or an array of JSON in our content type, we can create a class that implements Decodable.

The CodingKey representing the field identifiers/JSON keys for the corresponding content type. These coding keys should be the same as those used when implementing Decodable.

## EntryDecodable | Swift Delivery SDK | Contentstack

EntryDecodable extends Swift's Decodable so you can map content type entries to custom models in the Swift Delivery SDK.

## BaseQuery

A concrete implementation of BaseQuery which serves as the base class for \`Query\`, \`ContentTypeQuery\` and \`AssetQuery\`.

## find(_:)

This is a generic find method which can be used to fetch collections of ContentType, Entry, and Asset instances.

```
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.contentType(uid: "<CONTENT_TYPE_UID>").entry().query()
.find { (result: Result<ContentstackResponse<EntryModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.contentType().query()
.find { (result: Result<ContentstackResponse<ContentTypeModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.asset().query()
.find { (result: Result<ContentstackResponse<AssetModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
```

A handler which will be called on completion of the operation.

## where(valueAtKeyPath:_:)

Method to adding Query.

```
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.contentType(uid: "<CONTENT_TYPE_UID>").entry().query()
.where(valueAtKeyPath: "<FIELD_UID>", .equals("Field condition"))
.find { (result: Result<ContentstackResponse<EntryModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.contentType().query()
.where(valueAtKeyPath: "<FIELD_UID>", .equals("Field condition"))
.find { (result: Result<ContentstackResponse<ContentTypeModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.asset().query()
.where(valueAtKeyPath: "<FIELD_UID>", .equals("Field condition"))
.find { (result: Result<ContentstackResponse<AssetModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
```

Key path for field uid.

The query operation used in the query.

## skip(theFirst:)

Instance method to mutating query to skip the first n records.

```
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.contentType(uid: "<CONTENT_TYPE_UID>").entry().query()
.skip(theFirst: 20)
.find { (result: Result<ContentstackResponse<EntryModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.contentType().query()
.skip(theFirst: 20)
.find { (result: Result<ContentstackResponse<ContentTypeModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.asset().query()
.skip(theFirst: 20)
.find { (result: Result<ContentstackResponse<AssetModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
```

The number of results that will be skipped in the query.

## limit(to:)

Instance method to mutating query to limit response to contain n values.

```
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.contentType(uid: "<CONTENT_TYPE_UID>").entry().query()
.limit(to: 20)
.find { (result: Result<ContentstackResponse<EntryModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.contentType().query()
.limit(to: 20)
.find { (result: Result<ContentstackResponse<ContentTypeModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.asset().query()
.limit(to: 20)
.find { (result: Result<ContentstackResponse<AssetModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
```

The number of results the response will be limited to.

## orderByAscending(keyPath:)

Instance method to ordering the response in ascending for specific field.

```
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.contentType(uid: "<CONTENT_TYPE_UID>").entry().query()
.orderByAscending(keyPath: “<FIELD_UID>”)
.find { (result: Result<ContentstackResponse<EntryModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.contentType().query()
.orderByAscending(keyPath: “<FIELD_UID>”)
.find { (result: Result<ContentstackResponse<ContentTypeModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.asset().query()
.orderByAscending(keyPath: “<FIELD_UID>”)
.find { (result: Result<ContentstackResponse<AssetModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
```

The key path for the property you are performing ordering.

## orderByDecending(keyPath:)

Instance method to ordering the response in descending for specific field.

```
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.contentType(uid: "<CONTENT_TYPE_UID>").entry().query()
.orderByDecending(keyPath: “<FIELD_UID>”)
.find { (result: Result<ContentstackResponse<EntryModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.contentType().query()
.orderByDecending(keyPath: “<FIELD_UID>”)
.find { (result: Result<ContentstackResponse<ContentTypeModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.asset().query()
.orderByDecending(keyPath: “<FIELD_UID>”)
.find { (result: Result<ContentstackResponse<AssetModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
```

The key path for the property you are performing ordering.

## addURIParam(dictionary:)

The parameters dictionary that are converted to URLComponents.

```
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.contentType(uid: "<CONTENT_TYPE_UID>").entry().query()
.addURIParam(dictionary: ["key": "value"])
.find { (result: Result<ContentstackResponse<EntryModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.contentType().query()
.addURIParam(dictionary: ["key": "value"])
.find { (result: Result<ContentstackResponse<ContentTypeModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.asset().query()
.addURIParam(dictionary: ["key": "value"])
.find { (result: Result<ContentstackResponse<AssetModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
```

The dictionary for URLComponents

## addURIParam(with:value:)

The parameters dictionary that are converted to URLComponents.

```
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.contentType(uid: "<CONTENT_TYPE_UID>").entry().query()
.addURIParam(with: “key”, value: “value”)
.find { (result: Result<ContentstackResponse<EntryModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.contentType().query()
.addURIParam(with: “key”, value: “value”)
.find { (result: Result<ContentstackResponse<ContentTypeModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.asset().query()
.addURIParam(with: “key”, value: “value”)
.find { (result: Result<ContentstackResponse<AssetModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
```

The key for query parameter,

The value for query parameter.

## addQuery(dictionary:)

The Query parameters dictionary that are converted to URLComponents.

```
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.contentType(uid: "<CONTENT_TYPE_UID>").entry().query()
.addQuery(dictionary: ["key": "value"])
.find { (result: Result<ContentstackResponse<EntryModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.contentType().query()
.addQuery(dictionary: ["key": "value"])
.find { (result: Result<ContentstackResponse<ContentTypeModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.asset().query()
.addQuery(dictionary: ["key": "value"])
.find { (result: Result<ContentstackResponse<AssetModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
```

The dictionary for URLComponents

## addQuery(with:value:)

The Query parameters dictionary that are converted to URLComponents.

```
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.contentType(uid: "<CONTENT_TYPE_UID>").entry().query()
.addQuery(with: "key", value: "value")
.find { (result: Result<ContentstackResponse<EntryModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.contentType().query()
.addQuery(with: "key", value: "value")
.find { (result: Result<ContentstackResponse<ContentTypeModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.asset().query()
.addQuery(with: "key", value: "value")
.find { (result: Result<ContentstackResponse<AssetModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
```

The key for query parameter.

The value for query parameter.

## BaseQuery | Swift Delivery SDK | Contentstack

BaseQuery is the Swift Delivery SDK base class powering Query, ContentTypeQuery, and AssetQuery for building and refining content queries.

## Query

To fetch all or find Entries use Query.

## where(valueAtKey:_:)

Use this method to do a search on Entries which enables searching for entries based on value’s for field key Path.

```
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.contentType(uid: "<CONTENT_TYPE_UID>").entry().query()
.where(valueAtKey: "<FIELD_UID>", .equals("Entry Title"))
.find { (result: Result<ContentstackResponse<EntryModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.contentType(uid: "<CONTENT_TYPE_UID>").entry().query()
.where(valueAtKey: "<FIELD_UID>", .notEquals("Entry Title"))
.find { (result: Result<ContentstackResponse<EntryModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.contentType(uid: "<CONTENT_TYPE_UID>").entry().query()
.where(valueAtKey: "<FIELD_UID>", .includes(["one", "two"])
.find { (result: Result<ContentstackResponse<EntryModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.contentType(uid: "<CONTENT_TYPE_UID>").entry().query()
.where(valueAtKey: "<FIELD_UID>", .excludes(["three", "four"]))
.find { (result: Result<ContentstackResponse<EntryModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.contentType(uid: "<CONTENT_TYPE_UID>").entry().query()
.where(valueAtKey: "<FIELD_UID>", .isLessThan(10))
.find { (result: Result<ContentstackResponse<EntryModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.contentType(uid: "<CONTENT_TYPE_UID>").entry().query()
.where(valueAtKey: "<FIELD_UID>", .isLessThanOrEqual(10))
.find { (result: Result<ContentstackResponse<EntryModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.contentType(uid: "<CONTENT_TYPE_UID>").entry().query()
.where(valueAtKey: "<FIELD_UID>", .isGreaterThan(10))
.find { (result: Result<ContentstackResponse<EntryModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.contentType(uid: "<CONTENT_TYPE_UID>").entry().query()
.where(valueAtKey: "<FIELD_UID>", .isGreaterThanOrEqual(10))
.find { (result: Result<ContentstackResponse<EntryModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.contentType(uid: "<CONTENT_TYPE_UID>").entry().query()
.where(valueAtKey: "<FIELD_UID>", exists(true))
.find { (result: Result<ContentstackResponse<EntryModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.contentType(uid: "<CONTENT_TYPE_UID>").entry().query()
.where(valueAtKey: "<FIELD_UID>", .matches("^[a-z]"))
.find { (result: Result<ContentstackResponse<EntryModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
```

The field key path that you are performing your select operation against.

The query operation used in the query.

## where(queryableCodingKey:_:)

Use this method to do a search on Entries which enables searching for entries based on value’s for members of referenced entries.

```
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.contentType(uid: "<CONTENT_TYPE_UID>").entry().query()
.where(queryableCodingKey: .title, .equals("Entry Title"))
.find { (result: Result<ContentstackResponse<EntryModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.contentType(uid: "<CONTENT_TYPE_UID>").entry().query()
.where(queryableCodingKey: .title, .notEquals("Entry Title"))
.find { (result: Result<ContentstackResponse<EntryModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.contentType(uid: "<CONTENT_TYPE_UID>").entry().query()
.where(queryableCodingKey: .title, .includes(["one", "two"])
.find { (result: Result<ContentstackResponse<EntryModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.contentType(uid: "<CONTENT_TYPE_UID>").entry().query()
.where(queryableCodingKey: .title, .excludes(["three", "four"]))
.find { (result: Result<ContentstackResponse<EntryModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.contentType(uid: "<CONTENT_TYPE_UID>").entry().query()
.where(queryableCodingKey: .age, .isLessThan(10))
.find { (result: Result<ContentstackResponse<EntryModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.contentType(uid: "<CONTENT_TYPE_UID>").entry().query()
.where(queryableCodingKey: .age, .isLessThanOrEqual(10))
.find { (result: Result<ContentstackResponse<EntryModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.contentType(uid: "<CONTENT_TYPE_UID>").entry().query()
.where(queryableCodingKey: .age, .isGreaterThan(10))
.find { (result: Result<ContentstackResponse<EntryModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.contentType(uid: "<CONTENT_TYPE_UID>").entry().query()
.where(queryableCodingKey: .age, .isGreaterThanOrEqual(10))
.find { (result: Result<ContentstackResponse<EntryModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.contentType(uid: "<CONTENT_TYPE_UID>").entry().query()
.where(queryableCodingKey: .title, exists(true))
.find { (result: Result<ContentstackResponse<EntryModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.contentType(uid: "<CONTENT_TYPE_UID>").entry().query()
.where(queryableCodingKey: .title, .matches("^[a-z]"))
.find { (result: Result<ContentstackResponse<EntryModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
```

The member of your EntryModel.FieldKeys that you are performing your select operation against.

The query operation used in the query.

## where(referenceAtKeyPath:_:)

Use this method to do a search on Entries which enables searching for entries based on value’s for members of referenced entries.

```
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

let referenceQuery = stack.contentType(uid: "<CONTENT_TYPE_UID>").entry().query()
.where(queryableCodingKey: EntryModel.FieldKeys.title,Query.Operation.equals("10"))

let inReference = Query.Reference.include(referenceQuery)

stack.contentType(uid: "<CONTENT_TYPE_UID>").entry().query()
.where(referenceAtKeyPath: .title, inReference)
.find { (result: Result<ContentstackResponse<EntryModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

let referenceQuery = stack.contentType(uid: "<CONTENT_TYPE_UID>").entry().query()
.where(queryableCodingKey: EntryModel.FieldKeys.title,Query.Operation.equals("10"))

let ninReference = Query.Reference.notInclude(referenceQuery)

stack.contentType(uid: "<CONTENT_TYPE_UID>").entry().query()
.where(referenceAtKeyPath: .title, ninReference)
.find { (result: Result<ContentstackResponse<EntryModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
```

The reference field key path that you are performing your select operation against.

The query operation used in the query.

## orderByAscending(propertyName:)

When fetching entries, you can sort them in the ascending order with respect to the value of a specific field in the response body.

```
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.contentType(uid: "<CONTENT_TYPE_UID>").entry().query()
.orderByAscending(propertyName: .title)
.find { (result: Result<ContentstackResponse<EntryModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
```

The member of your \`EntryModel.FieldKeys\` that you are performing order by ascending.

## orderByDecending(propertyName:)

When fetching entries, you can sort them in the descending order with respect to the value of a specific field in the response body.

```
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.contentType(uid: "<CONTENT_TYPE_UID>").entry().query()
.orderByDecending(propertyName: .title)
.find { (result: Result<ContentstackResponse<EntryModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
```

The member of your \`EntryModel.FieldKeys\` that you are performing order by descending.

## tags(for:)

Use this method to do a search on tags for Entries.

```
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

stack.contentType(uid: "<CONTENT_TYPE_UID>").entry().query()
.tags(for: "tagSearchString")
.find { (result: Result<ContentstackResponse<EntryModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
```

The text string to match against.

## operator(_:)

Use this method to do a search on Entries which enables searching for entries based on Query.Operator.

```
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

let query1 = stack.contentType(uid: "<CONTENT_TYPE_UID>").entry().query()
.where(valueAtKeyPath: "title", Query.Operation.equals("Gold"))

let query2 = stack.contentType(uid: "<CONTENT_TYPE_UID>").entry().query()
.where(valueAtKeyPath: "name", Query.Operation.equals("John"))

stack.contentType(uid: "<CONTENT_TYPE_UID>").entry().query()
.operator(.and([query1, query2]))
.find { (result: Result<ContentstackResponse<EntryModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")

let query1 = stack.contentType(uid: "<CONTENT_TYPE_UID>").entry().query()
.where(valueAtKeyPath: "title", Query.Operation.equals("Gold"))

let query2 = stack.contentType(uid: "<CONTENT_TYPE_UID>").entry().query()
.where(valueAtKeyPath: "name", Query.Operation.equals("John"))

stack.contentType(uid: "<CONTENT_TYPE_UID>").entry().query()
.operator(.or([query1, query2]))
.find { (result: Result<ContentstackResponse<EntryModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
```

The member of Query.Operator that you are performing.

Stack instance for the Query.

URI parameter

Query parameters.

To set the cache policy for the query request.

## Query | Swift Delivery SDK | Contentstack

Query lets you fetch all entries or find specific entries in the Contentstack Swift Delivery SDK.

## EntryQueryable

Query class for Entry.

## locale(_:)

Instance method to fetch Entry for specific locale.

```
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")
stack.contentType(uid: contentTypeUID).entry().query()
.locale("<LOCALE_CODE>")
.fetch { (result: Result<ContentstackResponse<EntryModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
```

The code for fetching entry for locale.

## only(fields:)

Specifies an array of only keys in BASE object that would be included in the response.

```
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")
stack.contentType(uid: contentTypeUID).entry().query()
.only(["<FIELD_UID_TO_EXCEPT>"])
.fetch { (result: Result<ContentstackResponse<EntryModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
```

List for field uids to included in response.

## except(fields:)

Specifies an array of except keys in BASE object that would be included in the response.

```
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")
stack.contentType(uid: contentTypeUID).entry().query()
.except(["<FIELD_UID_TO_EXCEPT>"])
.fetch { (result: Result<ContentstackResponse<EntryModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
```

List for field uids to excepted in response

## includeReference(with:)

Instance method to include reference objects with given key in response.

```
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")
stack.contentType(uid: contentTypeUID).entry().query()
.includeReference(with: ["<REFERENCE_FIELD_UIDS>"])
.fetch { (result: Result<ContentstackResponse<EntryModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
```

List for reference field uids to include reference in response.

## include(params:)

Instance method for including count, Unpublished, ContentType schema, Global Fields schema, and Reference ContentType Uid in result.

```
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")
stack.contentType(uid: contentTypeUID).entry().query().include(params: [.count])
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")
stack.contentType(uid: contentTypeUID).entry().query().include(params: [.refContentTypeUID])
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")
stack.contentType(uid: contentTypeUID).entry().query().include(params: [.contentType])
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")
stack.contentType(uid: contentTypeUID).entry().query().include(params: [.globalField])
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")
stack.contentType(uid: contentTypeUID).entry().query().include(params: [.fallback])
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")
stack.contentType(uid: contentTypeUID).entry().query().include(params: [.embeddedItems])
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")
stack.contentType(uid: contentTypeUID).entry().query().include(params: [.unpublished])
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")
stack.contentType(uid: contentTypeUID).entry().query().include(params: [.count, .fallback, .embeddedItems])
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")
stack.contentType(uid: contentTypeUID).entry().query().include(params: [.all])
```

The member of your Query.Include that you want to include in response

## includeReferenceField(with:only:)

Specifies an array of only keys in reference object that would be included in the response.

```
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")
stack.contentType(uid: contentTypeUID).entry().query()
.includeReferenceField(with: "<REFERENCE_FIELD_UID>",only:["<ONLY_FIELD_UIDS>"])
.fetch { (result: Result<ContentstackResponse<EntryModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
```

Reference field uid as key to include reference.

List of field uid's to be included in response.

## includeReferenceField(with:except:)

Specifies an array of except keys in reference object that would be included in the response.

```
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")
stack.contentType(uid: contentTypeUID).entry().query()
.includeReferenceField(with: "<REFERENCE_FIELD_UID>",except:["<EXCEPT_FIELD_UIDS>"])
.fetch { (result: Result<ContentstackResponse<EntryModel>, Error>, response: ResponseType) in
   switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

   }
}
```

Reference field uid as key to include reference.

List of field uid's to be excluded in response.

## includeMetadata()

Includes AssetQuery metadata along with response body.

```
let stack = Contentstack.stack(apiKey:"API_KEY", deliveryToken:"DELIVERY_TOKEN", environment: "ENVIRNOMENT")
stack.contentType(uid: contentTypeUID).entry().query()
.includeMetadata()
.fetch { (result: Result ContentstackResponse&lt;EntryMode&gt;, Error&lt;response: ResponseType&gt;) in
switch result {
case.success(let contentstackResponse):
case.failure(let error):

  }
}
```

## EntryQueryable | Swift Delivery SDK | Contentstack

EntryQueryable is the query class used to build and run entry queries in the Contentstack Swift Delivery SDK.

## FieldKeysQueryable

A protocol enabling strongly typed queries to the Contentstack Delivery API via the SDK.

The CodingKey representing the field identifiers/JSON keys for the corresponding content type. These coding keys should be the same as those used when implementing Decodable.

## FieldKeysQueryable | Swift Delivery SDK | Contentstack

FieldKeysQueryable is a protocol enabling strongly typed queries to the Contentstack Delivery API via the Swift SDK.

## QueryProtocol

A base Query protocol which holds the essentials shared by all query types in the SDK which enable querying against content types, entries and assets.

The Stack instance to perform operation.

The parameters dictionary that are converted to \`URLComponents\`.

The Query parameters dictionary that are converted to \`URLComponents\`.

The cachePolicy that is use for fetching entity.

## QueryProtocol | Swift Delivery SDK | Contentstack

QueryProtocol is the base protocol shared by all query types for content types, entries, and assets in the Swift Delivery SDK.

## Queryable

The base Queryable protocol to find collections for content types, assets, and entries.

## find(_:)

This is a generic find method which can be used to fetch collections of **ContentType**, **Entry**, and **Asset** instances.

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

A handler which will be called on completion of the operation.

## Queryable | Swift Delivery SDK | Contentstack

Queryable is the base protocol for finding collections of content types, assets, and entries in the Swift Delivery SDK.

## QueryableRange

Use types that conform to QueryableRange to perform queries with the four Range operators

A string representation of a query value that can be used in an API query.

## QueryableRange | Swift Delivery SDK | Contentstack

QueryableRange lets conforming types run queries using the four range operators in the Swift Delivery SDK.

## ResourceQueryable

The base Queryable protocol to fetch instance for **ContentType**, **Asset**, and **Entry**.

## fetch(_:)

This call fetches the latest version of a specific **ContentType**, **Asset**, and **Entry** of a particular stack.

A handler which will be called on completion of the operation.

## ResourceQueryable | Swift Delivery SDK | Contentstack

ResourceQueryable is the base protocol for fetching ContentType, Asset, and Entry instances in the Swift Delivery SDK.

## Operator

When fetching entries, you can perform \`and\` or \`or\` operation.

[And Operator](https://www.contentstack.com/docs/developers/apis/content-delivery-api/#and-operator).

[Or Operator](https://www.contentstack.com/docs/developers/apis/content-delivery-api/#or-operator).

## Operator | Swift Delivery SDK | Contentstack

Operator lets you combine entry search conditions using and or or operations in the Contentstack Swift Delivery SDK.

## Reference

When fetching entries, you can search base on reference \`$in\` or \`$nin\`.

[Reference Search Equals](https://www.contentstack.com/docs/developers/apis/content-delivery-api/#reference-search-equals).

[Reference Search Not-equals](https://www.contentstack.com/docs/developers/apis/content-delivery-api/#reference-search-not-equals).

## Reference | Swift Delivery SDK | Contentstack

Reference lets you search entries based on referenced fields using $in or $nin operators in the Swift Delivery SDK.

## Operation

When fetching entries, you can search on field key paths.

[Equals Operator](https://www.contentstack.com/docs/developers/apis/content-delivery-api/#equals-operator)

[Not-equals Operator](https://www.contentstack.com/docs/developers/apis/content-delivery-api/#not-equals-operator)

[Includes content in array](https://www.contentstack.com/docs/developers/apis/content-delivery-api/#array-equals-operator)

[Excludes content in array](https://www.contentstack.com/docs/developers/apis/content-delivery-api/#array-equals-operator).

[Less Than](https://www.contentstack.com/docs/developers/apis/content-delivery-api/#less-than).

[Less than or equal](https://www.contentstack.com/docs/developers/apis/content-delivery-api/#less-than-or-equal-to).

[Greater Than](https://www.contentstack.com/docs/developers/apis/content-delivery-api/#greater-than).

[Greater than or equal](https://www.contentstack.com/docs/developers/apis/content-delivery-api/#greater-than-or-equal-to).

[The existence operator](https://www.contentstack.com/docs/developers/apis/content-delivery-api/#exists).

[Search on a field by Regex](https://www.contentstack.com/docs/developers/apis/content-delivery-api/#search-by-regex)

## Operation | Swift Delivery SDK | Contentstack

Operation lets you search entries on field key paths when fetching content in the Contentstack Swift Delivery SDK.

## Include

The \`Query.Include\` is parameter for including count, Unpublished, ContentType schema, Global Fields schema, and Reference ContentType Uid in result.

Each bit of rawValue potentially represents an element of the option set.

To include count in the response.

To include Unpublished Entries in response,

To include ContentType schema in Entry response,

To include Global Fields schema in Entry response.

To include Reference ContentType Uid in reference field in Entry response.

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

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

To include all Query.Include values.

## Include | Swift Delivery SDK | Contentstack

Include lets you add count, unpublished items, content type and global field schema, and reference UIDs to results in the Swift SDK.

## QueryOn

To fetch all or find Entries and Querying for Specific Model use QueryOn.

## where(queryableCodingKey:_:)

Use this method to do a search on Entries which enables searching for entries based on value’s queryable coding from \`EntryType.FieldKeys\`.

```
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")
stack.contentType(uid: "<CONTENT_TYPE_UID>").entry().query(Product.Self)
.where(queryableCodingKey: .title, .equals("Entry Title"))
.find { (result: Result<ContentstackResponse<EntryModel>, Error>, response: ResponseType) in
    switch result {
    case .success(let contentstackResponse):
        
    case .failure(let error):
        
    }
}
```

The member of your EntryType.FieldKeys that you are performing your select operation against.

The query operation used in the query.

## orderByAscending(propertyName:)

When fetching entries, you can sort them in the ascending order with respect to the value of a specific field in the response body.

```
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")
stack.contentType(uid: "<CONTENT_TYPE_UID>").entry().query(Product.Self)
.orderByAscending(propertyName: .title)
.find { (result: Result<ContentstackResponse<EntryModel>, Error>, response: ResponseType) in
    switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

    }
}
```

The member of your EntryType.FieldKeys that you are performing order by ascending.

## orderByDecending(propertyName:)

When fetching entries, you can sort them in the decending order with respect to the value of a specific field in the response body.

```
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")
stack.contentType(uid: "<CONTENT_TYPE_UID>").entry().query(Product.Self)
.orderByDecending(propertyName: .title)
.find { (result: Result<ContentstackResponse<EntryModel>, Error>, response: ResponseType) in
    switch result {
    case .success(let contentstackResponse):

    case .failure(let error):

    }
}
```

The member of your EntryType.FieldKeys that you are performing order by descending.

## QueryOn | Swift Delivery SDK | Contentstack

QueryOn lets you fetch entries and run queries for a specific model in the Contentstack Swift Delivery SDK.

## 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.

## Global FIelds

A Global field is a reusable field (or group of fields) that you can define once and reuse in any content type within your stack. This eliminates the need (and thereby time and efforts) to create the same set of fields repeatedly in multiple content types.

**Example:**

```
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")
stack.globalField().find{(result: Result<ContentstackResponse<GlobalFieldModel>, Error>, responseType) in
switch result {
     case .success(let model):

     case .failure(let error):

     }
}
```

## fetch

The fetch method retrieves the data of the specified global field.

```
Example:
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<envirnoment>")
stack.globalField(uid: globalFieldUid).fetch{ (result: Result<GlobalFieldModel, Error>, _) in
switch result {
     case .success(let model):

     case .failure(let error):

     }
}
```

UID of the Global field

## find

The find method retrieves the data of the all the global fields of the stack.

```
Example:
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")
stack.globalField().includeBranch().find{(result: Result<ContentstackResponse<GlobalFieldModel>, Error>, responseType) in
switch result {
     case .success(let model):

     case .failure(let error):

     }
}
```

## includeBranch

The fiincludeBranchd method includes the branch details for single or multiple global fields

```
Example:
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")
let stack = Contentstack.stack(apiKey: "<API_KEY>", deliveryToken: "<DELIVERY_TOKEN>", environment: "<ENVIRNOMENT>")
stack.globalField().includeBranch().find{(result: Result<ContentstackResponse<GlobalFieldModel>, Error>, responseType) in
switch result {
     case .success(let model):

     case .failure(let error):

     }
}

Note: 
  
    Information about Global fields can be retrieved by all users, regardless of their role or access level.
    If your Global field contains nested Global fields, they will appear as part of the schema in the API response.
```

## Global FIelds | Swift Delivery SDK | Contentstack

Global Fields are reusable fields you define once and reuse across content types in the Contentstack Swift Delivery SDK.