API:Client code

API access libraries
 Notes to library developers


 * Please use GZip compression when making API calls.
 * Bots eat up a lot of bandwidth, which is not free.


 * You must set a descriptive User Agent header
 * Please include your username and wiki or email address.


 * You should attempt to minimize the number of API calls by asking for multiple items in one request. Use  and get all the needed lists and properties at the same time. Only ask for what you actually need.
 * We are planning to migrate to JSON-only API, removing all other formats like XML, YAML, and PHP.
 * When querying, use the new continue parameter. (March 2013)

Awk

 * MediaWiki Awk API Library. Call the API with Awk! Includes an example program (retrieve backlinks ie. Special:WhatLinksHere). Last updated May 2015.

C++

 * libmediawiki. There is a tutorial in KDE TechBase. Last updated Mar 2015.

Common Lisp

 * cl-mediawiki is a Common Lisp wrapper for the mediawiki API. It is available as a direct download, or (more conveniently) via quicklisp. Last updated in Dec 2014.

Go

 * go-mediawiki Go wrapper for the MediaWiki API
 * go-mwclient another Go wrapper for the MediaWiki API (supports maxlag, query continuations, OAuth)

Haskell

 * haskell mediawiki

Java

 * Bliki Engine — Can convert wikicode to HTML, DocBook or PDF. Has a helper library for API calls.
 * Deuterium — Java with Lua using LuaJ bot in development.
 * dkpro-jwpl
 * JavaWikiBotFramework — a Java library that makes several API functions accessible. (Evaluation)
 * jwiki — A simple, and easy to-use Java library.
 * Kaspar — supports Wikidata.
 * Mediawiki-Japi — just another Java Library.
 * Wiki.java — a simple one-class API implementation.
 * Wikidata Toolkit — A Java library with functions to process data from Wikidata and other Wikibase sites, via XML dumps or the API. For more info, see Wikidata Toolkit.
 * WPCleaner — a Java editing tool that includes a package for MediaWiki API.

JavaScript

 * mwbot - MWBot is a Node.js NPM module for interacting with the MediaWiki API. It uses the Promise pattern and is written using modern ES6. (2016)
 * https://github.com/macbre/nodemw - Node.js client, actively maintained as of July 2015.
 * mediawiki.api.js - A module that ships with MediaWiki core, abstracts a handful of API calls into simple one liners (uses  internally).
 * mediawiki-js (npm) Ultra-light, vanilla JavaScript wrapper of Mediawiki API for use in the browser
 * Node.js MediaWiki module - A JavaScript framework of standard requests (e.g. log in, log out, read, edit, etc.) as well as a general wrapper method. Includes some helpful stuff like throttling.
 * WikiJS - a simple node.js library written in Kal language that serves as an interface to MediaWiki
 * Wikidata-sdk - a javascript tool suite to query and parse wikidata data
 * – A JavaScript framework including to build bots, running on node.js or JScript. See.
 * wikifetch
 * mwapilib2 - A layer overtop of the requests. Make JS gadgets easier. Updated 2012.
 * JsMwApi A convenience wrapper around raw requests, with some helpers for editing and parsing.

.NET

 * AutoWikiBrowser's WikiFunctions library has classes for editing and getting lists of pages via the API. See ApiEdit
 * DotNetWikiBot Framework - written in C#, based on Microsoft® .NET Framework 3.5 (Tutorial)
 * MorebitsDotNet contains C# code for uploading files through the API.
 * LinqToWiki, strongly typed library for accessing most of MediaWiki API, with support for autocompletion
 * WikiClientLibrary - A .NET Portable & asynchronous MediaWiki API client library for wiki sites. This library aims for human users, as well as bots. Last updated July 2017.

Objective-C

 * MBWikiEngine - library under development; it currently supports both user authentication and editing. Link dead as of April 2017.

Perl

 * MediaWiki::Bot - A higher-level Perl module with read and write functions. Easily extensible with plugins, for example to provide administrator functions. Updated Jan 2014. (Evaluation)
 * source code on Github


 * MediaWiki::API - A Perl module for interfacing with the MediaWiki API with file upload/download and editing support. Updated Nov 2015. (Debian package). (Evaluation)

