API:Client code
From MediaWiki.org
![]() |
This page is part of the MediaWiki API documentation. |
Language: | English • 日本語 • русский |
---|
Quick overview:
- Quick start guide
- FAQ
- Tutorial
- Formats
- Error reporting
- Restricting usage
- Cross-site requests
- Authentication
- Queries
- Search suggestions
- Parsing wikitext and expanding templates
- Purging pages' caches
- Parameter information
- Changing wiki content
- Watchlist feed
- Wikidata
- Extensions
- Using the API in MediaWiki and extensions
- Miscellaneous
- Implementation
- Client code
- Asserting
Contents
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.
- You must set a descriptive User Agent header (
User-Agent: User name/email/framework/...
)
- 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)
Bash[edit | edit source]
- See API:Client_code/Bash. Requires curl package.Smallman12q (talk) 00:02, 7 January 2013 (UTC)
- Make sure to add your email address to the User-Agent line.
C++[edit | edit source]
No updates after May 2013:
- libmediawiki. There is a tutorial in KDE TechBase. Last updated Aug 2013.
Clojure[edit | edit source]
No updates after May 2013:
- cloki Last updated in 2010.
Common Lisp[edit | edit source]
No updates after May 2013:
- 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 2012.
Delphi/Object Pascal[edit | edit source]
No updates after May 2013:
- MediaWiki API Wrapper, based on ICS open-source sockets, with synchronous and asynchronous (event based) requests, requires the JEDI Code Library for dependencies. Last updated in 2012.
Go[edit | edit source]
- go-mediawiki Go wrapper for the MediaWiki API
- go-mwclient another Go wrapper for the MediaWiki API (supports maxlag)
Haskell[edit | edit source]
Java[edit | edit source]
- Bliki Engine - Java Wikipedia API - very complete. Can convert wikicode to HTML, DocBook or PDF. Has a helper library for API calls.
- JavaWikiBotFramework - a Java library that makes almost all API functions accessible. On github: https://github.com/eldur/jwbf.
- Wiki.java — a simple one-class API implementation
- WPCleaner — a Java editing tool that includes a package for MediaWiki API.
No updates since May 2013:
JavaScript[edit | edit source]
- https://github.com/macbre/nodemw - Node.js client, actively maintained as of May 2014.
- 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 that serves as an interface to MediaWiki
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]
- 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
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:
- ocaml-mediawiki Last updated in 2012.
Perl[edit | edit source]
- 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.
- source code on Github
- Client scripts (As of May 2014, last updated in 2010)
No updates after May 2013:
- MediaWiki::API - A Perl module for interfacing with the MediaWiki API with file upload/download and editing support. (Debian package).
- CMS-MediaWiki Perl extension for fetching, creating and updating MediaWiki pages. Documentation: http://search.cpan.org/dist/CMS-MediaWiki/lib/CMS/MediaWiki.pm
- Perl MediaWiki API - An open source Perl module wrapping many of the MediaWiki API functions.
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
- 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)
Python[edit | edit source]
- Pywikibot - A collection of python scripts. Seems up to date (Nov 2013) (IRC)(Evaluation)
- mwclient - A Python library that makes most of the API functions accessible. (PyPI)(Evaluation)
- wikitools - Provides several layers of abstraction around the API. Should be up to date (PyPI) (Evaluation)
- 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/ .(PyPI) (Evaluation)
- Wikipedia - A Python library that makes it easy to access and parse data from Wikipedia. (PyPI)
- python-mwapi - A simple wrapper around the Mediawiki API, meant to closely mirror its interface (PyPI)
- supersimplemediawiki - Similar to simplemediawiki, but does not handle tokens or compression.
- Pattern, [1] - web mining module, has classes for handling MediaWiki API requests, handles continuations
- ceterach - Python3 library, fully PEP8 compliant.
R[edit | edit source]
- WikipediR - a read-only API wrapper.
Ruby[edit | edit source]
- mediawiki/ruby/api, https://gerrit.wikimedia.org/r/#/admin/projects/mediawiki/ruby/api - Ruby API client library in active development as of April 2014
- wikipedia-client - Ruby framework using the API.
- MediaWiki::Gateway - Ruby framework for the API. Maintained, tested up to MediaWiki 1.22, compatible with Wikimedia wikis. Has not been in active development since 2012.
- Sunflower - Provides Ruby access to MediaWiki API; can be used as a base for more sophisticated bots or as standalone by beginners
No updates after May 2013:
- RWikiBot - a Ruby framework using the API. No releases since 2008.
- rbmediawiki - Another Ruby framework that uses the API. No releases since 2009.
- mediawikiclient - No releases since 2007
- wikipedia-api - No releases since 2008
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]
- Collection of bot libraries on Wikipedia, several of these use the API.