# Wikipedia & Wikidata API — encyclopedia content, knowledge-graph facts and pageview traffic across 360+ languages: summaries, full articles, rendered HTML/wikitext, full-text search, entity facts, category members, cross-language links, edit history, random pages, geosearch, on-this-day and featured-content feed

> page summary: extract, description, thumbnail, coordinates, wikibase QID, urls (lang= any of 360+ editions)
> ReefAPI engine `wikipedia` · 16 endpoints · clean JSON, no scraping or browsers to manage.

## How to call
- **Endpoint:** `POST https://api.reefapi.com/wikipedia/v1/<action>` with a JSON body.
- **Auth:** header `x-api-key: <YOUR_REEFAPI_KEY>` — create one free (1,000 credits, no card): https://reefapi.com/signup
- **Response (every call):** `{ ok: boolean, data: ..., meta: { record_count, credits, ... }, error: { code, message } }` — branch on `ok`. Failed or blocked calls are free.
- **One key + one shared credit pool** across every ReefAPI API. Per-call credits are listed on each endpoint below.
- **Use it from an AI agent (MCP):** connect `https://api.reefapi.com/mcp` (remote streamable-http, `Authorization: Bearer <key>`) and your assistant can call these actions directly.

## Endpoints

### POST /wikipedia/v1/summary — 1 credit
page summary: extract, description, thumbnail, coordinates, wikibase QID, urls (lang= any of 360+ editions)

**Parameters:**
- `title` (string, required) — Exact article title (case-sensitive first letter aside).
- `lang` (string, optional, default "en") — Wikipedia language edition code (en, de, fr, ja, … 360+ editions). Default en.

**Returns:** summary{} — title, extract, description, thumbnail, coordinates, wikibase_item (QID), content_urls; + attribution

**Example request body:**
```json
{
  "title": "Albert Einstein"
}
```

### POST /wikipedia/v1/page — 1 credit
full article: plain-text body + internal links + image list + categories + external links (content=false → structure only)

**Parameters:**
- `title` (string, required) — Exact article title (case-sensitive first letter aside).
- `lang` (string, optional, default "en") — Wikipedia language edition code (en, de, fr, ja, … 360+ editions). Default en.
- `content` (boolean, optional, default true) — false (or 0/no) → return article STRUCTURE only (links/images/categories), skip the plain-text body.
- `links_limit` (integer, optional, default 100) — Max internal links to return (1-500); clamped.
- `images_limit` (integer, optional, default 50) — Max images to return (1-200); clamped.

**Returns:** page{} — title, content (plain text), links[], images[], categories[], external_links[]; + attribution

**Example request body:**
```json
{
  "title": "Albert Einstein"
}
```

### POST /wikipedia/v1/search — 1 credit
full-text search → ranked pages (snippet/pageid/wordcount) + totalhits; enrich= adds extract/thumbnail/QID

**Parameters:**
- `query` (string, required) — Full-text search query.
- `lang` (string, optional, default "en") — Wikipedia language edition code (en, de, fr, ja, … 360+ editions). Default en.
- `limit` (integer, optional, default 10) — Max results (1-50, default 10); clamped.
- `offset` (integer, optional, default 0) — Result offset for pagination (0-10000); page with meta/next_offset.
- `enrich` (boolean, optional, default false) — If true, hydrate each result with extract + thumbnail + Wikidata QID (extra requests).

**Returns:** results[] (title, pageid, snippet, wordcount [+extract/thumbnail/QID if enrich]), total, suggestion, next_offset; + attribution

**Example request body:**
```json
{
  "query": "quantum computing"
}
```

### POST /wikipedia/v1/entity_facts — 2 credits
Wikidata facts for a QID or title: label/description/aliases + resolved human-readable facts{prop:value} + key_facts + identifiers + image/coords

**Parameters:**
- `id` (string, optional) — Wikidata QID (e.g. Q937). Supply this OR `title`/`query` to resolve one.
- `title` (string, optional) — Article/entity title to resolve to a Wikidata QID. Supply this OR `id`.
- `lang` (string, optional, default "en") — Wikipedia language edition code (en, de, fr, ja, … 360+ editions). Default en.
- `value_cap` (integer, optional, default 50) — Max values kept per multi-valued Wikidata property (1-200); clamped.

**Returns:** entity{} — label, description, aliases, facts{prop:value}, key_facts, identifiers, image, coords, qid, wikipedia_url; + attribution

**Example request body:**
```json
{
  "id": "Q937"
}
```

### POST /wikipedia/v1/pageviews — 1 credit
daily/monthly traffic for an article over a date range → series + total + average

