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.5.tar.gz
(4.1 kB
view hashes)
Built Distribution
Close
Hashes for czpubtran-0.1.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d7853f785691aa0c6f0359ee9614ff7e31d402ec5485865fc93ec47b5b1fb99 |
|
MD5 | b0f8c74c338ea64825de8d53b85d7385 |
|
BLAKE2b-256 | 9768e6f44a28993d447e6fdbcf16e12b534db8bf8ca09b4c6d7c9001ba2b8f52 |