API Documentation¶
Using the API in other projects¶
Avgangstider requires at least Python 3.7. I recommend using pyenv for installing and managing different Python versions.
Avgangstider is available on PyPi, so inside the environment where you want Avgangstider, all you have to do is:
pip install avgangstider
Functions and classes¶
- class avgangstider.Departure(line_id: str, line_name: str, destination: str, platform: str, departure_datetime: datetime.datetime, bg_color: str, fg_color: str)¶
A data class to hold information about a departure
- property departure_string: str¶
The departure time as a string relative to now()
- class avgangstider.Situation(line_id: str, line_name: str, transport_mode: str, bg_color: str, fg_color: str, summary: str)¶
A data class to hold information about a situation
- avgangstider.get_departures(stop_id: str, line_ids: Optional[List[str]] = None, platforms: Optional[List[str]] = None, max_departures: int = 10) List[avgangstider.classes.Departure] ¶
Query the Entur API and return a list of matching departures
- Parameters
stop_id – The stop_id you want departures for
line_ids – An optional list with line_ids
platforms – An optional list with platform_ids
max_departures – The maximum number of departures to query for
- Returns
A list of departures
- avgangstider.get_situations(line_ids: List[str], language: str = 'no') List[avgangstider.classes.Situation] ¶
Query the Entur API and return a list of relevant situations
- Parameters
line_ids – A list of strings with line_ids
language – A language string: ‘en’ or ‘no’
- Returns
A list of relevant situations for that line