Nov 19, 2024
Request options
The API client methods accept additional parameters for adding custom headers or query parameters, or for changing the default timeouts for individual requests.
To customize all requests, you can customize the client.
For example:
Copy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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 header
"headers": {
"extra-header": "greetings",
},
# Add query parameter
"query_parameters": {
"queryParam": "value",
},
# Change default timeouts
"timeouts": {
"read": 10_000,
"connect": 10_000,
},
}
)
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. |
timeouts
|
type: dict[str, int]
Timeouts for read and write operations, in milliseconds. You can change the following timeouts:
|
Did you find this page helpful?