Calling CHAPS REST API to get information about public transit in CZ
Project description
CzPubTran
A Python package to rertrieve realtime information about public transit in CZ by calling CHAPS REST API.
Main purpose at the moment is to feed a sensor in Home-Assistant
Install
pip install czpubtran
Example usage
import asyncio
import aiohttp
from czpubtran.api import czpubtran
async def test():
session=aiohttp.ClientSession(raise_for_status=True)
bus = czpubtran(session,'')
timetables = await bus.async_list_combination_ids()
print("Listing available timetables (Combination IDs)")
print(timetables)
print('------------------------------------------------')
await bus.async_find_connection('Chyne, Haje','Ortenovo namesti','ABCz')
print(f'Connection from {bus.origin} to {bus.destination} using timetable {bus.combination_id}:')
print(f'Departure: {bus.departure} line {bus.line}')
print(f'Duration: {bus.duration}')
print('Connections:')
for connection in bus.connections:
print(f"line {connection['line']} "
f"at {connection['depTime']} "
f"from {connection['depStation']} "
f"-> {connection['arrStation']} "
f"{connection['arrTime']} "
f"(delay: {connection['delay']} min)")
await session.close()
asyncio.run(test())```
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
czpubtran-0.1.11.tar.gz
(4.4 kB
view hashes)
Built Distribution
Close
Hashes for czpubtran-0.1.11-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 29f27c86c1643d5a8dfc3de3eaecc21b81f72fe2c4c161fef83cf6830d7f6502 |
|
MD5 | bac14a3b412e6628a94e8cfca98c0719 |
|
BLAKE2b-256 | 0ffb8a0fa3fc46cc93df25cde45cceb43d01ea684741f15283fa51cafa5bffd9 |