A simple API wrapper in Swift for NextBus transit information.
Initialize a transit Agency:
letagency=Agency(tag:"sf-muni", title:"San Francisco Municipal Railway", regionTitle:"California-Northern")Get an Agency's routes:
do{letnJudah=try agency.routes().filter({ $0.tag =="N"})}catch{fatalError()}Get Predictions for a Stop:
do{letpowellOutbound=Stop(agency: agency, stopTag:"6995", title:"Powell Station Outbound", location:(37.7843,-122.4078199), stopId:"16995")let(predictions, _)=try powellOutbound.predictions()}catch{fatalError()}Unless otherwise marked, calls should be assumed to be synchronous. It's a good idea to dispatch to a background queue, query routes/stops, then dispatch back to main when you're ready to update your UI.