Example
using Algolia.Search.Clients;
using Algolia.Search.Http;
using Algolia.Search.Models.Search;
var client = new SearchClient("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY");
client.SearchSingleIndex<Hit>(
indexName: "INDEX_NAME",
searchParams: new SearchParams(new SearchParamsObject { Query = "SEARCH_QUERY" }),
options: new RequestOptions
{
// Add a custom HTTP header to this request
Headers = new Dictionary<string, string> { { "extra-header", "greetings " } },
// Add query parameters to this request
QueryParameters = new Dictionary<string, object> { { "queryParam", "value" } },
// Adjust timeout this request
ReadTimeout = TimeSpan.FromSeconds(10),
}
);
import 'package:algoliasearch/algoliasearch.dart';
Future<void> main() async {
final client = SearchClient(
appId: 'ALGOLIA_APPLICATION_ID',
apiKey: 'ALGOLIA_API_KEY',
);
await client.searchSingleIndex(
indexName: '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'},
// Adjust timeout this request
readTimeout: Duration(seconds: 10),
),
);
}
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("INDEX_NAME").
WithSearchParams(&searchParams),
// Add a custom HTTP header to this request
search.WithHeaderParam("extra-header", "greetings"),
// Add query parameters to this request
search.WithQueryParam("queryParam", "value"),
// Adjust timeout this request
search.WithReadTimeout(10*time.Second),
)
}
package org.example;
import com.algolia.api.SearchClient;
import com.algolia.config.RequestOptions;
import com.algolia.model.search.*;
import java.time.Duration;
public class Main {
public static void main(String[] args) {
var client = new SearchClient(
"ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY"
);
var searchParams = new SearchParamsObject().setQuery("SEARCH_QUERY");
var requestOptions = new RequestOptions()
// Add a custom HTTP header to this request
.addExtraHeader("extra-header", "greetings")
// Add query parameters to this request
.addExtraQueryParameters("queryParam", "value")
// Adjust timeout for this request
.setReadTimeout(Duration.ofSeconds(10));
client.searchSingleIndex(
"INDEX_NAME",
searchParams,
Hit.class,
requestOptions
);
}
}
import { algoliasearch } from "algoliasearch";
const client = algoliasearch("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY");
await client.searchSingleIndex(
{
indexName: "INDEX_NAME",
searchParams: {
query: "SEARCH_QUERY",
},
},
{
// Add a custom HTTP header to this request
headers: {
"extra-header": "greetings",
},
// Add query parameters to this request
queryParameters: {
queryParam: "value",
},
// Adjust timeouts for this request
timeouts: {
connect: 10000,
read: 10000,
},
},
);
package org.example
import com.algolia.client.api.SearchClient
import com.algolia.client.model.search.SearchParamsObject
import com.algolia.client.transport.RequestOptions
import kotlin.time.DurationUnit
import kotlin.time.toDuration
suspend fun main() {
val client = SearchClient(
appId = "ALGOLIA_APPLICATION_ID",
apiKey = "ALGOLIA_API_KEY"
)
client.searchSingleIndex(
indexName = "INDEX_NAME",
searchParams = SearchParamsObject(
query = "SEARCH_QUERY"
),
request_options = RequestOptions(
// Add a custom HTTP header to this request
headers = mapOf("extra-header" to "greetings"),
// Add query parameters to this request
urlParameters = mapOf("queryParam" to "value"),
// Adjust timeout for this request
readTimeout = 10.toDuration(DurationUnit.SECONDS)
)
)
}
<?php
require_once realpath(__DIR__.'/vendor/autoload.php');
use Algolia\AlgoliaSearch\Api\SearchClient;
$client = SearchClient::create(
appId: 'ALGOLIA_APPLICATION_ID',
apiKey: 'ALGOLIA_API_KEY',
);
$requestOptions = [
// Add custom HTTP header to this request
'headers' => ['extra-header' => 'greetings'],
// Add query parameter to this request
'queryParameters' => ['queryParam' => 'value'],
// Adjust timeout for this request
'readTimeout' => 10
];
$client->searchSingleIndex(
indexName: 'INDEX_NAME',
searchParams: ['query' => 'time'],
requestOptions: $requestOptions,
);
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="INDEX_NAME",
search_params={"query": "time"},
request_options={
# Add custom HTTP header to this request
"headers": {
"extra-header": "greetings",
},
# Add query parameter to this request
"query_parameters": {
"queryParam": "value",
},
# Adjust timeouts for this request
"timeouts": {
"read": 10_000,
"connect": 10_000,
},
},
)
require "algolia"
client = Algolia::SearchClient.create(
"ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY"
)
client.search_single_index(
"INDEX_NAME",
{query: "SEARCH_QUERY"},
# Add a custom HTTP header to this request
header_params: {:"extra-header" => "greetings"},
# Add query parameters to this request
query_params: {queryParam: "value"}
)
package com.algolia.example
import scala.concurrent.duration.DurationInt
import scala.concurrent.ExecutionContext.Implicits.global
import algoliasearch.api.SearchClient
import algoliasearch.config.RequestOptions
import algoliasearch.search.SearchParamsObject
@main
def main(): Unit = {
val client = SearchClient("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY")
client.searchSingleIndex(
indexName = "INDEX_NAME",
searchParams = Some(SearchParamsObject(query = Some("SEARCH_QUERY"))),
requestOptions = Some(RequestOptions(
// Add a custom HTTP header to this request
headers = Map("extra-header" -> "greetings"),
// Add query parameters to this request
queryParameters = Map("queryParam" -> "value"))),
// Adjust timeout for this request
readTimeout = Some(100.seconds)
)
}
import Core
@preconcurrency import Search
let client = try SearchClient(
appID: "ALGOLIA_APPLICATION_ID",
apiKey: "ALGOLIA_API_KEY"
)
let searchResults: SearchResponse<Hit> = try await client.searchSingleIndex(
indexName: "INDEX_NAME",
searchParams: SearchSearchParams.searchSearchParamsObject(
SearchSearchParamsObject(query: "SEARCH_QUERY")
),
requestOptions: RequestOptions(
// Add a custom HTTP header to this request
headers: ["extra-header": "greetings" ],
// Add query parameters to this request
queryParameters: ["queryParam": "value"],
// Adjust timeout for this request
readTimeout: 60
)
)
Reference
- C#
- Dart
- Go
- Java
- JavaScript
- Kotlin
- PHP
- Python
- Ruby
- Scala
- Swift
Additional headers to include in the request, as key–value pairs.
Additional query parameters to include in the request.
These apply only to API operations that support query parameters.
Otherwise, they’re ignored.
Maximum duration, in milliseconds, to wait for the server to respond to read requests
(retrieving data from Algolia).
Maximum duration, in milliseconds, to wait for the server to respond to write requests
(sending data to Algolia).
Maximum time to wait for the connection to be established, in milliseconds.
Additional headers to include in the request, as key–value pairs.
Additional query parameters to include in the request.
These apply only to API operations that support query parameters.
Otherwise, they’re ignored.
Maximum duration, in milliseconds, to wait for the server to respond to read requests
(retrieving data from Algolia).
Maximum duration, in milliseconds, to wait for the server to respond to write requests
(sending data to Algolia).
Maximum time to wait for the connection to be established, in milliseconds.
Additional headers to include in the request, as key–value pairs.
Use the
search.WithHeaderParam() function to add them.Additional query parameters to include in the request.
These apply only to API operations that support query parameters.
Otherwise, they’re ignored.
Use the
search.WithQueryParam() function to add them.Timeout durations for different types of network requests.
Hide child attributes
Hide child attributes
Maximum duration, in milliseconds, to wait for the server to respond to read requests
(retrieving data from Algolia).
Use the
search.WithReadTimeout() function to change this timeout.Maximum duration, in milliseconds, to wait for the server to respond to write requests
(sending data to Algolia).
Use the
search.WithWriteTimeout() function to change this timeout.Maximum time to wait for the connection to be established, in milliseconds.
Use the
search.WithConnectTimeout() function to change this timeout.Additional headers to include in the request, as key–value pairs.
Use the
RequestOptions.addExtraHeader() method to add them.Additional query parameters to include in the request.
These apply only to API operations that support query parameters.
Otherwise, they’re ignored.
Use the
RequestOptions.addExtraQueryParameters() method to add them.Maximum duration, in milliseconds, to wait for the server to respond to read requests
(retrieving data from Algolia).
Use the
RequestOptions.setReadTimeout() method to change this timeout.Maximum duration, in milliseconds, to wait for the server to respond to write requests
(sending data to Algolia).
Use the
RequestOptions.setWriteTimeout() method to change this timeout.Maximum time to wait for the connection to be established, in milliseconds.
Use the
RequestOptions.setConnectTimeout() method to change this timeout.Additional headers to include in the request, as key–value pairs.
Additional query parameters to include in the request.
These apply only to API operations that support query parameters.
Otherwise, they’re ignored.
Timeout durations for different types of network requests.
Hide child attributes
Hide child attributes
Maximum duration, in milliseconds, to wait for the server to respond to read requests
(retrieving data from Algolia).
Maximum duration, in milliseconds, to wait for the server to respond to write requests
(sending data to Algolia).
Maximum time to wait for the connection to be established, in milliseconds.
Additional headers to include in the request, as key–value pairs.
Additional query parameters to include in the request.
These apply only to API operations that support query parameters.
Otherwise, they’re ignored.
Maximum duration, in milliseconds, to wait for the server to respond to read requests
(retrieving data from Algolia).
Maximum duration, in milliseconds, to wait for the server to respond to write requests
(sending data to Algolia).
Maximum time to wait for the connection to be established, in milliseconds.
Additional headers to include in the request, as key–value pairs.
Additional query parameters to include in the request.
These apply only to API operations that support query parameters.
Otherwise, they’re ignored.
Maximum duration, in milliseconds, to wait for the server to respond to read requests
(retrieving data from Algolia).
Maximum duration, in milliseconds, to wait for the server to respond to write requests
(sending data to Algolia).
Maximum time to wait for the connection to be established, in milliseconds.
Additional headers to include in the request, as key–value pairs.
Additional query parameters to include in the request.
These apply only to API operations that support query parameters.
Otherwise, they’re ignored.
Timeout durations for different types of network requests.
Hide keys
Hide keys
Maximum duration, in milliseconds, to wait for the server to respond to read requests
(retrieving data from Algolia).
Maximum duration, in milliseconds, to wait for the server to respond to write requests
(sending data to Algolia).
Maximum time to wait for the connection to be established, in milliseconds.
Additional headers to include in the request, as key–value pairs.
Additional query parameters to include in the request.
These apply only to API operations that support query parameters.
Otherwise, they’re ignored.
Maximum duration, in milliseconds, to wait for the server to respond to requests.
Maximum time to wait for the connection to be established, in milliseconds.
Additional headers to include in the request, as key–value pairs.
Additional query parameters to include in the request.
These apply only to API operations that support query parameters.
Otherwise, they’re ignored.
Maximum duration, in milliseconds, to wait for the server to respond to read requests
(retrieving data from Algolia).
Maximum duration, in milliseconds, to wait for the server to respond to write requests
(sending data to Algolia).
Maximum time to wait for the connection to be established, in milliseconds.
Additional headers to include in the request, as key–value pairs.
Additional query parameters to include in the request.
These apply only to API operations that support query parameters.
Otherwise, they’re ignored.
Maximum duration, in milliseconds, to wait for the server to respond to read requests
(retrieving data from Algolia).
Maximum duration, in milliseconds, to wait for the server to respond to write requests
(sending data to Algolia).