• Our booking engine at tickets.railforums.co.uk (powered by TrainSplit) helps support the running of the forum with every ticket purchase! Find out more and ask any questions/give us feedback in this thread!

I made a REST version of the National Rail API

Status
Not open for further replies.

benmaynard

Member
Joined
12 Jan 2019
Messages
7
Hi all,

I posted on this forum a little while ago about a service I developed, and everyone was really friendly!

I enjoy spending my free time developing and architecting web applications and solutions. I previously created https://departureboard.io which offers quick and easy live train departure information for commuters. When I made this I had to interact with the National Rail SOAP API which wasn't fun, not one bit.

I decided to make a REST API interface that allows developers to quickly and easily pull information in a RESTful fashion. I have documented it over at https://api.departureboard.io and also written a post on my blog about it https://benjamin.maynard.io/departureboard-io-rest-api/.

It is a free service, I get nothing out of it other than the enjoyment of being able to run a useful service, and the satisfaction that people are using the things I create. @Mods, hope the links are ok let me know if not and I will remove them.

Really keen to see what people can create off the back of it.
 
Sponsor Post - registered members do not see these adverts; click here to register, or click here to log in
R

RailUK Forums

a_c_skinner

Established Member
Joined
21 Jun 2013
Messages
1,585
Really fascinating. Can I just observe that your departure board site doesn't take the three letter station codes that proper trainspotters type in rather than station names?
 

benmaynard

Member
Joined
12 Jan 2019
Messages
7
Really fascinating. Can I just observe that your departure board site doesn't take the three letter station codes that proper trainspotters type in rather than station names?

Thank you!!. It does! If you look at the URL https://departureboard.io/journey/HAY/PAD/ you can see the CRS codes in the URL. I just need to make the search prioritise the CRS code over the name. You can still search by CRS codes though!

upload_2019-6-20_14-25-8.png
 

Dr Hoo

Established Member
Joined
10 Nov 2015
Messages
3,970
Location
Hope Valley
Any chance of some explanation of what these abbreviations are and what this is really all about? Sadly some of us don’t have PhDs in software engineering. Thanks.
 

takno

Established Member
Joined
9 Jul 2016
Messages
5,067
Any chance of some explanation of what these abbreviations are and what this is really all about? Sadly some of us don’t have PhDs in software engineering. Thanks.
None of them really stand for anything very useful.

An API in this context is a way for an application or website to get information over the internet.
SOAP is a somewhat old-fashioned way of creating APIs which is particularly painful to use on websites and the like.
REST is the normal way to do it these days.

CRS is the 3-letter code for a station that you can use on sites like national rail to save typing the full name

A URL is a web address
 

benmaynard

Member
Joined
12 Jan 2019
Messages
7
Any chance of some explanation of what these abbreviations are and what this is really all about? Sadly some of us don’t have PhDs in software engineering. Thanks.

Sure, takno did a good job of explaining.

National Rail provide a range of data that can be accessed by developers, everything from train departures, arrivals, calling points and delay reasons. The only issue is that they provide it in a format that isn't too friendly for developers to interact with. My project has been to make it a little easier for developers to consume rail information so they can make cool and useful applications a little easier!

Developers can make queries to my API (Application Programming Interface) in a simpler way, and my application handles the complexity of actually asking National Rail for that data. As an example if you browse to https://api.departureboard.io/api/v1.0/getStationDetailsByCRS/PBO/ you will see a range of information on the Peterborough Station. You've just made an API call. By replacing the last 3 letters with any station code in the UK you will get information on that station. It isn't too friendly to read, but it is pretty easy for developers to consume that information and make for example a train station lookup website.

Another example is if you browse to https://api.departureboard.io/api/v1.0/getStationBasicInfo/?station=London , this will return all UK train stations with London in their name. You can change the part after ?station= with any station name or CRS (three letter code like KGX for London Kings Cross) and it will return stations that match. A developer might use this to make a station search box.

Typically interacting with SOAP (which is a format that National Rail use to query and provide information isn't too easy), so before developers can actually start on making something cool and useful, they have to start work on interacting with National Rail in a legacy way. Whereas with my tool I've done the legwork and developers can pick up right from the "make something cool" part.

Hope that explains, and apologies for going in with too many acronyms!
 

Dr Hoo

Established Member
Joined
10 Nov 2015
Messages
3,970
Location
Hope Valley
Sure, takno did a good job of explaining.

[SNIP]

Hope that explains, and apologies for going in with too many acronyms!

Yeah, thanks. Glad to know that some people are making things easier for some other people about something. That's what life should be all about. Still totally overawed really but at least I get how the departure board thingy works.
 
Status
Not open for further replies.

Top