Skip to content
墨 AniLink

AniList client configuration ​

Complete options table ​

OptionTypeDefaultBehaviorWhen to change it
timeoutnumber30000Milliseconds before the client aborts a request. 0 disables. Timeout errors carry timeoutMsSlow endpoints or strict latency budgets
signalAbortSignalnoneCancels in-flight requestsUser-driven cancellation
retryboolean | Partial<RetryPolicy>built-in policyAutomatic retries. false opts out. Partial policy merges over defaultsNon-idempotent workflows, custom backoff
paceWithRateLimitbooleantrueWaits for window reset when remaining quota drops below rateLimitFloorHigh-volume schedulers
rateLimitFloornumber1Remaining-quota threshold that triggers pacing. It must be a finite, non-negative integer. A value of 0 disables floor-based pacing. A defined but invalid value throwsStart pacing earlier than the last request
ignorePaceDeadlinebooleanfalseBypass the shared pacing deadline for this callUrgent single requests during a rate-limited window
circuitBreaker{ threshold, cooldownMs }offFail fast with CIRCUIT_OPEN_ERROR after threshold consecutive failures until cooldownMs elapses. Each consecutive failed probe doubles the next cooldown, capped at 8×Protect against sustained outages
responseCacheResponseCacheoffOpt-in TTL cache for reads: GET requests and GraphQL query documentsRead-heavy traversals with repeated identical reads
onErrorOnErrorHandlernoneFires per failed attempt and when retries run outLogging, metrics
onRetryOnErrorHandlernoneFires when the client retries a failed attemptRetry telemetry
onRequestStartOnRequestStartHandlernoneFires immediately before each attemptRequest counting
onResponseOnResponseHandlernoneFires after each attempt with durationMs and cacheHit?Latency metrics, cache hit/miss tracking
onPaceOnPaceHandlernoneFires after a rate-limit pacing wait completes, before the client sends the request. An aborted wait emits the elapsed portion with aborted: truePacing telemetry
onHookErrorOnHookErrorHandlernoneFires when a lifecycle hook throws. Wire this to your logger in production. Without it, hook failures fall back to console.warn, which is unqueryable in serverless/structured-logging setupsRoute hook failures to a logger
onCircuitOpenOnCircuitOpenHandlernoneFires when the circuit breaker tripsBreaker trip alerts
onCircuitCloseOnCircuitCloseHandlernoneFires when the circuit breaker closes after a probeBreaker recovery tracking
refreshTokenstringnoneStored refresh token. With clientId and clientSecret, it enables automatic refresh on 401 and bootstraps a client without authToken on its first auth-required call.Automatic token refresh
clientIdstringnoneAniList application client ID. With refreshToken and clientSecret, it enables automatic refresh.Automatic token refresh
clientSecretstringnoneAniList application secret. AniList requires it for the refresh grant, so automatic refresh stays off until you set it.Automatic token refresh
onTokenRefreshAniListTokenRefreshCallbacknoneFires after each successful automatic refresh and receives the effective token response. Persist it synchronously.Persisting refreshed tokens
exposeRawAxiosErrorbooleanfalseAttaches the raw Axios error as rawAxiosError/cause and redacts sensitive headersLocal debugging only

Note

exposeRawAxiosError: true redacts the Authorization, Cookie, and Proxy-Authorization headers to [REDACTED] in the attached raw error, so opting in for diagnostics does not leak bearer tokens into your logs.

Usage ​

typescript
import { AniLink } from "anilink-api-wrapper";

const aniLink = new AniLink("anilist-token", {
    timeout: 10_000,
    retry: { maxRetries: 3, baseDelayMs: 250 },
    paceWithRateLimit: true,
    onResponse: ({ url, durationMs }) => console.log(url, durationMs),
});

Each mechanism gets its own page: Retries & resilience, Observability, Cancellation & timeouts, Response cache. With refreshToken, clientId, and clientSecret all set, a 401 triggers an automatic refresh and a single replay. See AniList authentication.

Next steps ​

AniLink, typed AniList & MyAnimeList client for TypeScript.