Client

@objcMembers
public class Client : AbstractClient

Entry point into the Swift API.

  • Algolia application ID.

    Declaration

    Swift

    @objc
    public var appID: String { get }
  • Algolia API key.

    Declaration

    Swift

    @objc
    public var apiKey: String { get set }
  • Create a new Algolia Search client.

    Declaration

    Swift

    @objc
    public init(appID: String, apiKey: String)

    Parameters

    appID

    The application ID (available in your Algolia Dashboard).

    apiKey

    A valid API key for the service.

  • Obtain a proxy to an Algolia index (no server call required by this method).

    Note

    Only one instance can exist for a given index name. Subsequent calls to this method with the same index name will return the same instance, unless it has already been released.

    Declaration

    Swift

    @objc(indexWithName:)
    public func index(withName indexName: String) -> Index

    Parameters

    indexName

    The name of the index.

    Return Value

    A proxy to the specified index.

  • List all existing indexes.

    Declaration

    Swift

    @discardableResult
    @objc(listIndexesWithRequestOptions:completionHandler:)
    public func listIndexes(requestOptions: RequestOptions? = nil, completionHandler: @escaping CompletionHandler) -> Operation

    Parameters

    requestOptions

    Request-specific options.

    completionHandler

    Completion handler to be notified of the request’s outcome.

    Return Value

    A cancellable operation.

  • Delete an index.

    Declaration

    Swift

    @discardableResult
    @objc(deleteIndexWithName:requestOptions:completionHandler:)
    public func deleteIndex(withName name: String, requestOptions: RequestOptions? = nil, completionHandler: CompletionHandler? = nil) -> Operation

    Parameters

    name

    Name of the index to delete.

    requestOptions

    Request-specific options.

    completionHandler

    Completion handler to be notified of the request’s outcome.

    Return Value

    A cancellable operation.

  • Move an existing index.

    If the destination index already exists, its specific API keys will be preserved and the source index specific API keys will be added.

    Declaration

    Swift

    @discardableResult
    @objc(moveIndexFrom:to:requestOptions:completionHandler:)
    public func moveIndex(from srcIndexName: String, to dstIndexName: String, requestOptions: RequestOptions? = nil, completionHandler: CompletionHandler? = nil) -> Operation

    Parameters

    srcIndexName

    Name of index to move.

    dstIndexName

    The new index name.

    requestOptions

    Request-specific options.

    completionHandler

    Completion handler to be notified of the request’s outcome.

    Return Value

    A cancellable operation.

  • Copy an existing index.

    If the destination index already exists, its specific API keys will be preserved and the source index specific API keys will be added.

    Declaration

    Swift

    @discardableResult
    @objc(copyIndexFrom:to:requestOptions:completionHandler:)
    public func copyIndex(from srcIndexName: String, to dstIndexName: String, requestOptions: RequestOptions? = nil, completionHandler: CompletionHandler? = nil) -> Operation

    Parameters

    srcIndexName

    Name of the index to copy.

    dstIndexName

    The new index name.

    requestOptions

    Request-specific options.

    completionHandler

    Completion handler to be notified of the request’s outcome.

    Return Value

    A cancellable operation.

  • Strategy when running multiple queries. See Client.multipleQueries(...).

    See more

    Declaration

    Swift

    public enum MultipleQueriesStrategy : String
  • Query multiple indexes with one API call.

    Declaration

    Swift

    @discardableResult
    @objc(multipleQueries:strategy:requestOptions:completionHandler:)
    public func multipleQueries(_ queries: [IndexQuery], strategy: String?, requestOptions: RequestOptions? = nil, completionHandler: @escaping CompletionHandler) -> Operation

    Parameters

    queries

    List of queries.

    strategy

    The strategy to use.

    requestOptions

    Request-specific options.

    completionHandler

    Completion handler to be notified of the request’s outcome.

    Return Value

    A cancellable operation.

  • Query multiple indexes with a single API call.

    Declaration

    Swift

    @discardableResult
    public func multipleQueries(_ queries: [IndexQuery], strategy: MultipleQueriesStrategy? = nil, requestOptions: RequestOptions? = nil, completionHandler: @escaping CompletionHandler) -> Operation

    Parameters

    queries

    List of queries.

    strategy

    The strategy to use.

    requestOptions

    Request-specific options.

    completionHandler

    Completion handler to be notified of the request’s outcome.

    Return Value

    A cancellable operation.

  • Batch operations.

    Declaration

    Swift

    @discardableResult
    @objc(batchOperations:requestOptions:completionHandler:)
    public func batch(operations: [Any], requestOptions: RequestOptions? = nil, completionHandler: CompletionHandler? = nil) -> Operation

    Parameters

    operations

    List of operations.

    requestOptions

    Request-specific options.

    completionHandler

    Completion handler to be notified of the request’s outcome.

    Return Value

    A cancellable operation.