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

For example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from algoliasearch.search.client import SearchClientSync

client = SearchClientSync(
        app_id="ALGOLIA_APPLICATION_ID",
        api_key="ALGOLIA_API_KEY"
)

results = client.search_single_index(
    index_name="ALGOLIA_INDEX_NAME",
    search_params={"query": "time"},
    request_options={
        # Add extra headers to all requests
        "headers": {
            "extra-header": "greetings",
        },
        # Add query parameters
        "query_parameters": {
            "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: dict[str,str]

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

query_parameters
type: dict[str,Any]

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?
Python API clients v4