Sep 20, 2024
Request options
The API client methods accept additional parameters for adding custom headers or query parameters.
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
27
28
package main
import (
"github.com/algolia/algoliasearch-client-go/v4/algolia/search"
)
func main() {
client, _ := search.NewClient(
"ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY"
)
searchParams := search.SearchParams{
SearchParamsObject: search.
NewEmptySearchParamsObject().
SetQuery("SEARCH_QUERY"),
}
client.SearchSingleIndex(
client.
NewApiSearchSingleIndexRequest("ALGOLIA_INDEX_NAME").
WithSearchParams(&searchParams),
// Add a custom HTTP header to this request
search.HeaderParamOption("extra-header", "greetings"),
// Add query parameters to this request
search.QueryParamOption("queryParam", "value"),
)
}
Query parameters only apply to methods that accept them,
such as GET
requests.
See the API reference for more information.
Did you find this page helpful?