API:Client code

From MediaWiki.org
(Redirected from API:Client Code)
Jump to: navigation, search
Language:Project:Language policy English  • 日本語 • русский
This page is part of the MediaWiki action API documentation.

MediaWiki action API

v · d · e

API access libraries[edit]

Notes to library developers

  • Please use GZip compression when making API calls (Accept-Encoding: gzip).
Bots eat up a lot of bandwidth, which is not free.
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 titles=PageA|PageB|PageC 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[edit]

Dates and version numbers were updated on 2017-08-01.

  • MediaWiki Awk API Library. Call the API with Awk! Includes an example program (retrieve backlinks ie. Special:WhatLinksHere). Last activity: December 2016.

C++[edit]

Dates and version numbers were updated on 2017-08-01.

Common Lisp[edit]

Dates and version here were updated 2017-08-01.

  • cl-mediawiki is a Common Lisp wrapper for the mediawiki API. It is available as a direct download, or (more conveniently) via quicklisp. Last activity: 2016-11-10.

Go[edit]

Dates and version numbers were updated on 2017-08-01.

  • go-mediawiki Go wrapper for the MediaWiki API. Last activity: 2017-02-07.
  • go-mwclient another Go wrapper for the MediaWiki API (supports maxlag, query continuations, OAuth). Last release: 1.0.0, 2017-01-04.

Haskell[edit]

Dates and version numbers were updated on 2017-08-01.

Java[edit]

Dates and version numbers were updated on 2017-08-01. Last activity refers to the last commit in the repository, which is useful to know if it is still active (and sometimes there are no "official" releases).

Name Description Last release Release Date Last activity
Bliki Engine Can convert wikicode to HTML, DocBook or PDF. Has a helper library for API calls April 2017
Deuterium Java with Lua using LuaJ bot in development June 2016
dkpro-jwpl. 1.1.0 2016-04-26 March 2017
JavaWikiBotFramework a Java library that makes several API functions accessible. (Evaluation) 3.1.0 December 2014 September 2016
jwiki A simple, and easy to-use Java library 1.3.0 2017-03-31 July 2017
Kaspar supports Wikidata 0.2 2015-07-18 January 2016
Mediawiki-Japi just another Java Library 0.0.19 2017-05-30 2017-05-30
Wiki.java a simple one-class API implementation 0.32 2016-12-18 2017-06-24
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. 0.7.0 2016-08-05 2017-07-04
WPCleaner a Java editing tool that includes a package for MediaWiki API 2017-07-19

JavaScript[edit]

Dates and version numbers were updated on 2017-08-06. Last activity refers to the last commit in the repository, which is useful to know if it is still active (and sometimes there are no "official" releases).

Name Description Last release Release Date Last activity
Wikidata SDK A javascript tool-suite to query Wikidata and simplify its results. 5.1.4 2017-04-01 2017-06-10
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. 1.0.8 2017-07-25 2017-07-25
WikiJS WikiJs is a node.js library which serves as an interface to Wikipedia (or any MediaWiki). 3.2.0 2017-08-02 2017-08-02
nodemw 0.10.1 2016-06-04 2017-06-27
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. 2014-07-02
mediawiki.api.js A module that ships with MediaWiki core, abstracts a handful of API calls into simple one liners (uses jQuery.ajax internally). Kept up-to-date by Wikimedia.
mediawiki-js Ultra-light, vanilla JavaScript wrapper of Mediawiki API for use in the browser (npm) 2015-06-17
CeJS A JavaScript framework including MediaWiki functions to build bots, running on node.js or JScript. See Wikipedia bot examples on GitHubGerrit/GitHub. 2.0.0 2015-10-28 2017-08-04

In-wiki JavaScript clients[edit]

Dates and version numbers were updated on 2017-08-06. Last activity refers to the last commit in the repository, which is useful to know if it is still active (and sometimes there are no "official" releases).

Name Description Last release Release Date Last activity
mwapilib2 A layer overtop of the requests. Make JS gadgets easier. 2016-09-25
JsMwApi A convenience wrapper around raw requests, with some helpers for editing and parsing. 2014-06-11


.NET[edit]

  • 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 update: July 2017.

Perl[edit]

PHP[edit]

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
  • addwiki, actively maintained as of July 2017, comprised of several libraries:
  • 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 require'ing WebStart.php (MW_INSTALL_PATH 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[edit]

  • wptools - Wikipedia tools (for Humans). Last updated September 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.
  • mwclient - A Python library that makes most of the API functions accessible. Last updated in June 2017. (PyPI) (Evaluation)
  • python-mwapi - A simple wrapper around the Mediawiki API, meant to closely mirror its interface. Last updated in March 2017. (PyPI)
  • ceterach - Python3 library, fully PEP8 compliant. Last updated in November 2016.

No updates after October 2015:

See also:

R[edit]

Ruby[edit]

  • 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 continue 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[edit]

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

Scala[edit]

Comparing clients[edit]

API:Client code/Gold standard describes best practices for action 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.)

See Also[edit]