algolia_client_core library
Core functionality for interacting with the Algolia API.
This library provides the essential logic for configuring and executing HTTP requests to the Algolia API. It includes support for retry strategies and comprehensive exception handling.
Classes
- AgentSegment
- Represents a segment of algolia agent header.
- AlgoliaNoResponse
- Represents a successful API response with no content (HTTP 204).
- ApiClient
- An abstract class representing an API client with specific properties and options.
- ApiRequest
- Represents an API request to be sent to Algolia.
- ChunkedHelperOptions
- Optional configuration for chunked helpers that batch records and poll for task completion.
- ClientOptions
- Host
- Represents an Algolia host.
- HttpRequest
- Represents an Http request.
- HttpResponse
- Represents an Http response
- Requester
- A contract Requester to define an interface for handling HTTP requests and responses.
- RequestOptions
- Represents options for configuring a request to an endpoint.
- RetryStrategy
- Component to run http requests with retry logic.
- TransformationOptions
-
Options for the ingestion transporter used by
*WithTransformationhelpers.
Enums
- CallType
- Indicate whether the HTTP call performed is of type read (GET) or write (POST, PUT ..). Used to determine which timeout duration to use.
- RequestMethod
- Provides enumerated HTTP verbs
Constants
- defaultMaxRetries → const int
- Default maximum number of retries for chunked helpers and wait operations.
- defaultReplaceAllObjectsMaxRetries → const int
-
Default maximum number of retries used by
replaceAllObjects. - platformRequestIdAsQueryParameter → const bool
-
Whether the platform mints the Request-ID as the
x-algolia-request-idquery parameter instead of the header. Browsers must: the header is not covered by the API's CORS allow-list. Also the fallback for unknown platforms (wasm web included), where only the query parameter is safe. - requestIdHeader → const String
- The name of the header carrying the Request-ID minted when a client supports it.
- requestIdQueryParameter → const String
- The name of the query parameter carrying a Request-ID; the server consults it only when the header is absent.
Functions
-
generateRequestId(
) → String - Returns a fresh 11-character base62 identifier suitable for the Request-ID header.
-
hasRequestIdHeader(
Map< String, dynamic> ? headers) → bool - Whether the given headers already carry a Request-ID entry, whatever its casing.
-
hasRequestIdQueryParameter(
Map< String, dynamic> ? queryParameters) → bool -
Whether the given query parameters already carry an
x-algolia-request-identry, whatever its casing; a minted header would shadow it. -
mintedRequestIdOptions(
{bool asQueryParameter = platformRequestIdAsQueryParameter}) → RequestOptions - Request options carrying a freshly minted Request-ID on the given channel: the header on native platforms, the query parameter on the web.
Exceptions / Errors
- AlgoliaApiException
- Exception thrown when the Algolia API returns an error.
- AlgoliaException
- Abstract base class for all Algolia exceptions.
- AlgoliaIOException
- Exception thrown when there is an input/output error during a request to the Algolia API.
- AlgoliaTimeoutException
- Exception thrown when a request to the Algolia API times out.
- AlgoliaWaitException
- Exception thrown when an error occurs during the wait strategy. For example: maximum number of retry exceeded.
- UnreachableHostsException
- Exception thrown when all hosts for the Algolia API are unreachable.