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 logging
import aiohttp
from czpubtran.api import czpubtran
logging.basicConfig(level=logging.ERROR)
async def test():
session=aiohttp.ClientSession(raise_for_status=True)
bus = czpubtran(session,'')
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('------------------------------------------------')
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.8.tar.gz
(4.1 kB
view hashes)
Built Distribution
Close
Hashes for czpubtran-0.1.8-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d7733f65b228a8e949837ad7206931769e8d247b10b6bde210b67a9685dbfb47 |
|
MD5 | 16fb8f4fb11f6f37ee50e2ec34a19661 |
|
BLAKE2b-256 | e8882fcc7b4a7950d17ba051d4f6283133cde0420c8f6acedcf6de415b825d7b |