Wikipedia

Mediawiki Encyclopedia

Wikipedia's MediaWiki API provides programmatic access to the world's largest free encyclopedia — 60+ million articles in 300+ languages. You can search articles, retrieve page content (HTML, wikitext, or plain text extracts), fetch images, get page metadata, access revision history, and use the REST API for structured summaries. For OpenClaw agents, Wikipedia is an essential knowledge lookup tool. Your agent can fetch article summaries for factual questions, get structured data from Wikidata, pull images for enriching responses, or use Wikipedia as a grounding source to verify LLM claims. The REST API's summary endpoint is particularly agent-friendly — it returns clean, structured JSON with extract text and thumbnail images.

Tags: knowledge, open-data

Category: Open Data

Use Cases

  • Look up factual information to ground agent responses with verified data
  • Fetch article summaries and thumbnails for enriching chat responses
  • Use Wikipedia as a knowledge base for 'what is X' type queries

Tips

  • Use the REST API (/api/rest_v1/) for clean, structured responses instead of the older Action API
  • The /page/summary/ endpoint is the simplest way to get article content for agent responses
  • For disambiguation, use the search endpoint first to find the correct article title

Known Issues & Gotchas

  • MUST include a User-Agent header — requests without one get blocked
  • The Action API (api.php) returns complex nested JSON — use the REST API instead
  • Article titles are case-sensitive and use underscores instead of spaces

Frequently Asked Questions

Which Wikipedia API endpoint is best for agents?

The REST API summary endpoint (/api/rest_v1/page/summary/{title}) is ideal. It returns a clean JSON object with title, extract text, description, and thumbnail — perfect for agent consumption.

Do I need an API key?

No key needed. However, you MUST set a descriptive User-Agent header or requests may be blocked. Include your app name and contact email in the header.

Can I access Wikipedia in other languages?

Yes. Replace 'en.wikipedia.org' with the language code subdomain (e.g., 'hi.wikipedia.org' for Hindi, 'fr.wikipedia.org' for French). The API structure is identical across all language editions.