Friday, 5 March 2010

Sharing is Caring - JSON now available

One of the reasons that YourNextMP.com was created was because there was no central list of candidates. So we created one.

But we don't want anyone to duplicate our efforts collecting the candidate information - we'd rather that they were doing something interesting with the data instead. So almost all the data we have is now available under a Creative Commons license as JSON endpoints.

At the bottom of most pages you will now see a little 'json' link. If you click on it you will get the same data that we used to create the page in the JSON format which you can easily read into your code and do things with.

We've chosen the CC by-nc-sa license - which means that you must attribute where you got the data from, you can't use it commercially and you have to apply this same license to the work that you produce. Hopefully this is liberal enough for most people. If it isn't please contact us and we'll see what we can do.

UPDATE: we're now using the 'by-sa' license - we dropped the 'nc'.

Hopefully the data structure we've used is fairly self-explanatory. Documentation will be appearing on the site soon.

Let us know what you create with it!

6 comments:

  1. We love you so very, very much. :)

    ReplyDelete
  2. oooh smashing, just what I was looking for. Any chance of a json list of all the seats? Or list of the seat URL portions in any format really.

    ReplyDelete
  3. wow! json on the seats and all the candidate info at the constituency level :-) thanks!

    ReplyDelete
  4. any chance of getting the wikipedia URL in the constituency json? Also it would be rather splendid to have country and county in the data too.

    ReplyDelete
  5. Great work. Minor point, is it possible to get the JSON from a search query?

    I was using http://www.yournextmp.com/seats/search?query=SW1A+1AA&output=json

    That now just returns

    http://www.yournextmp.com/seats/cities_of_london_and_westminster without the "output=json" at the end.

    Regarding @alanbell's Wikipedia URL, you can just use the URL http://en.m.wikipedia.org/wiki/{$constituency}_%28UK_Parliament_constituency%29

    You can determine the constituency name from either the YNMP URL or the URI returned in the JSON.

    HTH

    T

    ReplyDelete
  6. thanks Terence, I have it all working now, I also used BeautifulSoup to parse the county from the wikipedia pages so I now have a full list by country and county.

    ReplyDelete