Add your description here
Project description
Serbia Bus API
Serbia Bus API (srbusapi) is a Python package that provides access to real-time bus arrival data for major cities in Serbia, including Belgrade, Novi Sad, and Niš. It is based on a reversed-engineered API extracted from mobile bus applications, allowing developers to retrieve bus station details, arrival times, and route information efficiently.
Features
- Retrieve real-time bus arrivals for stations in Belgrade, Novi Sad, and Niš.
- Fetch route details and versions for specific bus lines.
- Caching support via Redis for optimized API calls.
- AES encryption for secure communication with APIs.
- Asynchronous support using
httpx.
Installation
Install srbusapi via pip:
pip install srbusapi
For Redis caching support, install with:
pip install srbusapi[redis]
Usage
Initialize a Client
To use the API, import the desired city client and fetch data:
import asyncio
from srbusapi import BeogradClient
async def main():
client = BeogradClient()
# Fetch station details
stations = await client.get_stations() # Returns a list of stations explore this to see ids for stations
print(stations)
# Fetch arrivals for a specific station
arrivals = await client.get_arrivals(station_id="20493")
print(arrivals)
if __name__ == "__main__":
asyncio.run(main())
Using Redis Cache
If you have Redis set up, provide the credentials via environment variables:
export REDIS_HOST=localhost # Put your redis host here
export REDIS_PORT=6379 # Put your redis port here
export REDIS_USERNAME=yourusername # Optional
export REDIS_PASSWORD=yourpassword # Optional
import asyncio
from srbusapi import BeogradClient, RedisCache
async def main():
cache = RedisCache(
host="localhost", # Put your redis host here
port=6379, # Put your redis port here
username="yourusername", # Optional
password="yourpassword" # Optional
)
client = BeogradClient(cache=cache)
stations = await client.get_stations()
print(stations)
if __name__ == "__main__":
asyncio.run(main())
API Methods
General Methods (Available in all city clients)
get_stations() -> dict- Retrieve station information.get_arrivals(station_id: str) -> dict- Fetch bus arrival times.get_route(actual_line_number: str) -> dict- Get route details for a bus line.get_route_version(actual_line_number: str) -> dict- Fetch the latest route version.
City-Specific Clients
| City | Client Class |
|---|---|
| Belgrade | BeogradClient |
| Novi Sad | NoviSadClient |
| Niš | NisClient |
Contributing
Contributions are welcome! Please submit issues and pull requests on GitHub.
License
This project is licensed under the MIT License. See the LICENSE file for details.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file srbusapi-0.1.3.tar.gz.
File metadata
- Download URL: srbusapi-0.1.3.tar.gz
- Upload date:
- Size: 26.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ecde5c461c850407226c0beefd5a676b30f92044aec9dcd9de7a24317dc2cb4
|
|
| MD5 |
786f8a01520a6478a6ade1a8adb190e7
|
|
| BLAKE2b-256 |
1063294d1282657fa37e9a1ad1fcf668806d6f709dad980436c18f1c69ee1492
|
File details
Details for the file srbusapi-0.1.3-py3-none-any.whl.
File metadata
- Download URL: srbusapi-0.1.3-py3-none-any.whl
- Upload date:
- Size: 14.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1811ddf07ff3cd2e380177603b7ab69914efc6b6d2e35283e49ea0abc9908b52
|
|
| MD5 |
be52770a25871da9b6eb3ffe026f7c85
|
|
| BLAKE2b-256 |
5dc08709244a2cc2a6f7b7c0667fed4a9c0f5454221b1eea3c4d05062c86d469
|