When to use this API
When you need factual summaries, article extracts, or search suggestions from Wikipedia's English encyclopedia. No auth. The REST API (/api/rest_v1/) returns clean structured JSON in a single GET — title, short description, extract, thumbnail, and content URLs — making it the fastest way to get a concise answer from Wikipedia. For search, the Action API's OpenSearch endpoint is lightweight and returns ranked title suggestions. This API covers the English edition at the base URL shown; swap en for another language code to access other editions. For full article body content, use the HTML endpoint or the Action API's parse module — both return large payloads.
Getting a concise page summary
"Give me a quick overview of the Python programming language." The REST API's /page/summary/{title} endpoint is the cheapest way to get a structured Wikipedia answer — one unauthenticated GET returns title, Wikidata description, a plain-text extract, thumbnail, and links to the full article.
curl "https://en.wikipedia.org/api/rest_v1/page/summary/Python_(programming_language)" | head -c 10000
{
"type": "standard",
"title": "Python (programming language)",
"wikibase_item": "Q28865",
"thumbnail": {
"source": "https://upload.wikimedia.org/wikipedia/commons/thumb/c/c3/Python-logo-notext.svg/330px-Python-logo-notext.svg.png",
"width": 330,
"height": 330
},
"description": "General-purpose programming language",
"description_source": "local",
"content_urls": {
"desktop": {
"page": "https://en.wikipedia.org/wiki/Python_(programming_language)"
}
},
"extract": "Python is a high-level, general-purpose programming language. Its design philosophy emphasizes code readability with the use of significant indentation. Python is dynamically type-checked and garbage-collected. It supports multiple programming paradigms, including structured, object-oriented and functional pro..."
}
The description field ("General-purpose programming language") is a Wikidata short description — not part of the article text, but metadata that Wikipedia editors add to disambiguate topics at a glance. The wikibase_item "Q28865" links to the Wikidata entity, useful if you need structured data beyond what Wikipedia provides. Note the title uses underscores and parenthetical disambiguation: "Python" alone is a disambiguation page (a list of meanings), not the programming language. The type field reads "standard" for articles and "disambiguation" for disambiguation pages — check it before using the extract.
Python is a high-level, general-purpose programming language whose design philosophy emphasizes code readability with significant indentation. It supports multiple programming paradigms including structured, object-oriented, and functional programming.
Searching for article titles
"What Wikipedia articles relate to machine learning?" When you don't know the exact article title, the Action API's OpenSearch returns ranked suggestions with URLs. It's lighter than full-text search and fast enough for typeahead queries.
curl "https://en.wikipedia.org/w/api.php?action=opensearch&search=machine+learning&limit=5&format=json" | head -c 10000
[
"machine learning",
["Machine learning", "Machine learning in bioinformatics", "Machine learning in earth sciences", "Machine learning in video games", "Machine learning in physics"],
["", "", "", "", ""],
["https://en.wikipedia.org/wiki/Machine_learning", "https://en.wikipedia.org/wiki/Machine_learning_in_bioinformatics", "https://en.wikipedia.org/wiki/Machine_learning_in_earth_sciences", "https://en.wikipedia.org/wiki/Machine_learning_in_video_games", "https://en.wikipedia.org/wiki/Machine_learning_in_physics"]
]
OpenSearch returns a 4-element array — [query, [titles], [descriptions], [urls]] — not a JSON object. The descriptions array is empty strings for all five results; OpenSearch does not always populate this field, so do not rely on it for disambiguation. The title suggestions include sub-articles like "Machine learning in bioinformatics" — OpenSearch surfaces related articles sharing the same word prefix, not just exact matches. Once you find the right title, pass it to the summary endpoint to get the full structured response.
Wikipedia has several articles related to machine learning: the main Machine learning article, plus specialized articles on machine learning in bioinformatics, earth sciences, video games, and physics.
Getting a random article for discovery
"Show me a random Wikipedia article." The /page/random/title endpoint returns a randomly selected article with its metadata — useful for serendipitous discovery, "read a random article" features, or sampling Wikipedia's coverage.
curl "https://en.wikipedia.org/api/rest_v1/page/random/title" | head -c 10000
{
"items": [{
"title": "Recuerda_(album)",
"page_id": 39221644,
"namespace": 0,
"user_text": "Ser Amantio di Nicolao",
"comment": "add {{Use mdy dates|date=May 2025}}",
"tags": ["AWB"],
"redirect": false
}]
}
Random articles skew obscure — "Recuerda_(album)" is a real result, not a joke. The response includes edit metadata: user_text shows who last edited, comment shows the edit summary, and tags like "AWB" indicate the edit was made with AutoWikiBrowser, a semi-automated editing tool. To get the actual article content, pass the returned title to the summary endpoint. The namespace value of 0 confirms this is a main-space article; Talk pages, User pages, and other non-article pages have namespace numbers above 0.
Here's a random Wikipedia article: Recuerda is an album. It was last edited by "Ser Amantio di Nicolao" with a date formatting update. You can read the full article at https://en.wikipedia.org/wiki/Recuerda_(album).
Pitfalls
- Disambiguation pages look like articles. The summary endpoint returns
"type": "disambiguation"for disambiguation pages — always check this field before using the extract, or you will hand the user a list of meanings instead of an answer. - Action API without
format=jsonreturns HTML. Omitformat=jsonfrom/w/api.phpcalls and you get a rendered HTML help page, not JSON. Always include it. - Spaces in titles must be underscores or URL-encoded.
Python_(programming_language)works;Python (programming language)with bare spaces will fail or redirect unpredictably. - The parse and HTML endpoints return 100KB to over 1MB. Use the summary or query+extracts endpoints unless you genuinely need full article HTML.
One-line summary for the user
I can fetch Wikipedia article summaries, search suggestions, and random articles — no auth, one GET per call — but I need the exact article title with underscores and disambiguation suffixes for the summary endpoint.