Without being tied to a lineID. I’d like to get all the tube stations and their arrival info. I’m already able to retrieve them here:
https://api.tfl.gov.uk/swagger/ui/index.html?url=/swagger/docs/v1#!/Line/Line_StopPoints
However, this Url doesn’t work:
https://api.tfl.gov.uk/swagger/ui/index.html?url=/swagger/docs/v1#!/Mode/Mode_Arrivals
Thank you in advance.
@Kupod5uR
I’m sure I’ve said this before. Use the status call to get a list of line ids (it’s a comma separated list)…
https://api.tfl.gov.uk/line/mode/tube,overground,dlr,tflrail/status
and then loop though them using line/linename/arrivals
https://api.tfl.gov.uk/line/london-overground/arrivals
1 Like
I edited my OP. I’m able to get all the overground stations. Yes, I’ve used this url:
https://api.tfl.gov.uk/line/london-overground/arrivals
I was wondering if was possible to get all the tube stations arrivals in one url without using the lineId.
@Kupod5uR
No, thus my answer to use a loop.
$arrOut = [];
foreach (json_decode(file_get_contents("https://api.tfl.gov.uk/line/mode/tube/status")) as $line) {
$arrOut[$line->id] = json_decode(file_get_contents("https://api.tfl.gov.uk/line/{$line->id}/arrivals"));
}
var_dump($arrOut);
Done!