A simple and modern Python wrapper for the MediaWiki API.
(Yes, yet another.)
Use me to talk to Wikipedia.
This library particularly suited for large batch jobs that perform many queries to Wikipedia. Features include:
- Simple (but relatively low-level) API
- Persistent connections by default
- Uses POST for requests, allowing large payloads
This library is used by Citation Hunt, and, as such, is in active development and production use.
Fetching the Wikitext of a page requires a single method:
import yamwapi
api = yamwapi.MediaWikiAPI('https://en.wikipedia.org/w/api.php', 'yamwapi UA')
print api.get_page_contents(title = 'Wikipedia')
Other methods and options can be accessed via a lower level API:
api.options.maxlag = 10
print api.parse({'text': '{{ cn }}', 'contentmodel': 'wikitext'})
If you're considering this library, also be sure to have a look at mwapi, which is similar, but slightly lower level.