This package allow to fetch data from API provided by "UM Warszawa" - https://api.um.warszawa.pl/
- Fetch ZTM buses and trams real-time location
- Fetch Schedule for bus stop for certain bus line
pip install warsaw-data-api
We can fetch all location data for buses:
import warsaw_data_api
ztm = warsaw_data_api.ztm(apikey='your_api_key') # you can get API KEY on the https://api.um.warszawa.pl/ after you register
buses = ztm.get_buses_location()
for bus in buses:
print(bus)
We can do the same for trams, as a parameter we can set number of tram line
import warsaw_data_api
ztm = warsaw_data_api.ztm(apikey='your_api_key')
trams = ztm.get_trams_location(line=17)
for tram in trams:
print(tram)
We can fetch schedule by using bus stop id:
import warsaw_data_api
ztm = warsaw_data_api.ztm(apikey='your_api_key')
schedule = ztm.get_bus_stop_schedule_by_id(7009, "01", "182")
print(schedule)
or we can fetch it by using bus stop name:
import warsaw_data_api
ztm = warsaw_data_api.ztm(apikey='your_api_key')
schedule = ztm.get_bus_stop_schedule_by_name("Marszałkowska", "01", "182")
print(schedule)
We can pass API Key in two different ways:
- Pass API Key to factory function (
ztm()
in this case) as a parameterztm = warsaw_data_api.ztm(apikey='your_api_key')
- Create environment variable called
WARSAW_DATA_API_KEY