Huxley - Rail API Proxy


Update: Huxley 2 is out now.


I recently hosted another Cleanweb London event and the theme this time was transport. More on that later but it gave me a great excuse to start a project that I’ve been thinking of doing for a while. So I’ve made a free and open source CORS enabled JSON proxy for the National Rail Live Departure Board SOAP API (called Huxley, because reasons). For more information on the data available from the APIs see Peter Hicks’ talk (which was great BTW).

huxley

Here’s a quick demo of the next train to arrive in London from Brussels. Paste the following into your browser console (F12) to try it out. You may have to enable pasting.

var r = new XMLHttpRequest(); 
r.open("GET", "https://huxley.apphb.com/all/stp/from/bxs/1?accessToken=DA1C7740-9DA0-11E4-80E6-A920340000B1", true); 
r.onreadystatechange = function () { 
  if (r.readyState != 4 || r.status != 200) return;
  var resp = JSON.parse(r.response); 
  if (resp.trainServices && resp.trainServices.length > 0) {
    alert("The next train to arrive at " + resp.locationName + " from " + resp.filterLocationName + " will get in at " + resp.trainServices[0].sta);
  } else { 
    alert("Sorry, no trains from " + resp.filterLocationName + " arriving soon"); 
  } 
}; 
r.send();

N.B. The demo server might (and does) go down so if you want to use this then host it yourself and use your own access token.

My project focuses on making enterprise APIs easier for developers to use (which has general applications outside of just this one). WCF SOAP APIs like this are pretty tricky to get working if you’re not a Microsoft developer using Visual Studio. By changing the format to a standard approach that most developers will be familiar with it makes it easier to access the API with JavaScript, Ruby, Python and other open technologies.

The project site is at huxley.unop.uk so have a look and let me know if it’s worth continuing beyond the alpha stage. Comment here or there is a discussion on the open rail data mailing list.

Archived Comments

Dhanasekarapandian Srinivasan says:
22nd February 2016 at 8:39 pm

Good job bro. I tried myself with my access token. And got 401. What is d3 user. my token user name password starts with d3.

James says:
23rd February 2016 at 9:30 am

It looks like you are trying to use your feed token with the API. There are 3 separate systems. For Huxley you need the token you get after registering here: https://realtime.nationalrail.co.uk/OpenLDBWSRegistration/Registration. Not https://datafeeds.networkrail.co.uk.


This blog is treeware! If you found it useful then please plant a tree.
Donate a treeDonate a tree🌳🌳