**Parameters:**
- `title` (string, required) — Article title to pull traffic for.
- `lang` (string, optional, default "en") — Wikipedia language edition code (en, de, fr, ja, … 360+ editions). Default en.
- `start` (string, optional) — Range start date, YYYYMMDD or YYYY-MM-DD. Supply both start AND end, or use `days` instead.
- `end` (string, optional) — Range end date, YYYYMMDD or YYYY-MM-DD. Supply both start AND end, or use `days` instead.
- `days` (integer, optional, default 30) — Look-back window ending today, used when start/end are omitted (1-1000).
- `granularity` (enum, optional, default "daily") — Bucket size. Anything not starting with 'month' is treated as daily. [one of: daily, monthly]
- `access` (enum, optional, default "all-access") — Wikimedia Pageviews access channel (passed through to the REST API). [one of: all-access, desktop, mobile-app, mobile-web]
- `agent` (enum, optional, default "all-agents") — Wikimedia Pageviews agent class (passed through to the REST API). [one of: all-agents, user, spider, automated]

**Returns:** article, daily[] (date, views), total, average, granularity/start/end; + attribution

**Example request body:**
```json
{
  "title": "Albert Einstein",
  "start": "20240101",
  "end": "20240131"
}
```

### POST /wikipedia/v1/related — 1 credit
pages related to a title; enrich= adds extract/thumbnail

**Parameters:**
- `title` (string, required) — Exact article title (case-sensitive first letter aside).
- `lang` (string, optional, default "en") — Wikipedia language edition code (en, de, fr, ja, … 360+ editions). Default en.
- `limit` (integer, optional, default 10) — Max results (1-50, default 10); clamped.
- `enrich` (boolean, optional, default false) — If true, hydrate each result with extract + thumbnail + Wikidata QID (extra requests).

**Returns:** source_title, related[] (title, pageid [+extract/thumbnail if enrich]), count; + attribution

**Example request body:**
```json
{
  "title": "Albert Einstein"
}
```

### POST /wikipedia/v1/autocomplete — 0 credits
typeahead title suggestions

**Parameters:**
- `q` (string, required) — Typeahead prefix to autocomplete.
- `lang` (string, optional, default "en") — Wikipedia language edition code (en, de, fr, ja, … 360+ editions). Default en.
- `limit` (integer, optional, default 10) — Max results (1-50, default 10); clamped.

**Returns:** query, suggestions[] (title, description, url), count; + attribution

**Example request body:**
```json
{
  "q": "Einst"
}
```

### POST /wikipedia/v1/geosearch — 1 credit
Wikipedia pages near a coordinate or around a title

**Parameters:**
- `lat` (number, optional) — Latitude. Provide lat+lon, OR `coord`, OR `title` for geosearch.
- `lon` (number, optional) — Longitude (pairs with lat).
- `coord` (string, optional) — 'lat,lon' string — alternative to separate lat/lon params.
- `title` (string, optional) — Find pages near THIS article's coordinates (alternative to lat/lon/coord).
- `radius` (integer, optional, default 1000) — Search radius in metres (10-10000); clamped.
- `limit` (integer, optional, default 10) — Max results (1-50, default 10); clamped.
- `lang` (string, optional, default "en") — Wikipedia language edition code (en, de, fr, ja, … 360+ editions). Default en.

**Returns:** results[] (title, pageid, lat, lon, dist_m), count; + attribution

**Example request body:**
```json
{
  "lat": 48.8584,
  "lon": 2.2945,
  "radius": 1000
}
```

### POST /wikipedia/v1/on_this_day — 1 credit
historical events/births/deaths/holidays for a month-day (kind=all|selected|events|births|deaths|holidays)

**Parameters:**
- `month` (integer, optional) — Month 1-12 (pair with `day`), OR supply `date` instead. Defaults to today.
- `day` (integer, optional) — Day-of-month 1-31 (pairs with `month`).
- `date` (string, optional) — Date whose month-day is used (MM-DD or YYYY-MM-DD). Alternative to month/day.
- `kind` (enum, optional, default "all") — Which on-this-day category. An unknown value falls back to 'all'. [one of: all, selected, events, births, deaths, holidays]
- `limit` (integer, optional, default 30) — Max results (1-100, default 30); clamped.
- `lang` (string, optional, default "en") — Wikipedia language edition code (en, de, fr, ja, … 360+ editions). Default en.

**Returns:** date, kind, and the requested blocks (events/births/deaths/holidays/selected)[]; + attribution

**Example request body:**
```json
{
  "month": 3,
  "day": 14,
  "kind": "selected"
}
```

### POST /wikipedia/v1/top_articles — 1 credit
most-viewed articles for a given date (trending)

**Parameters:**
- `date` (string, optional) — Day to rank, YYYY-MM-DD or YYYYMMDD. Defaults to yesterday (today lags).
- `limit` (integer, optional, default 50) — Max results (1-1000, default 50); clamped.
- `access` (enum, optional, default "all-access") — Wikimedia Pageviews access channel (passed through to the REST API). [one of: all-access, desktop, mobile-app, mobile-web]
- `include_special` (boolean, optional, default false) — Keep special pages (Main_Page, Special:Search) in the ranking; default drops them.
- `lang` (string, optional, default "en") — Wikipedia language edition code (en, de, fr, ja, … 360+ editions). Default en.

