Skip to content
墨 AniLink

Per-request options ​

Every operation accepts a trailing options argument. It overrides the instance defaults for that call, so you do not need a new client.

AniList operations ​

AniList operations accept options?: RequestOptions as the last parameter. Operations whose signatures also list fields accept a field selector in the same object. AniLink composes the document from the selected fields at any nesting depth and narrows the return type to DeepPick<...>. Some operations return fixed shapes instead, such as query.markdown and query.viewer. Check the operation signature or see the full list in Field selection:

typescript
const media = await aniLink.anilist.query.media(
    { id: 1, type: "ANIME" },
    { timeout: 5_000, signal: controller.signal }
);

const slim = await aniLink.anilist.query.media(
    { id: 1, type: "ANIME" },
    { fields: ["id", "title.romaji", "averageScore"] }
);
// slim: DeepPick<MediaResponse, "id" | "title.romaji" | "averageScore" | "idMal">
// The always-selected idMal joins the pick; the document always sends it.

See Field selection for the nested path rules, the always-selected id, and which operations accept fields.

MAL operations ​

MAL operations take MalRequestOptions, which extends RequestOptions with the MAL fields selector:

typescript
const anime = await aniLink.mal.anime.get(
    { id: 21 },
    {
        fields: ["id", "title", "main_picture"],
        timeout: 8_000,
    }
);
OptionTypeDefaultDescription
fieldsstring | readonly string[]provider default fieldsComma-separated MAL field selector, or the same selector as an array. Shapes the response.
timeoutnumberinstance value (30000)Milliseconds before the request times out. 0 disables.
signalAbortSignalinstance valueSignal used to cancel the in-flight request.
retryboolean | Partial<RetryPolicy>instance policyRetry policy for this call. false opts out.
exposeRawAxiosErrorbooleanfalseAttach the raw Axios error for debugging.

Available options ​

OptionTypeDefaultDescription
timeoutnumberinstance value (30000)Milliseconds before the request times out. 0 disables.
signalAbortSignalinstance valueSignal used to cancel the in-flight request.
retryboolean | Partial<RetryPolicy>instance policyRetry policy for this call. false opts out.
exposeRawAxiosErrorbooleanfalseAttach the raw Axios error for debugging. The library redacts sensitive headers.
paceWithRateLimitbooleaninstance valueWaits for the rate-limit window to reset when remaining quota drops below rateLimitFloor.
rateLimitFloornumberinstance valueRemaining-quota threshold that triggers pacing.
circuitBreaker{ threshold, cooldownMs }instance valueCircuit breaker configuration.
retryBudget{ maxRetriesPerWindow, windowMs }instance valuePer-window cap on total retries across requests. When the budget runs out, failures surface without retries until the window elapses.
ignorePaceDeadlinebooleanfalseBypass the shared rate-limit pacing deadline for this call.
allowPartialDatabooleanfalseReturn data from a GraphQL envelope that contains both data and errors instead of throwing. AniLink reports the error entries through onError. The envelope must contain at least one resolved, non-null root field. An empty data: {} or a single null root field still throws. AniLink never retries or caches the result. See Error handling.
responseCacheResponseCacheinstance valueOpt-in response cache for reads (GET requests and GraphQL query documents).
onErrorOnErrorHandlerinstance valueFires per failed attempt and when retries are exhausted.
onRetryOnErrorHandlerinstance valueFires when the client decides to retry a failed attempt.
onRequestStartOnRequestStartHandlerinstance valueFires immediately before each attempt.
onResponseOnResponseHandlerinstance valueFires after each attempt with durationMs and cacheHit?.
onPaceOnPaceHandlerinstance valueFires after a rate-limit pacing wait completes and before the client dispatches the request. An aborted wait emits the elapsed portion with aborted: true. See Observability.
onHookErrorOnHookErrorHandlerinstance valueFires when a lifecycle hook throws.
diagnostics"warn" | "hook" | "silent""warn"Controls the library's unsolicited diagnostics (hook-failure fallback and the one-time stateOwner warning): warn emits a structured record via onHookError or console.warn, hook uses the observer only, silent suppresses both. Also settable client-wide on the credentials object. See Observability.
onCircuitOpenOnCircuitOpenHandlerinstance valueFires when the circuit breaker trips.
onCircuitCloseOnCircuitCloseHandlerinstance valueFires when the circuit breaker closes after a probe.

Merge behavior ​

Per-request options override instance defaults shallowly. An override replaces the full value for that key, including nested objects. For example, retry: { maxRetries: 1 } replaces the entire retry policy for that call. Unspecified retry fields use built-in defaults, not the instance-level policy.

Provider scoping ​

Options never cross providers. A per-request timeout on an AniList call leaves MAL calls untouched. Both providers have a fields option, but they differ. AniList fields narrows the return type (DeepPick<...>, including nested paths like title.romaji), while MAL fields selects the response shape without type narrowing.

Next steps ​

AniLink, typed AniList & MyAnimeList client for TypeScript.