TL;DR
The Wikipedia API provides programmatic access to the world's largest free encyclopedia — 60 million+ articles across 300+ languages. Search for articles, retrieve summaries, get full page text, extract images and infobox data, browse categories, and find related pages. REST API with simple URL patterns. Use the action API for advanced queries (backlinks, page info, recent changes) or the REST API for simpler content retrieval. The foundation of countless apps, voice assistants (Siri, Alexa use it), and knowledge bases worldwide.
Quick start: https://en.wikipedia.org/api/rest_v1/page/summary/Moon
No API key needed — just make a request!
https://en.wikipedia.org/api/rest_v1/page/summary/Moon
How to Use This API
1. Page Summary (REST API)
https://en.wikipedia.org/api/rest_v1/page/summary/JavaScript
Returns title, extract (first paragraph), thumbnail image, and page URL.
2. Page Summary in Another Language
https://fr.wikipedia.org/api/rest_v1/page/summary/Paris
3. Full Page HTML
https://en.wikipedia.org/api/rest_v1/page/html/Python_(programming_language)
4. Search Articles (Action API)
https://en.wikipedia.org/w/api.php?action=opensearch&search=quantum&limit=5
5. JavaScript — Knowledge Box
async function wikiSummary(topic) {
const resp = await fetch(
`https://en.wikipedia.org/api/rest_v1/page/summary/${encodeURIComponent(topic)}`
);
const data = await resp.json();
console.log(`\u{1F4D6} ${data.title}`);
console.log(`\n${data.extract}`);
console.log(`\nRead more: ${data.content_urls.desktop.page}`);
if (data.thumbnail) {
console.log(`Image: ${data.thumbnail.source}`);
}
}
wikiSummary('Artificial intelligence');
6. Python — Multi-Lingual Search
import requests
def search_wikipedia(query, lang='en', limit=3):
params = {
'action': 'opensearch',
'search': query,
'limit': limit,
'namespace': 0,
'format': 'json'
}
resp = requests.get(
f'https://{lang}.wikipedia.org/w/api.php',
params=params
)
data = resp.json()
print(f'Wikipedia ({lang}) results for "{query}":')
for i, title in enumerate(data[1], 1):
desc = data[2][i - 1] if i <= len(data[2]) else ''
url = data[3][i - 1] if i <= len(data[3]) else ''
print(f' {i}. {title}')
if desc:
print(f' {desc[:80]}...')
print(f' {url}')
search_wikipedia('machine learning', 'en')
search_wikipedia('aprendizaje automático', 'es')
Frequently Asked Questions
- Do I need an API key?
- No. Wikipedia's API is completely free and open. Just provide a User-Agent header identifying your application.
- What's the difference between REST and Action APIs?
- The REST API (v1) is simpler for common tasks like summaries and page content. The Action API is more powerful for complex queries like searching, category membership, template expansion, and recent changes.
- How many languages are supported?
- 300+ languages. Replace
enin the URL with any Wikipedia language code (fr,de,ja,es,pt,zh, etc.). - What rate limits apply?
- Be respectful — Wikipedia requests no more than 200 requests/second for the API. Use caching and set a meaningful User-Agent header.
- Can I get article categories?
- Yes. Use the Action API with
prop=categoriesto get all categories a page belongs to. - How do I get random articles?
- Use
action=query&list=random&rnlimit=5in the Action API, or use the REST API endpoint/page/random/summary.
API Details
- API URLs
https://en.wikipedia.org/api/rest_v1/(REST)https://en.wikipedia.org/w/api.php(Action)- Documentation
- mediawiki.org/wiki/API
- Category
- Education
- Authentication
- Not Required (User-Agent recommended)
- Geographic Coverage
- Global — 300+ languages
What You Can Build
- Voice assistant that reads Wikipedia summaries aloud
- Trivia game sourcing questions from random articles
- Research assistant that fetches and cites Wikipedia references
- Language learning app showing the same article in two languages
- Knowledge graph exploring connections between topics