API:Client Code/Access Library Comparison

Initial microtask for Evaluating MediaWiki web API client libraries.

The Python libraries listed on API:Client Code fall into two groups: libraries that offer a layer of abstraction that makes it easy for programmers to take advantage of the internal structure of the Mediawiki instance, and simple API wrappers that handle functions like logging in and cookies but do not otherwise mask the API structure.

Libraries that provide layers of abstraction over the Mediawiki API:

 * Pywikipediabot (IRC)
 * [//github.com/mwclient/mwclient mwclient] ([//pypi.python.org/pypi/mwclient/ PyPI])
 * wikitools ([//pypi.python.org/pypi/wikitools PyPI])
 * Wikipedia (PyPI)
 * Documentation warns not to use this for bots; does not support rate-limiting and other important features.

No-abstraction libraries for the Mediawiki API:

 * [//github.com/ianweller/python-simplemediawiki simplemediawiki] ([//pypi.python.org/pypi/simplemediawiki PyPI])
 * Handles cookies, login
 * Requires Python 2.6+ or 3.3+
 * Includes a documentation build configuration file, but no separate documentation
 * Provides usage examples in comments
 * Includes unit tests
 * Last updated: March 2014


 * [//github.com/legoktm/supersimplemediawiki supersimplemediawiki]
 * Handles login, cookies, get, post, and API calls
 * Python 2.6-3.3 compatible
 * Has an example script, but no other documentation.
 * No tests provided
 * Last updated: Nov 2013


 * [//github.com/yuvipanda/python-mwapi python-mwapi] ([//pypi.python.org/pypi/python-mwapi PyPI])
 * Handles login, get, post
 * Minimal documentation; no usage examples provided
 * No tests provided
 * Last updated: Dec 2012

The simplemediawiki is the only one of these basic API client libraries actively maintained (as of March 2014) and it is now compatible with Python 3. It is the best documented and is the only one that includes unit tests. The documentation could be improved by writing a more in-depth introduction to the library, making the example code easier to find and better documented, and including a separate documentation file. Simplemediawiki makes it easy to create a user_agent string, handles login and cookies, and provides a Python interface for making API calls (including the relatively recent Wikibase extension wbsearchentities).

Tests for simplemediawiki

 * Make sure that the API call you're making is supported on the wiki you're interacting with.  is available on Wikidata, not on Mediawiki.


 * Get calls work now that they are being called on the correct API! For instance:

Corresponding API request in browser: Result:


 * results for a missing page: