Metadata-Version: 2.4
Name: bizkaibus
Version: 1.1.2
Summary: Online information for buses of Biscay bus services (Basque Country, Spain).
Author-email: Ugaitz Etxebarria <etxeba17@gmail.com>
License-Expression: MIT
Project-URL: Homepage, https://github.com/UgaitzEtxebarria/BizkaibusRTPI
Project-URL: Source, https://github.com/UgaitzEtxebarria/BizkaibusRTPI
Project-URL: Download, https://github.com/UgaitzEtxebarria/BizkaibusRTPI/archive/refs/tags/v1.1.2.tar.gz
Keywords: Bizkaibus,Bizkaia,Autobusa,rtpi,buses
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Libraries
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: LICENSE.txt
Requires-Dist: aiohttp>=3.14
Provides-Extra: dev
Requires-Dist: black>=24.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.23; extra == "dev"
Requires-Dist: pytest>=8.0; extra == "dev"
Requires-Dist: ruff>=0.5; extra == "dev"
Dynamic: license-file

# BizkaibusRTPI

Async client to query real-time information of Bizkaibus buses.

## Installation

```bash
pip install bizkaibus
```

## Basic usage

```python
import asyncio

from bizkaibus import BizkaibusAPI
from bizkaibus.Model.BizkaibusLanguages import BizkaibusLanguages


async def main():
    api = await BizkaibusAPI.create(BizkaibusLanguages.EU, "0296")
    async with api:
        timetable = await api.get_timetable()
        print(timetable)

asyncio.run(main())
```

## Get lines for a stop

```python
async def main():
    api = await BizkaibusAPI.create(BizkaibusLanguages.ES, "0296")
    async with api:
        lines = await api.get_lines_on_stop()
        for line in lines:
            print(line)
```

## Error handling

The client raises the following exceptions, all available from `bizkaibus`:

- `BizkaibusConnectionError` when a request times out, cannot connect, receives a non-200 HTTP status, or the service reports a failure.
- `BizkaibusStopNotFoundError` when the requested stop does not exist.
- `BizkaibusParseError` when the service returns malformed or unexpected data.

```python
from bizkaibus import (
    BizkaibusConnectionError,
    BizkaibusParseError,
    BizkaibusStopNotFoundError,
)

try:
    api = await BizkaibusAPI.create(BizkaibusLanguages.EU, "0296")
    async with api:
        timetable = await api.get_timetable()
except BizkaibusStopNotFoundError:
    print("The requested stop does not exist")
except BizkaibusConnectionError:
    print("Could not contact the Bizkaibus service")
except BizkaibusParseError:
    print("The Bizkaibus service returned an invalid response")
```

## Features

- Stop timetable lookup
- Stop line lookup
- Incident retrieval by language
- Async support with `asyncio` and `aiohttp`

## Development

```bash
python -m venv .venv
source .venv/bin/activate
pip install -e .[dev]
pytest
```

## License

MIT
