Skip to main content

Add your description here

Project description

Serbia Bus API

Python Version from PEP 621 TOML License

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

srbusapi-0.1.2.tar.gz (28.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

srbusapi-0.1.2-py3-none-any.whl (20.8 kB view details)

Uploaded Python 3

File details

Details for the file srbusapi-0.1.2.tar.gz.

File metadata

  • Download URL: srbusapi-0.1.2.tar.gz
  • Upload date:
  • Size: 28.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.21

File hashes

Hashes for srbusapi-0.1.2.tar.gz
Algorithm Hash digest
SHA256 b9c080e6b9ead283a303c53c97a1cc89104cf304802f8ca1d767ba85ec504b2f
MD5 8fd3563275689c43e3014b8d0c618d57
BLAKE2b-256 cd33c1ceed0f74c14e599fa5e4c0b07cb48ca1bf8de21233585f20720f80c926

See more details on using hashes here.

File details

Details for the file srbusapi-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: srbusapi-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 20.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.21

File hashes

Hashes for srbusapi-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 827de204aa85eee1cfc6f96757e0cc18e59013b17eeff6c3f85f6dc002ab172a
MD5 3ce8cab39b303e919b8a7e7a1aa9b3f1
BLAKE2b-256 fbbedc5ba8cc810a5d1c040534bd565bbe424882dcf8a5a08b0a93de849f9817

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page