Getting started
Type declarations for MediaWiki Action API responses, written for formatversion=2 with a field union spanning 1.39–1.47. The package ships declarations only (dist/*.d.ts) — no runtime code, so importing it adds nothing to your bundle.
Install
Cast the response of an action
Each action maps to one ApiXxxResponse. For example, fetching page revisions:
Pass formatversion: "2" on the request — the library's types cover fv2 only. Every response type is listed in the API reference.
Handling errors
Casting to ApiXxxResponse only asserts no root error — which is not the same as "the operation succeeded". How to handle a failing response depends mainly on the client:
- Clients that handle root errors for you, such as
mw.Api, throw as soon as the response carries a rooterror/errors— just wrap the request in atry/catch, and no extra handling of the response type is needed. - Clients that hand the error response back as-is (native
fetch, for example) need the type wrapped withApiResponseWith<T>and a narrowing onerror/errors.
See Envelope and error handling for the details.
Extensions
Core types cover MediaWiki core modules only. Fields contributed by extensions are split into opt-in packs: a single type-only import in any file covered by your tsconfig activates the pack program-wide:
A field that shows up in the real response but not in the core types usually means an extension provides it — that is your cue to activate its pack.
An extension action (action=thank, action=shortenurl, …) instead exports a standalone response type — import it by name where you call it, like any core action response:
Working with AI
Besides the copy-Markdown feature at the top of each page, this docs site also publishes llms.txt files alongside its content:
- llms.txt: an index file with descriptions and links for every page on the site
- llms-full.txt: the entire site content merged into one file
Copy whichever link fits your use case and hand it to your agent.