**Returns:** articles[] (article, rank, views), date; + attribution

**Example request body:**
```json
{
  "date": "2024-01-15"
}
```

### POST /wikipedia/v1/category_members — 1 credit
list the pages, sub-categories or files that belong to a Wikipedia category (cmtype=page|subcat|file); paginate with meta.next/cmcontinue

**Parameters:**
- `category` (string, required) — Category name, with or without the 'Category:' prefix (e.g. 'Physicists' or 'Category:1879 births').
- `lang` (string, optional, default "en") — Wikipedia language edition code (en, de, fr, ja, … 360+ editions). Default en.
- `limit` (integer, optional, default 20) — Max results (1-500, default 20); clamped.
- `cmtype` (enum, optional, default "page") — Which kind of category member to list. Unknown values fall back to 'page'. [one of: page, subcat, file]
- `cmcontinue` (string, optional) — Pagination token from a previous response's meta.next — fetch the next batch.

**Returns:** category, members[] (title, pageid, ns, type, timestamp), count, next; + attribution

**Example request body:**
```json
{
  "category": "Physicists"
}
```

### POST /wikipedia/v1/langlinks — 1 credit
full cross-language map for a title: every edition's {lang, title, url, langname, autonym} plus a langmap{lang:title} lookup (the page action only returns the count)

**Parameters:**
- `title` (string, required) — Exact article title to resolve into its full cross-language map.
- `lang` (string, optional, default "en") — Wikipedia language edition code (en, de, fr, ja, … 360+ editions). Default en.
- `limit` (integer, optional, default 500) — Max results (1-500, default 500); clamped.

**Returns:** title, pageid, langlinks[] (lang, title, url, langname, autonym), langmap{lang:title}, count; + attribution

**Example request body:**
```json
{
  "title": "Albert Einstein"
}
```

### POST /wikipedia/v1/random — 1 credit
one or more random articles; enrich= adds extract/thumbnail/QID

**Parameters:**
- `lang` (string, optional, default "en") — Wikipedia language edition code (en, de, fr, ja, … 360+ editions). Default en.
- `limit` (integer, optional, default 1) — Max results (1-50, default 1); clamped.
- `enrich` (boolean, optional, default false) — If true, hydrate each result with extract + thumbnail + Wikidata QID (extra requests).

**Returns:** results[] (title, pageid, ns [+extract/thumbnail/QID if enrich]), count; + attribution

### POST /wikipedia/v1/revisions — 1 credit
edit history of an article: revid, parentid, timestamp, user, comment, size, tags; from/to window the range

**Parameters:**
- `title` (string, required) — Exact article title (case-sensitive first letter aside).
- `lang` (string, optional, default "en") — Wikipedia language edition code (en, de, fr, ja, … 360+ editions). Default en.
- `limit` (integer, optional, default 10) — Max results (1-500, default 10); clamped.
- `from` (string, optional) — Window start (ISO timestamp). Returns revisions at/after this point (newest-first). Optional.
- `to` (string, optional) — Window end (ISO timestamp). Returns revisions at/before this point. Optional.

**Returns:** title, pageid, revisions[] (revid, parentid, timestamp, user, comment, size, minor, tags), count, next; + attribution

**Example request body:**
```json
{
  "title": "Albert Einstein"
}
```

### POST /wikipedia/v1/html — 2 credits
rendered article HTML (REST Parsoid) — or raw wiki markup with format=wikitext

**Parameters:**
- `title` (string, required) — Exact article title (case-sensitive first letter aside).
- `lang` (string, optional, default "en") — Wikipedia language edition code (en, de, fr, ja, … 360+ editions). Default en.
- `format` (enum, optional, default "html") — Output flavour: rendered 'html' (default) or raw 'wikitext' source. [one of: html, wikitext]

**Returns:** page{} — title, pageid, lang, format (html|wikitext), html|wikitext, length, etag; + attribution

**Example request body:**
```json
{
  "title": "Albert Einstein"
}
```

### POST /wikipedia/v1/featured — 1 credit
Wikimedia featured-content feed for a date: tfa (today's featured article), image-of-the-day, in-the-news, most-read and on-this-day (blocks vary by language/date)

**Parameters:**
- `date` (string, optional) — Day to rank, YYYY-MM-DD or YYYYMMDD. Defaults to yesterday (today lags).
- `lang` (string, optional, default "en") — Wikipedia language edition code (en, de, fr, ja, … 360+ editions). Default en.

**Returns:** date + present blocks: tfa{}, image{}, news[], mostread{articles[]}, onthisday[]; + attribution

**Example request body:**
```json
{
  "date": "2024-03-14"
}
```

## More
- Try it live, no code: https://reefapi.com/playground?engine=wikipedia
- Human docs page: https://reefapi.com/docs/wikipedia
- Every ReefAPI API in one file (for your AI): https://reefapi.com/llms-full.txt
