Wikimania 2007 talk: “MediaWiki API”

Talk: “MediaWiki API” by Yuri Astrakhan

Summary: “It’s all about the data, stupid!”

Yurikbot: More than 3 million edits.

The API adds a new layer of access. Allows new clients to access data (e.g. JavaScript browser extensions, Standalone apps like vandal fighter, data gathering for researchers).

Does not use the HTML rendering code.

Example of this; The navigation pop ups extension – this uses the API (because it is faster).

Current situation:

  • We have login

  • Can query existing data

  • Multiple output formats.

Coming:

  • Change data (this is currently in development by the Spanish Vodafone folks, among others)

API is very modular – can add things, and they will just plug in.

Can get some of the following:

  • Page information

  • Lists (e.g. list of backlinks to a page)

  • Metadata (servers)

  • Can get multiple types of information all in one query

  • Conveniences to avoid gotchas – e.g. normalisation, resolving redirects, etc.

(gave some demos of these on the live Wikipedia).

Tries to be very quick – only does the work that you ask it for.

Gave API performance figures: API gets 2% of Wikimedia site hits. Yet uses 0.1% of CPU load. I.e. API is 20 times more efficient than the main UI. However at the moment is a read-only API, so would expected better performance that the main UI (which also has to do writes).

Most of the hits are coming from the Open Search module currently.

Future: Want to add unit tests for the API (Note from me: it’s coming, but don’t hold your breath!).

Asked API users to use GZIP compression when calling it – added recently to PyWiki – this saves lots of bandwidth.

In the Q&A time, I asked the Vodafone folks about the API write capacity they’re working on, and very roughly when they thought it might be ready: Their estimate: Should be ready around Christmas (i.e. 4.5 months). They want it for their mobile phone customers, who want to be able to modify the Wikipedia, as well as view it on their mobile phones.

Demo time: Showed some examples of some API code (e.g. added a simple module, showed how to add new supported formats to the API).

Link to talk’s page.