-
Notifications
You must be signed in to change notification settings - Fork 1
Home
Evan Ugarte edited this page Jun 10, 2024
·
1 revision
Welcome to the SCEta wiki!
- find a stop id for a VTA bus stop near school
- go on the 511 open data documentation and find the correct url to get stop predictions
- open the url in the browser, make sure you use your api key in the url, there should be a response with the transit predictions
- using the above url, make an HTTP request in python
- parse the JSON response with python, print out the below
- the name of the stop
- each route and its upcoming arrival times
- try following along this https://www.youtube.com/watch?v=9B9CdKANjnM
- use dataclass to store the response from the API, like
from dataclass import dataclass
import typing
@dataclass
class Prediction:
route: str
times: typing.List[str]
@dataclass
class Stop:
id: str
name: str
prediction: typing.List[Prediction]
p1 = Prediction(
"66",
[
"2023-12-28T01:36:02Z",
"2023-12-28T01:54:35Z",
"2023-12-28T02:11:46Z",
]
)
p2 = Prediction(
"68",
[
"2023-12-28T01:49:19Z",
"2023-12-28T02:00:27Z",
"2023-12-28T02:19:29Z",
]
)
s = Stop("63211", "1st & Reed", [p1, p2])
print(s)
- the
Stop
object will hold the stop id, stop name, and list of predictions - a prediction will hold the route name and array of timestamps for when the bus is arriving