This package wraps the MediaWiki API so Python code can search Wikipedia, fetch summaries, and read page content and links without hand-rolling HTTP calls.
Overview
The Wikipedia library is a Python package for reading data from Wikipedia through the MediaWiki API. It focuses on everyday tasks such as searching titles, pulling short summaries, loading full article text, and accessing metadata like URLs and outbound links.
Callers can change the active language, resolve pages by exact title, and work with page objects that expose title, content, and related fields. The wrapper handles HTTPS, connection pooling, timeouts, limited retries, and short-lived caching so repeated reads do not hammer the API.
Wikimedia asks clients to set a descriptive user agent with contact information; the library documents how to do that. Optional rate limiting can insert a minimum delay between requests for polite bulk use.
The authors position it for simple scripts and learning, and note that heavy scraping or automation should use a more full-featured MediaWiki client instead. Install it with pip for use in Python application code.
Key features
- Article search and summaries
- Full page content access
- MediaWiki API wrapper
- HTTPS with timeouts and retries
- Language selection
- Request caching
- Configurable user agent
- Optional rate limiting
Use cases
- Scripts that fetch article text
- Quick Wikipedia lookups in Python
- Building tools on encyclopedia data
- Prototyping MediaWiki integrations
- Teaching API usage patterns