pythonmediawikiwikipedia-apimediawiki-apipywikibot

Pywikibot MediaWiki Query API


I have a data dump of Wikipedia articles listed only by their pageid, and I am hoping to filter them by namespace. It would be relatively easy to write some python (probably using the requests module) to call the MediaWiki Query API, to query for namespaces 50 at a time using the pageids param.

But, I was going to try to use Pywikibot instead, as the best practices and error handling for querying the API are likely baked into Pywikibot, and less likely to get my IP banned if I make a logical error and over-query the API. (In addition, I am hoping to gain experience with this module for my future bot writing endeavors)

However, I can't really find very good documentation for Pywikibot, and am having trouble finding language in the existing doc about this API. I have also tried various other python packages in hopes to find bindings (is that the correct usage of bindings?) with this API, to no avail.


Solution

  • Pywikibot does not have much in the way of developer documentation, usually you have to read the source (data/api.py in this case). python-mwapi and mwclient are some well-maintained, well-documented libraries.