Skip to main content
Each API method accepts request options for adding custom headers, appending query parameters, or adjusting request timeouts. To customize all requests, see Customize the clients.

Example

using Algolia.Search.Clients;
using Algolia.Search.Http;
using Algolia.Search.Models.Search;

var client = new SearchClient("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY");

client.SearchSingleIndex<Hit>(
    indexName: "ALGOLIA_INDEX_NAME",
    searchParams: new SearchParams(new SearchParamsObject { Query = "SEARCH_QUERY" }),
    options: new RequestOptions
    {
        // Add a custom HTTP header to this request
        Headers = new Dictionary<string, string> { { "extra-header", "greetings " } },
        // Add query parameters to this request
        QueryParameters = new Dictionary<string, object> { { "queryParam", "value" } },
        // Adjust timeout this request
        ReadTimeout = TimeSpan.FromSeconds(10),
    }
);

Reference

  • C#
  • Dart
  • Go
  • Java
  • JavaScript
  • Kotlin
  • PHP
  • Python
  • Ruby
  • Scala
  • Swift
Headers
IDictionary<string,string>
Additional headers to include in the request, as key–value pairs.
QueryParameters
IDictionary<string,object>
Additional query parameters to include in the request. These apply only to API operations that support query parameters. Otherwise, they’re ignored.
ReadTimeout
Timespan
Maximum duration, in milliseconds, to wait for the server to respond to read requests (retrieving data from Algolia).
WriteTimeout
Timespan
Maximum duration, in milliseconds, to wait for the server to respond to write requests (sending data to Algolia).
ConnectTimeout
Timespan
Maximum time to wait for the connection to be established, in milliseconds.
I