The API client methods accept additional parameters for adding headers or query parameters, or for changing the default timeouts for individual requests.

To customize all requests, you can customize the client.

For example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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 header to this request
        Headers = new Dictionary<string, string> { { "extra-header", "greetings" } },
        // Add query parameter to this request
        QueryParameters = new Dictionary<string, object> { { "queryParam", "value" } }
        // Adjust timeout for this request
        Timeout = TimeSpan.FromSeconds(10),
    }
);

Reference

Headers
type: IDictionary<string,string>

Additional headers as key-value pairs to send with this request.

QueryParameters
type: IDictionary<string,object>

Additional query parameters to send with this request. They only take effect with API operations that support query parameters. Otherwise, they’re ignored.

Timeout
type: TimeSpan

Maximum number of seconds to wait for a response from the server.

Did you find this page helpful?
C# API clients v7