• Our new ticketing site is now live! Using either this or the original site (both 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!

API for headcode lookup

Status
Not open for further replies.

jumbo_t

Member
Joined
4 Oct 2023
Messages
14
Location
UK
Apologies if a similar question has been posted here before.

I'm looking for an online API which I can use to programmatically look up schedule/train info from a headcode (basically the same as how rail-record.co.uk works).

Is anyone aware of a website providing this service or one which can be "massaged" to do so? I am aware of National Rail data feeds but it seems that these are not publicly accessible without an application.

Cheers!
 
Sponsor Post - registered members do not see these adverts; click here to register, or click here to log in
R

RailUK Forums

Freightmaster

Verified Rep
Joined
7 Jul 2009
Messages
4,429
Apologies if a similar question has been posted here before.

I'm looking for an online API which I can use to programmatically look up schedule/train info from a headcode
The problem with that is that many (most?) headcodes apply to more than one train, so you need
to pass/retrieve more information, such as originating STANOX, time of departure, etc, to enable
your lookup query to reliably fetch the correct schedule.



MARK
 
Last edited:

jumbo_t

Member
Joined
4 Oct 2023
Messages
14
Location
UK
Hi Mark - thanks for the heads up on this. In my use case, I will have clarifying information about the specific train I'm looking for, so this shouldn't be an issue.

What I am really looking for is something which provides a programmatic interface to the sort of data available on realtimetrains.co.uk and rail-record.co.uk. Both of these sites return webpages with the data rather than the raw info itself. At a push, I could of course write a scraper for the HTML which you get from running a query, but this would be an ugly solution and I'm hoping that there is a more elegant one out there.
 
Last edited:

trainmania100

Established Member
Joined
8 Nov 2015
Messages
3,032
Location
Newhaven
I'm sure realtimetrains was doing an upgraded API for his website so maybe it's something that could be offered through there.
 

jumbo_t

Member
Joined
4 Oct 2023
Messages
14
Location
UK
Hi Matt - Realtimetrains does offer an API (see https://www.realtimetrains.co.uk/about/developer/) but it only offers searches by station (i.e. departures and arrivals), not a generic service lookup by headcode. There is some mention of a "detailed" API mode, which I guess could allow this kinds of lookups, but there doesn't seem to be much information about this.

== Doublepost prevention - post automatically merged: ==

In the end I've settled on grabbing the relevant page from one of the aforementioned websites and am using BeautifulSoup (Python HTML processing library) to extract the information I need. It's a bodge, but it does the job.
 
Last edited:
Status
Not open for further replies.

Top