tags:

views:

55

answers:

2

I'm calling a web API exposed by TheyWorkForYou (TWFI). http://www.theyworkforyou.com/api/

I'm using the Python bindings provided by twfython: http://code.google.com/p/twfython/

I wrote some code to call this API a few months ago, at which time it worked fine. But now I dig it out to run it again, no matter what query I ask of the API, it always returns '{}' (an empty dictionary). For example the following code, which should return a list of all MPs:

from twfy import TWFY
API_KEY = 'XXXXXXXXXXXXXXXXXXXXXX'
twfy = TWFY.TWFY(API_KEY)
print twfy.api.getMPs(output='js')

Am I being really dumb? What else should I check?

+2  A: 

You can run the getMPs call on their website directly, and it also produces no output. So you're probably right about there actually being no MPs at the moment.

Do you get the same output if you call getMSPs? This one seems like it should return data.

David
+2  A: 

From the horse's mouth, MAtthew Somerville at ORG:

The API is working as documented - when there is no MP (ie. everywhere between dissolution and election, getMP will return no MP unless you specify the always_return parameter (which is why that parameter exists). This has always been the case after e.g. death of MP, resignation of Iris Robinson.

Also, getMPs (note the 's') will not return any MPs for a date for which there are no MPs - so you should specify the dissolution date if you want the list of MPs as on that date (and sorry there's not an always_return option there)

Tartley