TheyWorkForYou API

Welcome to TheyWorkForYou's API section, where you can learn how to query our database for information.

Overview

  1. Get an API key.
  2. All requests are made by GETting a particular URL with a number of parameters. key is required; output is optional, and defaults to js.

http://www.theyworkforyou.com/api/function?key=key&output=output&other_variables

Current API users: We realise the inconvenience of adding a key to an API that previously did not require one. However, we feel it is now necessary in order to monitor the service for abuse, help with support and maintenance, locate large volume/ commercial users to ask them to contribute to our costs, and provide you with usage statistics.
The API will allow key-less calls for a short time, during which you can get a key and update your code.

The current version of the API is 1.0.0. If we make changes to the API functions, we'll increase the version number and make it an argument so you can still use the old version.

Outputs

The output argument can take any of the following values:

  • xml. XML. The root element is twfy.
  • php. Serialized PHP, that can be turned back into useful information with the unserialize() command. Quite useful in Python as well, using PHPUnserialize.
  • js. A JavaScript object. You can provide a callback function with the callback variable, and then that function will be called with the data as its argument.
  • rabx. "RPC over Anything But XML".

Errors

If there's an error, either in the arguments provided or in trying to perform the request, this is returned as a top-level error string, ie. in XML it returns <twfy><error>ERROR</error></twfy>; in JS {"error":"ERROR"}; and in PHP and RABX a serialised array containing one entry with key error.

Licensing

To use parliamentary material yourself (that's data returned from getDebates, getWrans, and getWMS), you will need to get a Parliamentary Licence from the Office of Public Sector Information. Our own data - lists of MPs, Lords, constituencies and so on - is available under the Creative Commons Attribution-ShareAlike license version 2.5.

Low volume, non-commercial use of the API service itself is free. Please contact us for commercial use, or if you are about to use the service on a large scale.

Bindings

These help you interface with the API more easily in a particular language:

  • Ruby (thanks to Bruce Williams and Martin Owen)
  • Perl (thanks to Spiros Denaxas)
  • PHP (thanks to Ruben Arakelyan)
  • Python (thanks to Paul Doran)
  • ASP.net (thanks to Ruben Arakelyan)
  • Java (thanks to Mitch Kent)

If anyone wishes to write bindings for the API in any language, please do so, let us know and we'll link to it here. You might want to join our public developer mailing list to discuss things.

Examples