Skip to content
AniLink

Provider configuration

AniLink accepts credentials two ways. Both produce a client with aniLink.anilist and aniLink.mal surfaces.

Positional form (legacy AniList)

typescript
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

typescript
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

SlotFieldsProvider
anilistauthToken plus shared transport optionsAniList
malaccessToken, refreshToken, clientId, clientSecret plus shared transport optionsMAL

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:

typescript
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:

typescript
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

AniLink — typed AniList & MyAnimeList client for TypeScript.