Station Information
Similarly to when working with the various lines on the tube network, it is easier to work with an index rather than a string when referring to stations. As such, the Station Information service exists to allow for the translation of human-readable names to the unique indices that identify the stations, and vice-versa. This service also provides the location (latitude/longitude in degrees) of the stations, which may be helpful for visualisation purposes.
The service can be used to retrieve information about the individual stations; by providing either the name of the station, or the station index that the backend uses.
Regardless of which input is provided, the response is a csv file with four keys; "station name
", "station index
", "latitude
", "longitude
", which are of type str
, int
, float
and float
respectively.
If you provide a (mixed) sequence of indices or names, the service will return the corresponding information for each station - removing duplicates if necessary.
You may also provide "all
" as the identifier, in which case the response will contain the above information about every station in the network.
Keep in mind that pulling the entire table of stations only to use information about a few of them is not an efficient use of resources!
Querying
Query for the information about the stations X, Y, and Z:
stations/query?id=X,Y,Z
stations/query?id=X&id=Y&id=Z
stations/query?id=X,Y&id=Z
Query for the information about all stations in the tube network:
stations/query?id=all
Parameters
id
: A series of values consisting of (a mixture of) station indices and station names (case-insensitive). Information will be retrieved for each unique station, and will be returned sorted by the station index. Defaults to0
(acton town
).
Examples
https://rse-with-python.arc.ucl.ac.uk/londontube-service/stations/query?id=0,1,2,3
- fetch information about stations with index 0, 1, 2, and 3.https://rse-with-python.arc.ucl.ac.uk/londontube-service/stations/query?id=0,highgate
- fetch information about the station with index 0, and the station whose name matches "highgate".https://rse-with-python.arc.ucl.ac.uk/londontube-service/stations/query?id=0&id=highgate
- same as the example above, alternative syntax.
Return format
The service will return a .csv
file with headers where each row contains the following information about the requested stations:
station index, station name, latitude, longitude
Values in the columns are (respectively) of type int
, str
, float
, and float
.