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
import 'package:algoliasearch/algoliasearch.dart';

Future<void> main() async {
  final client = SearchClient(
    appId: 'ALGOLIA_APPLICATION_ID',
    apiKey: 'ALGOLIA_API_KEY',
  );

  await client.searchSingleIndex(
    indexName: 'ALGOLIA_INDEX_NAME',
    searchParams: SearchParamsObject(query: 'SEARCH_QUERY'),
    requestOptions: RequestOptions(
      // Add a custom HTTP header to this request
      headers: {'extra-header': 'greetings'},
      // Add query parameters to this request
      urlParameters: {'queryParam': 'value'}
    )
  );
}

Query parameters only apply to methods that accept them, such as GET requests.

Reference

headers
type: Map<String,dynamic>

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

urlParameters
type: Map<String, dynamic>

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

Did you find this page helpful?