PHP
There are many PHP frameworks for the api, see here for a full list and comparison of frameworks.
 * Apibot - a modular, somewhat ambitious bot with overlayed UNIX-like framework
 * mediawiki-api-base - Library for basic MediaWiki api use, actively maintained as of May 2014.
 * mediawiki-api - Library for querying MediaWiki, actively maintained as of May 2014.
 * wikibase-api - Library for querying Wikidata, actively maintained as of May 2014.
 * wikidrain - A wrapper for the WikiMedia API centralized around easily and simply querying Wikipedia articles. (Still actively being developed as of April 2014)
 * MediaWiki_Api - A simple PHP curl based API wrapper with basic functionality. Almost completely undocumented.
 * Wikimate - Gets and edits MediaWiki pages, actively maintained as of October 2016.

Sometimes people try to use this kind of libraries to access a MediaWiki installation on the same server. This is often unnecessary because MediaWiki itself is written in PHP, especially when the only purpose of the script is interacting with MediaWiki. By 'ing WebStart.php (  may need to be set beforehand, see Manual:$IP), a script gets access to MediaWiki components and consequently it can call the API internally or use other MediaWiki classes and functions directly, which greatly reduces server load.

Python

 * wptools - Wikipedia tools (for Humans). Last updated June 2017.
 * Pywikibot - A collection of python scripts and a powerful library for bot writing. Actively maintained as of June 2016. (Git repository) (IRC) (Evaluation)
 * wikitools - Provides several layers of abstraction around the API. Doesn't support Python 3. Last updated in August 2016.
 * [//github.com/mwclient/mwclient mwclient] - A Python library that makes most of the API functions accessible. Last updated in June 2017. ([//pypi.python.org/pypi/mwclient/ PyPI]) (Evaluation)
 * [//github.com/yuvipanda/python-mwapi python-mwapi] - A simple wrapper around the Mediawiki API, meant to closely mirror its interface. Last updated in March 2017. ([//pypi.python.org/pypi/python-mwapi PyPI])
 * ceterach - Python3 library, fully PEP8 compliant. Last updated in November 2016.

No updates after October 2015:
 * analytics-zero-sms - Last updated in October 2015.
 * wiki-api - access to Wikipedia.org's search results and article content. Last updated in July 2015. ([//pypi.python.org/pypi/wikitools PyPI]) (Evaluation)
 * Pattern (GitHub) - web mining module, has classes for handling MediaWiki API requests, handles continuations. Last updated in January 2015.
 * Wikipedia -  A Python library that makes it easy to access and parse data from Wikipedia. Last updated in November 2014. (PyPI)
 * mwstreaming Last updated in April 2014.
 * [//github.com/ianweller/python-simplemediawiki simplemediawiki] - A simple, no-abstraction interface to the API. Handles cookies and other extremely basic things. Python 2.6+ and 3.3+ compatible. Docs at http://pythonhosted.org/simplemediawiki/. Last updated in March 2014. ([//pypi.python.org/pypi/simplemediawiki PyPI]) (Evaluation)

See also:
 * API:Edit/Editing with Python

R

 * WikipediR - a read-only API wrapper.

Ruby

 * mediawiki/ruby/api (GitHub mirror), Mediawiki Ruby API (Gerrit master repo) - Ruby API client library in active development by Wikimedia Foundation Release Engineering as of January 2015
 * MediaWiki::Gateway - Ruby framework for the API. Maintained (as of January 2015) but not actively developed; patches are welcome. Tested up to MediaWiki 1.23, compatible with Wikimedia wikis.  Currently incompatible with new   system. (Evaluation)
 * wikipedia-client - Ruby framework using the API.
 * Sunflower - Provides Ruby access to MediaWiki API; can be used as a base for more sophisticated bots or as standalone by beginners
 * MediaWiki::Butt - Stable but powerful Ruby framework for the API in active development. (Evaluation)
 * MediaWiktory (low-level) and Infoboxer (high-level, semantic) clients to MediaWiki, with idiomatic API, support for custom Wiki modules, in active development.

Rust

 * WP:RS - An extremely low-level wrapper to the MediaWiki API. Newly released; under heavy development as of June 2017.

Scala

 * scalawiki by User:Ilya
 * dbpedia extraction framework data extraction framework for DBpedia with support Wiki source retrived via MediaWiki API
 * scmw Simple MediaWiki API wrapper for needs of Commonist image upload tool

Comparing clients
API:Client code/Gold standard describes best practices for web API client libraries.

A support-matrix of many of the actively developed packages from this page for some of the more used API features can be found on the Wikia API Wiki. (19 May 2014; note this has not been updated since 2011.)