Access to Countdown API

Hi all

I wold like to make a web page where I can have the next bus arriving information for local bus stop I can not seam to find any information on this. this will be for a locally hosted webserver.

Any advice welcome

Hunter Errington

Welcome @HunterErrington

Here’s a couple of code fragments to point you in the right direction

How to find the location of bus stops nears a given place…

    public const URL = "$$$$$&stopTypes=NaptanPublicBusCoachTram&radius=600&useStopPointHierarchy=True&returnLines=True&";
    [$this->fpLat, $this->fpLong] = preg_split("/,/", $this->getLatLong($this->strTLA));
    $strURL = strtr(self::URL, ["______" => $this->fpLat, "$$$$$" => $this->fpLong]) . ApiConfig::TFLAPISUFFIX; 

And you get the live bus info this way…

    public function getBusStopFiltered($strStopPoint, $indicator): array
    $strTFLurl = "$strStopPoint/Arrivals?" . ApiConfig::TFLAPISUFFIX;
    $strRetrieved = $this->cacheTFLcall($strTFLurl, self::BUSSTOPCACHETIME);
    $objTemp = json_decode($strRetrieved);
    $arrSorted = [];
        foreach ($objTemp as $objBuses) {
            $arrSorted[$objBuses->timeToStation * 1000 + intval($objBuses->lineId)] = [
                "route" => $objBuses->lineId,
                "destination" => self::cleandestinationName($objBuses->destinationName),
                "mins" => round($objBuses->timeToStation / 60),
                "stop" => strtr($indicator, ["Stop " => ""])];
    return $arrSorted;