Provider configuration
AniLink accepts credentials two ways. Both produce a client with aniLink.anilist and aniLink.mal surfaces.
Positional form (legacy AniList)
import { AniLink } from "anilink-api-wrapper";
// Token for AniList; transport settings apply to AniList only.
const aniLink = new AniLink("anilist-token", { timeout: 10_000 });The first argument is the AniList token. The second is transport settings forwarded only to the AniList factory. The MAL surface is still available but unauthenticated.
Per-provider credentials form
import { AniLink } from "anilink-api-wrapper";
const aniLink = new AniLink({
anilist: { authToken: "anilist-token", timeout: 5_000 },
mal: { accessToken: "mal-token", timeout: 10_000 },
});When the first argument is a credentials object, the second constructor argument is unused — transport settings belong inside each provider's slot.
Credential slots
| Slot | Fields | Provider |
|---|---|---|
anilist | authToken plus shared transport options | AniList |
mal | accessToken, refreshToken, clientId, clientSecret plus shared transport options | MAL |
Provider scope
Credentials given under one key are never applied to another provider's requests. A MAL access token is never sent to AniList. An AniList bearer token is never sent to MAL.
buildProviderClients()
The constructor delegates to buildProviderClients, which is exported for advanced composition:
import { buildProviderClients } from "anilink-api-wrapper";
const clients = buildProviderClients({
anilist: { authToken: "anilist-token" },
mal: { accessToken: "mal-token" },
});
const anime = await clients.mal.anime.get(21);buildProviderClients(credentials?, legacyOptions?) invokes each registered provider factory with only that provider's credential slot. legacyOptions exists for the positional form and is forwarded only to the AniList factory.
Transport settings scoping
timeout, retry, signal, pacing, circuit breaker, and hooks are transport settings. They are scoped to the provider slot where they are declared:
const aniLink = new AniLink({
anilist: { authToken: "t", timeout: 5_000, retry: false },
mal: { accessToken: "m", timeout: 15_000 },
});Here AniList requests time out after 5 s with no retries. MAL requests time out after 15 s with the default retry policy.
Next steps
- AniList client configuration — the full options table.
- MAL client configuration — MAL credentials in detail.