The API client methods accept additional parameters for adding headers or query parameters.

If you want to customize the client itself, see Customize clients.

For example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
using Algolia.Search.Clients;
using Algolia.Search.Http;
using Algolia.Search.Models.Search;

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

// Request options with the fluent builder
client.SearchSingleIndex<Hit>("ALGOLIA_INDEX_NAME",
  new SearchParams(new SearchParamsObject { Query = "SEARCH_QUERY" }),
  new RequestOptionBuilder()
    // Add an extra header to all requests
    .AddExtraHeader("extra-header", "greetings")
    // Add query parameters
    .AddExtraQueryParameters("queryParam", "value")
    .Build());

// Request options with the RequestOptions object
client.SearchSingleIndex<Hit>("ALGOLIA_INDEX_NAME",
  new SearchParams(new SearchParamsObject { Query = "SEARCH_QUERY" }),
  new RequestOptions
  {
    Headers = new Dictionary<string, string> { { "extra-header", "hello" } },
    QueryParameters = new Dictionary<string, object> { { "queryParam", "value" } }
});

Query parameters only apply to methods that accept them, such as GET requests. See the API reference for more information.

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.

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