Install the iOS API client


  • Add a dependency on InstantSearchClient:
    • CocoaPods: add pod 'InstantSearchClient', '~> 6.0' to your Podfile for Swift 4.2
    • CocoaPods: add pod 'InstantSearchClient', '~> 5.0' to your Podfile for Swift 4.1
    • Carthage: add github "algolia/algoliasearch-client-swift" ~> 6.0.0 to your Cartfile for Swift 4.2
    • Carthage: add github "algolia/algoliasearch-client-swift" ~> 5.0.0 to your Cartfile for Swift 4.1
  • Add import InstantSearchClient to your source files

Supported platforms

The API client is supported on iOS, macOS, tvOS and watchOS. You can use it from both Swift and Objective-C.

Language-specific notes

You can browse the automatically generated reference documentation.


If you were using version 2.x of our Swift client, read the migration guide to version 3.x.

Init Index

To begin, you will need to initialize the client. In order to do this you will need your Application ID and API Key. You can find both on your Algolia account.

let client = Client(appID: "YourApplicationID", apiKey: "YourAPIKey")
let index = client.index(withName: "your_index_name")

You need to replace your_index_name by the name of the index you want to use. If you want to target an existing index you can find the name from the dashboard. If the index does not exist you can choose any name and it will be created when you perform an add objects or a set settings operation.

If an api key is displayed in the previous snippet it is your ADMIN API Key. To maintain security, never use your ADMIN API Key on your frontend or share it with anyone. In your frontend, use the SEARCH ONLY API Key or any other key that has search only rights.

Make sure you don’t use any sensitive or personally identifiable information (PII) as your index name, including customer names, user IDs, or email addresses. Index names appear in network requests and should be considered publicly available.

If you are building a native app on mobile, be sure to not include the search API key directly in the source code. You should instead consider fetching the key from your servers during the app’s startup.