Introduction
AniLink is a typed TypeScript client for two anime-database APIs. One class, AniLink, composes two independent provider surfaces:
| Provider | Protocol | Namespace | What it offers |
|---|---|---|---|
| AniList | GraphQL | aniLink.anilist | Queries, page queries, mutations, pagination helpers, custom(), data helpers |
| MyAnimeList (MAL) | REST | aniLink.mal | anime.get and user.me REST reads with field selection |
The two surfaces share a transport layer (timeouts, retries, pacing, circuit breaker, hooks, error normalization) but never share credentials. A MAL access token is never sent to AniList. An AniList bearer token is never sent to MAL.
Why AniLink exists
Calling AniList or MAL directly means hand-rolling HTTP, GraphQL documents, OAuth flows, retry logic, and rate-limit handling. AniLink does that once, with types:
- Typed operations. Every operation has typed variables and a typed response, generated from the provider schemas.
- Normalized errors. Provider failures become
AniLinkErrorsubclasses with stablecodevalues, so you classify failures without parsing messages. - Resilience built in. Retries with jittered backoff, optional rate-limit pacing, and an optional circuit breaker work identically on both providers.
- Provider isolation. Credentials and transport settings are scoped per provider slot.
When to use custom()
anilist.custom() (AniList only) sends a raw GraphQL document you write yourself. Use it when you need a field combination the typed operations do not expose. MAL has no equivalent — the MAL surface is fixed REST operations.
How to choose a provider
- Need rich anime/manga metadata, lists, activity, or social features? AniList — it has the large GraphQL surface.
- Need data from a user's MyAnimeList account or MAL anime details? MAL — currently
anime.getanduser.meonly. - Need both? Compose them in one client and keep each provider's credentials in its own slot. See Provider configuration.
Where to go next
- Getting started — install and make your first calls.
- Operation reference — look up any operation's full request/response anatomy.
- API reference — exact TypeDoc signatures.