API:Client code

From MediaWiki.org
Jump to: navigation, search
Language: English  • 日本語 • русский
Tools clipart.png This page is part of the MediaWiki action API documentation.
MediaWiki APIsAPI:Main page

MediaWiki action API

v · d · e

API access libraries[edit | edit source]

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 | edit source]

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

Bash[edit | edit source]

C++[edit | edit source]

Clojure[edit | edit source]

No updates after May 2013:

  • cloki Last updated in 2010.

Common Lisp[edit | edit source]

  • 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.

Delphi/Object Pascal[edit | edit source]

No updates after May 2013:

Go[edit | edit source]

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

Haskell[edit | edit source]

Java[edit | edit source]

No updates since May 2013:

JavaScript[edit | edit source]

  • 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 jQuery.ajax 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
  • CeJS library for MediaWiki - a library to build bots, running on node.js or JScript.

No updates since May 2013:

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

No updates after May 2013:

  • WikiAccess - a C#-library that makes some API functions accessible, has write API. Last updated April 2013.

OCaml[edit | edit source]

No updates after May 2013:

Objective-C[edit | edit source]

  • MBWikiEngine - library under development; it currently supports both user authentication and editing. Actively maintained as of August 2015.

Perl[edit | edit source]

No updates after May 2013:

PHP[edit | edit source]

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.

No updates after May 2013:

  • SxWiki - a lightweight, simple MediaWiki bot framework. (Unmaintained since 2008)

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 | edit source]

See also:

R[edit | edit source]

Ruby[edit | edit source]

No updates after May 2013:

Scala[edit | edit source]

Comparing clients[edit | edit source]

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.)

See Also[edit | edit source]