> **For coding agents and LLMs:** This is one Social Fetch marketing page (markdown export). For API orientation start with [`/llms.txt`](https://www.socialfetch.dev/llms.txt); for auth and crawl rules use [`/agents.txt`](https://www.socialfetch.dev/agents.txt); for every operation use [`/llms-endpoints.txt`](https://www.socialfetch.dev/llms-endpoints.txt).

## This page

- **On-site (HTML):** <https://www.socialfetch.dev/platforms/wikipedia>
- **Markdown (.mdx) URL:** <https://www.socialfetch.dev/platforms/wikipedia.mdx>

---

# Wikipedia API. Pages, history and Wikidata as JSON.

Page records, article bodies, edit history, links, categories, pageviews and Wikidata in one API. Pick an edition, name a title, get JSON.

- Any Wikipedia edition
- Wikipedia + Wikidata
- 1 credit per request

Social Fetch exposes 26 routes under `/v1/wikipedia`. Most routes take `lang`, an edition code such as `en`, `de`, `ja` or `zh-hant`, so the same call works across Wikipedia editions. Every route that covers an edition, including Wikidata search, takes `lang`, and the SPARQL route needs no edition. Page routes also take a `title` exactly as it appears on the edition, including prefixes such as `Category:Living people` or `Talk:Barack Obama`.

Pages and history come from the page, batch, content, revisions and history-stats routes. The links and structure routes cover backlinks, internal and external links, language editions, media and category members. Discovery covers full-text search, prefix suggestions, nearby pages and random pages. Traffic and recency cover per-article pageviews, the most-viewed list, site totals, the featured feed, on-this-day entries, recent changes and public logs. People come from the user and contributions routes. Wikidata comes from the entity, search and read-only SPARQL routes.

Every response is the `{ data, meta }` envelope. `data.lookupStatus` is `found` or `not_found`, so a missing page, user or entity is a typed answer instead of an error. Lists page with an opaque `cursor` from `page.nextCursor`; when `page.hasMore` is false the walk is over. Nearby pages is the exception: it returns the nearest `limit` results and has no cursor. Counts and version fields are Wikipedia's own, never invented.

## What you can get

- Page records with title, namespace, Wikidata id, description, lead extract, images, coordinates, protection and revision data.
- Article content as plain text, rendered HTML or wikitext, with sections, categories, templates, images and external links.
- Full revision history, edit and editor counts, backlinks, internal and external links, language editions and media.
- Full-text search with match ranges and total hits, plus prefix suggestions, category members, nearby pages and random pages.
- Daily or monthly per-article views, most-viewed articles and countries, and site-wide views or unique devices.
- The featured feed, on-this-day entries, recent changes and public logs, filtered by type, page, namespace or time.
- Public user records and contribution lists, with block, group and registration data.
- Wikidata entities by id or wiki title, entity search, and read-only SPARQL query results.

## Wikipedia endpoints

| Endpoint | Request | Credits | Docs |
| --- | --- | --- | --- |
| Page | GET /v1/wikipedia/pages/{title} | 1 credit Failed requests are free | [docs](https://www.socialfetch.dev/docs/api/v1/wikipedia/pages/title/get) |
| Pages by title | GET /v1/wikipedia/pages | 1 credit per title Up to 20 titles per request Max 20 credits Failed requests are free | [docs](https://www.socialfetch.dev/docs/api/v1/wikipedia/pages/get) |
| Page content | GET /v1/wikipedia/pages/{title}/content | 1 credit Failed requests are free | [docs](https://www.socialfetch.dev/docs/api/v1/wikipedia/pages/title/content/get) |
| Revisions | GET /v1/wikipedia/pages/{title}/revisions | 1 credit Failed requests are free | [docs](https://www.socialfetch.dev/docs/api/v1/wikipedia/pages/title/revisions/get) |
| History stats | GET /v1/wikipedia/pages/{title}/history-stats | 1 credit Failed requests are free | [docs](https://www.socialfetch.dev/docs/api/v1/wikipedia/pages/title/history-stats/get) |
| Backlinks | GET /v1/wikipedia/pages/{title}/backlinks | 1 credit Failed requests are free | [docs](https://www.socialfetch.dev/docs/api/v1/wikipedia/pages/title/backlinks/get) |
| Links | GET /v1/wikipedia/pages/{title}/links | 1 credit Failed requests are free | [docs](https://www.socialfetch.dev/docs/api/v1/wikipedia/pages/title/links/get) |
| Languages | GET /v1/wikipedia/pages/{title}/languages | 1 credit Failed requests are free | [docs](https://www.socialfetch.dev/docs/api/v1/wikipedia/pages/title/languages/get) |
| Media | GET /v1/wikipedia/pages/{title}/media | 1 credit Failed requests are free | [docs](https://www.socialfetch.dev/docs/api/v1/wikipedia/pages/title/media/get) |
| Pageviews | GET /v1/wikipedia/pages/{title}/pageviews | 1 credit Failed requests are free | [docs](https://www.socialfetch.dev/docs/api/v1/wikipedia/pages/title/pageviews/get) |
| Top pages | GET /v1/wikipedia/pageviews/top | 1 credit Failed requests are free | [docs](https://www.socialfetch.dev/docs/api/v1/wikipedia/pageviews/top/get) |
| Site pageviews | GET /v1/wikipedia/pageviews/site | 1 credit Failed requests are free | [docs](https://www.socialfetch.dev/docs/api/v1/wikipedia/pageviews/site/get) |
| Search | GET /v1/wikipedia/search | 1 credit Failed requests are free | [docs](https://www.socialfetch.dev/docs/api/v1/wikipedia/search/get) |
| Search suggestions | GET /v1/wikipedia/search/suggest | 1 credit Failed requests are free | [docs](https://www.socialfetch.dev/docs/api/v1/wikipedia/search/suggest/get) |
| Category members | GET /v1/wikipedia/categories/{title}/members | 1 credit Failed requests are free | [docs](https://www.socialfetch.dev/docs/api/v1/wikipedia/categories/title/members/get) |
| Nearby pages | GET /v1/wikipedia/geosearch | 1 credit Failed requests are free | [docs](https://www.socialfetch.dev/docs/api/v1/wikipedia/geosearch/get) |
| Featured feed | GET /v1/wikipedia/feed | 1 credit Failed requests are free | [docs](https://www.socialfetch.dev/docs/api/v1/wikipedia/feed/get) |
| On this day | GET /v1/wikipedia/on-this-day | 1 credit Failed requests are free | [docs](https://www.socialfetch.dev/docs/api/v1/wikipedia/on-this-day/get) |
| Recent changes | GET /v1/wikipedia/recent-changes | 1 credit Failed requests are free | [docs](https://www.socialfetch.dev/docs/api/v1/wikipedia/recent-changes/get) |
| Logs | GET /v1/wikipedia/logs | 1 credit Failed requests are free | [docs](https://www.socialfetch.dev/docs/api/v1/wikipedia/logs/get) |
| User | GET /v1/wikipedia/users/{name} | 1 credit Failed requests are free | [docs](https://www.socialfetch.dev/docs/api/v1/wikipedia/users/name/get) |
| Contributions | GET /v1/wikipedia/users/{name}/contributions | 1 credit Failed requests are free | [docs](https://www.socialfetch.dev/docs/api/v1/wikipedia/users/name/contributions/get) |
| Wikidata entity | GET /v1/wikipedia/wikidata/entities/{id} | 1 credit Failed requests are free | [docs](https://www.socialfetch.dev/docs/api/v1/wikipedia/wikidata/entities/id/get) |
| Wikidata search | GET /v1/wikipedia/wikidata/search | 1 credit Failed requests are free | [docs](https://www.socialfetch.dev/docs/api/v1/wikipedia/wikidata/search/get) |
| SPARQL query | GET /v1/wikipedia/wikidata/query | 1 credit Failed requests are free | [docs](https://www.socialfetch.dev/docs/api/v1/wikipedia/wikidata/query/get) |
| Random pages | GET /v1/wikipedia/random | 1 credit Failed requests are free | [docs](https://www.socialfetch.dev/docs/api/v1/wikipedia/random/get) |

## How to start

1. **Create an API key.** Sign up at Social Fetch and copy a key (`sfk_...`). New accounts get 100 free credits, enough to try each route on a few pages.
2. **Choose the edition and route.** Send `x-api-key` on every request. Use `lang=en` for English, or `lang=de` for German. For example `GET /v1/wikipedia/pages/Albert%20Einstein` returns the page record and `GET /v1/wikipedia/search?query=einstein&lang=en` returns search hits.
3. **Branch and page.** Check `data.lookupStatus` before storing a row. Follow `data.page.nextCursor` while `data.page.hasMore` is true. Bill from `meta.creditsCharged`.

## Pricing

Most Wikipedia routes charge 1 credit per completed request. The batch route charges 1 credit per requested title, up to 20 titles per call. Each page of a list is its own request. Credits never expire on pay-as-you-go packs, and `meta.creditsCharged` on every response is the billing source of truth.

## Compared with the official API

Wikipedia and Wikidata publish their own JSON APIs, but each surface has a different shape: page records, rendered content, revision lists, pageview metrics and SPARQL results all look different. Social Fetch gives every route the same `{ data, meta }` envelope, the same `lookupStatus`, the same cursor block and the same edition parameter, so one client can read a page, its history and its views without a separate adapter for each.

## FAQ

### Which Wikipedia editions can I read?

Any edition with a code such as en, de, ja, zh or zh-hant. Pass it as lang. The default is en. Titles are read on the edition you choose, so a title that exists on one edition can be not_found on another.

### How do I name a page title?

Use the title as it appears in the page URL, for example Albert Einstein, C++ or Category:Living people. Spaces and underscores both work, and a #fragment is dropped. Titles are limited to 255 bytes and may not contain a pipe, control characters, or the characters < > [ ] { }.

### What is the difference between the page and content routes?

GET /v1/wikipedia/pages/{title} returns the page record: identity, namespace, Wikidata id, description, lead extract, images, coordinates, protection, category counts and optional search-index data. GET /v1/wikipedia/pages/{title}/content returns the article body as plain text, HTML or wikitext, with sections, categories, templates and links.

### Does HTTP 200 mean the page exists?

No. HTTP 200 means the request finished. Check data.lookupStatus. found means the page or entity was returned; not_found means it does not exist on that edition. A found list with no rows also sets data.empty to true.

### Can I fetch several pages at once?

Yes. GET /v1/wikipedia/pages takes up to 20 titles separated by a pipe, for example titles=Albert Einstein|Barack Obama. Each entry in data.pages keeps its requestedTitle and its own lookupStatus, so a mix of found and missing titles is one successful call.

### How far back can I read pageviews and history?

Pageview routes take from and to as ISO 8601 dates or times, with daily or monthly granularity, and return one row per day or month in that range. History and list routes return at most 500 rows per page and continue through data.page.nextCursor. Data starts at the dates it publishes; a range with no rows is found with empty set to true.

### What can I do with Wikidata?

GET /v1/wikipedia/wikidata/entities/{id} returns an item, property, lexeme or media entity by id such as Q937 or P31. Add site=enwiki and pass a page title instead of an id to resolve that page's entity. GET /v1/wikipedia/wikidata/search finds entities by label, alias or description, and GET /v1/wikipedia/wikidata/query runs a read-only SPARQL query and returns the variable names, bindings and row count.

### How much does the Wikipedia API cost?

Most routes charge 1 credit per completed request. The batch route charges 1 credit per requested title, up to 20 per call. Each page of a list is billed separately. Check meta.creditsCharged on every response. New accounts start with 100 free credits.

### Can I use these routes from agents or MCP?

Yes. Every Wikipedia route is a typed MCP tool and can also be reached through Ask (POST /v1/ask) in plain English. Use the typed routes for production jobs and the MCP tools when an assistant needs to look something up.

## Related

- [Wikipedia Page API](https://www.socialfetch.dev/platforms/wikipedia/pages-title): One page record with identity, description, lead extract and optional search-index data (`GET /v1/wikipedia/pages/{title}`).
- [Wikipedia Content API](https://www.socialfetch.dev/platforms/wikipedia/pages-title-content): Article text, rendered HTML or wikitext with sections and links (`GET /v1/wikipedia/pages/{title}/content`).
- [Wikipedia Search API](https://www.socialfetch.dev/platforms/wikipedia/search): Full-text search with snippets, match ranges and total hits (`GET /v1/wikipedia/search`).
- [Wikipedia Top Pages API](https://www.socialfetch.dev/platforms/wikipedia/pageviews-top): The most-viewed pages or countries for a day or month (`GET /v1/wikipedia/pageviews/top`).
- [Wikidata Entity API](https://www.socialfetch.dev/platforms/wikipedia/wikidata-entities-id): An item, property, lexeme or media entity by id (`GET /v1/wikipedia/wikidata/entities/{id}`).
- [Hosted MCP](https://www.socialfetch.dev/mcp): Call Wikipedia tools from Cursor or Claude with the same credit metering as REST.
