From Wikipedia, the free encyclopedia
Jump to: navigation, search

Hey Developers, I've just written a new tool that could help you write programs! It is an Application programming interface, or API. It provides machine-readable information that can be incorporated into your program with ease. It outputs data in JSON, PHP, XML, YAML formats, as well as various debugging formats. It outputs information about replag, user groups, and edit counts.


The API has the following formats available:

  • format=json
  • format=php
  • format=xml
  • format=yaml
  • format=txt (PHP's print_r function)
  • format=dbg (PHP's var_export function)

Additionally, appending "fm" to the end of each format prints it in pretty-print HTML. For example, "json" becomes "jsonfm", "xml" becomes "xmlfm", and "dbg" becomes "dbgfm". It's not designed for use in an application, but for debugging purposes.


The API will respond whether you send parameters with a HTTP GET or a HTTP POST request. The standard url is It will work for any wiki that the standard edit counter works for. Here are some examples of the API in use:

Example's edit count on enwiki (in json)


Example's edit count on enwiki (in xml)

                        <replag w="0" d="0" h="15" m="40" s="31" xml:space="preserve">56431</replag>
                        <counts live="1" deleted="0" total="1"/>

Example's edit count on frwiki (in php)


Example's edit count on enwikibooks (pretty-printed in yaml)

      w: 0
      d: 0
      h: 0
      m: 3
      s: 21
      *: 201
      live: |
      deleted: |
      total: 2

Example's edit count on enwiki (in PHP's print_r format)

    [query] => Array
            [count] => Array
                    [replag] => Array
                            [w] => 0
                            [d] => 0
                            [h] => 15
                            [m] => 42
                            [s] => 49
                            [*] => 56569

                    [groups] => Array

                    [counts] => Array
                            [live] => 1
                            [deleted] => 0
                            [total] => 1




Example2's edit count on enwiki (in json, with callback)

The API accepts a callback parameter when called with the json format. If specified, it wraps the output into a given function call.



There will only be a few types of errors that will ever show up, so you will know how to have your application react.


A MySQL error has occurred. Example:

<?xml version="1.0"?>
  <error code="mysqlerror" info="You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UNIX_TIMESTAMP(rc_timestamp) as replag FROM recentchanges ORDER BY rc_timestamp ' at line 1" />


The user specified does not exist. Example:,%20I%20have%20lost%20faith%20in%20Wikipedia&lang=en&wiki=wikipedia

<?xml version="1.0"?>
  <error code="nosuchuser" info="User does not exist" />


No username was specified. Example:

<?xml version="1.0"?>
  <error code="missingusername" info="No username given" />


No language was specified. Example:

<?xml version="1.0"?>
  <error code="missinglanguage" info="No language given" />


No wiki was specified. Example:

<?xml version="1.0"?>
  <error code="missingwiki" info="No wiki given" />

Future ideas

This is still a prototype, and a work in progress. Here are some features I will add in the future:

  • Month counts
  • Namespace percentages
  • Namespace edits per month
  • Top edited articles