Skip to main content
This page documents an earlier version of the API client. For the latest version, see Install the (latest) API clients and Customize the clients.
Before you can index your data or search your Algolia indices, you must initialize a search client with your application ID and API key. You can find both in your Algolia account.

Initialize the search client and index

The search client handles authentication and lets you manage your indices, for example, add data to them, or search them.
Replace INDEX_NAME with the name of the index you want to use. You can find your existing indices in the Algolia dashboard or using the List indices operation. If the index doesn’t exist, a new, empty index is created locally. It’s created on Algolia’s servers only if you add records to the index.
Don’t use sensitive or personally identifiable information as your index name, including usernames, IDs, or email addresses. Index names are publicly shared.
Methods that are scoped to your Algolia applications (methods of a client object):
  • Managing indices
  • Working with dictionaries
  • Working with API keys
Methods that are scoped to an index are:
  • Search, indexing, settings, synonyms, and rules methods
The Recommend, Personalization, Insights, and A/B testing APIs have their own clients:

Usage notes

Not all API clients have usage notes.

Serialization

The API client uses Json.NET as the serializer for your POCOs. You can index your POCOs directly if they follow the .NET naming convention.Example:
C#
You can override the naming strategy with the following attribute: [JsonProperty(PropertyName = "propertyName")]
You can also add and retrieve records via JObject:
C#
Algolia objects such as Rule, Synonym, or Settings are now typed.An example with the Settings class:
C#
If you want to access all properties of the SearchResponse object, you must add these properties to your class. For example, to get the _rankingInfo attribute with your search:
C#

Asynchronous and synchronous methods

The API client provides both synchronous and asynchronous methods for every API endpoint. Asynchronous methods are suffixed with the Async keyword.
C#

Custom HTTP clients

The API client uses the built-in HttpClient of the .NET Framework.The HttpClient is wrapped in an interface: IHttpRequester. If you want to use a custom HttpClient, you can pass it to the constructors of SearchClient, AnalyticsClient, or InsightsClient.For example:
C#

Thread safety

The API client is thread-safe. You can use SearchClient, AnalyticsClient, and InsightsClient in a multi-threaded environment.
Last modified on April 27, 2026