TheyWorkForYou API
Welcome to TheyWorkForYou's API section, where you can learn how to query our database for information.
Overview
All requests take a number of parameters. output is optional, and defaults to js.
http://www.theyworkforyou.com/api/function?output=output&other_variables
The current version of the API is 1.0.0. If we make changes to the API, 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".
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:
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
- Postcode to constituency lookup, with no server side code - use this to add constituency or MP lookup to a form on your website.
- Map showing location of all 646 constituencies, with no server side code - example code using JavaScript and Google Maps.
- Hansard prettifier - drag this bookmarklet to your bookmarks bar, or bookmark it. Then if you ever find yourself on the official site, clicking this will try and take you to the equivalent page on TheyWorkForYou. (Tested in IE, Firefox, Opera.)
- Matthew's MP Fab Farts - every technology has the capacity to be used for fun.
- Francis' MP Fight telnet text adventure (
and Chris' web version) - battle your way to Sedgefield! - Your MP - Google Desktop Gadget - with GPL source code
