Hi I was playing with some scripts to get crowding data and manipulate how it was displayed but I keep getting a isFound = False return. I used the gov website for naptan download, used area code 490 for Greater London and then just picked some random naptan codes to feed into the TFL API. If I however try out these codes I found on a github repo they ones work: ZackaryH8/tube-naptan/blob/master/data/naptan.csv
They seem to be of a different format from what i got on the gov site.
Can someone tell me if I am looking for the naptan ids in the wrong place/wrong way?
example code that works from Repo: 940GZZLUCHX
example code from gov site that doesn’t: 92073 (49029073 doesn’t either)
Hi @taulpom, @briantist this is an excellent question. I’m struggling with it too, as there’s definitely a discrepancy between TFL rest API requirements and Naptan gov file. It’s also not entirely clear what they mean by Naptan code (it would be nice if there was some documentation on this).
@briantist, thanks for the reply, at least it’s now clear how to create this Naptan code manually (not the easiest way). This is only relevant for metro stations, right? But what about the rest of Naptan (the official file you sent has over 450,000 Naptan points)? So if the API (APIs: Details - Transport for London - API) can work with any Naptan, that would give a much more accurate resolution than just metro stations. And since there are no corresponding Naptan API codes in this gov file, this file becomes useless.
So as far as I understand, @taulpom’s question is still valid, and I’d really like to hear comments on this that might give some insight into where the Naptan code is coming from.
This is of the type MKD (On-street Bus / Coach Stop) in the NaPTAN 940 dataset. In the DfT’s data, the SMS code seems to be captured as NaptanCode, whereas we use the AtcoCode as the identifier in our API under naptanId in the Unified API.
Thanks for such a quick reply. Now it’s clear to me that API supports not only tube. But it’s still not clear where I can find Naptan points with their description and code. You wrote that “In the DfT’s data, the SMS code seems to be captured as NaptanCode” but in DfT’s data there is no field like SMS code or smth like that. Also you wrote that you use ATCOCode as naptanId Unified API but if you take any ATCOCode from DfT’s file and try to call Unified API (crowding API) so you will always receive no data (“isFound”: false).
Btw, may be this is the terminology problem? You just wrote naptanId but throughout the documentation it is NaptanCode (both in the description of Unified API and field name in the DfL’s file).
If only it was just the tube, our jobs would be a lot easier!
Apologies I misread it that code!
Essentially the mapping is as follows:
UAPI
DfT
naptanId
AtcoCode
smsCode
NaptanCode
We take naptanId from the DfT for the datasets provided. The smsCode is taken from our internal systems for bus data. This doesn’t appear as data in the 910, 930 or 940 DfT datasets.
Thank you very much for your response.According to your answer we can use additional StopPont UAPI for extraction naptanId and after that use that naptanId as Naptan parameter in Crowding UAPI.
I just want to highlight again that ATCOCode in DfT data is not the same that Naptan parameter in Crowding UAPI. I just pick 5 random (for tube stations) examples from DfT and checked that. For instance let’s check “Canary Wharf Underground Station”: for that station ATCOCode from DfT data is 490000038F, so I use that ATCOCode as Naptan parameter in Crowding UAPI and it can not find that data for that Naptan parameter.
This scheme will definitely work. We can just query all stations we need in StopPont UAPI and after that put it as a parameter into Crowding UAPI. We can use stationNaptan entity (not naptanId) from StopPont UAPI as Naptan parameter in Crowding UAPI. I knew there was a problem with the terminology.
Hi @Golda
Hate to confuse matters further but 490000038F is the ATCOCode/naptanid for a bus stop at Canary Wharf Bus Station, with smscode 76008. Right now I can see buses from five different routes due in the next half hour.
The code for the station itself must be something different but others are better placed to advise for that specific case and - presumably the endgame here? - to extract a definitive list of codes for the stations from TfL’s own data.
Sorry, I can’t understand your question (could you please clarify?). My initial problem was: Where should I find Naptan code parameters for Crowding UAPI. Now as I see we can extract those parameters from another StopPoint UAPI
I think the only question I asked was answered in your post immediately above mine, which I hadn’t seen as it was made at much the same time. The main point I was making was that most codes with “station” in their description related to adjacent bus stops rather than the station entities themselves.
Hi @mjcarchive.
Okay. Got it.
Also want to add to my previous message that not all ** stationNaptan** codes from StopPont UAPI might be found in Crowding UAPI . But anyway according to the list of existing modes and data from StopPont UAPI there are 44450 Naptan points which is much more then in file ZackaryH8/tube-naptan/blob/master/data/naptan.csv.
Sorry to bother you, but I still can’t get my problem sorted out.
Let me spell it out formally again: I want to create a static database for all the UK transport types that are possible (bus, elizabeth-line, tube, etc), which would consist of: Station/stop name, station/stop coordinates, station/stop occupancy by day of week (json).
For this I did the following:
Collected all possible modes (via this endpoint https://api.tfl.gov.uk/StopPoint/Meta/Modes) - and I got a list of [‘bus’, ‘cable-car’, ‘coach’, ‘cycle’, ‘cycle-hire’, ‘dlr’, ‘elizabeth-line’, ‘interchange-keep-sitting’, ‘interchange-secure’, ‘national-rail’, ‘overground’, ‘replacement-bus’, ‘river-bus’, ‘river-tour’, ‘taxi’, ‘tram’, ‘tube’, ‘walking’]
Using this list from point 1, I compiled a complete list of StopPoints (via this endpoint https://api.tfl.gov.uk/StopPoint/Mode/) and I got a table of 44450 elements with columns “commonName”, “naptanId”, “stationNaptan”, “lat”, “lon”.
By this list from point 2, I wanted to collect crowding data of these StopPoints (through this endpoint https://api.tfl.gov.uk/crowding/Naptan) and under Naptan I independently used both naptanId and stationNaptan.