fandom-api-types Docs

Type Reference

Detailed notes for every namespace exported by fandom-api-types.

All exports are available via namespaces:

import { Rest, Action, Fandom, Generated, Routes } from "fandom-api-types";

Use the sections below to understand when to reach for each interface.

Rest namespace

Rest mirrors /w/rest.php/v1 responses.

Pages & revisions

TypeHighlights
Rest.MWRestPageRepresents a complete REST page response with id, key, title, latest, revisions, and optional content.
Rest.MWRevisionSummarySlim objects used inside MWRestPage.revisions; carries id, timestamp, and optional user/comment.
Rest.MWRevisionFull revision records for /revision endpoints. Includes anon, comment, and optional full content.
Rest.MWRevisionsResponseEnvelope around an array of MWRevision plus a total counter.

Discovery & metadata

TypeHighlights
Rest.MWSearchResult / Rest.MWSearchResponseShape of /search payloads (snippet, revision, canonical url).
Rest.MWSiteInfoMinimal REST site metadata containing mainPage, baseUrl, sitename, generator, and version.

Collections

TypeHighlights
Rest.MWCategory, Rest.MWCategoryPage, Rest.MWCategoryResponseModel /category listings, with nested page entries and pagination totals.
Rest.MWMedia, Rest.MWMediaResponseRepresent /media payloads (images, video, audio) including optional dimensions and byte size.
Rest.MWUser, Rest.MWUsersResponseCapture user cards surfaceable via REST (registration, avatar, group memberships).

Action namespace

Action captures api.php responses.

  • Action.MWQueryPage / Action.MWQueryResult / Action.MWQueryResponse – strongly typed envelope for action=query. Includes contentmodel, lastrevid, and optional embedded Rest.MWRevision records.
  • Action.MWRevisionsResponse – maps query.pages[PAGEID].revisions so you can narrow revision metadata fetched via prop=revisions.
  • Action.MWParseResponse – describes action=parse payloads including HTML in text['*'], section lists, category metadata, and template/link tables.
  • Action.MWEditResponse – returned by action=edit, exposing revision IDs, result status, and bookkeeping such as oldrevid/newrevid.

Fandom namespace

For /api/v1 and internal controllers unique to Fandom.

TypeNotes
Fandom.FandomArticleDetails / Fandom.FandomArticlesResponseArticle metadata used by curated feeds (wikiId, abstract, author, lastUpdated).
Fandom.FandomDiscussionPost, Fandom.FandomDiscussionThread, Fandom.FandomDiscussionResponseDiscussion threads, including replyTo, threadId, and activity timestamps.
Fandom.FandomFeedItem, Fandom.FandomFeedsResponseActivity feed entries with discriminated type union (article, discussion, news, other).
Fandom.FandomUser, Fandom.FandomUsersResponseLightweight user profiles referencing groups, karma, optional avatar, and total counts.

Generated namespace

Generated exposes raw, auto-generated TypeScript mirrors of real wiki responses:

  • Generated.MWParseResponse, Generated.MWQuerySearchResponse, and Generated.MWQuerySiteInfoResponse provide every optional key discovered in the Action API.
  • Generated.FandomArticlesDetailsResponse matches Fandom's Articles/Details JSON map structure (IDs as keys with nested metadata).
  • Refresh them with pnpm generate-types, which runs scripts/generate-types.ts against live sample endpoints. The generator infers JSON Schema via the inferSchema helper before piping it through json-schema-to-typescript.

Use these when you need complete fidelity (including rarely used fields) or when exploring newly uncovered properties.

Routes namespace

Routes is a plain-object helper that converts wiki bases and parameters into URLs.

HelperSignatureNotes
Routes.rest.page(wikiBase: string, title: string) => stringEncodes titles and returns /w/rest.php/v1/page/<title>.
Routes.rest.search(wikiBase: string, query: string, limit?: number) => stringAdds q/limit as query params.
Routes.rest.siteInfo(wikiBase: string) => stringPoints to /metadata/siteinfo.
Routes.action.query(wikiBase: string, params: Record<string, string | number>) => stringAdds format=json automatically.
Routes.action.parse(wikiBase: string, title: string, options?: { prop?: string }) => stringPre-fills action=parse and page arguments, letting you append prop values.
Routes.action.edit(wikiBase: string, title: string) => stringBuilds action=edit URLs for CSRF-protected edits.
Routes.action.revisions(wikiBase: string, title: string, limit?: number) => stringSupplies prop=revisions and optional rvlimit.
Routes.fandom.articlesDetails(wikiBase: string, ids: number[]) => stringSerializes ID arrays for /api/v1/Articles/Details.
Routes.fandom.discussionPosts(wikiBase: string, threadId: string, limit?: number) => stringTargets DiscussionPost controller with optional pagination.
Routes.fandom.userDetails(wikiBase: string, userId: string) => stringFetches /api/v1/User/Details.
Routes.fandom.feed(wikiBase: string, type?: string, limit?: number) => stringBuilds /Activity/Feeds URL with optional filters.

Because these helpers only operate on strings, you can call them from the browser, a bot, or a build script without bundling extra dependencies.

How is this guide?

On this page