Skip to main content

A library to get bus times from the Bus Nearby API

Project description

py-busnearby

A Python library to get bus times from the Bus Nearby API https://www.busnearby.co.il/

Installation

You can install the library from PyPI:

pip install bus_times

Alternatively, you can install it directly from the source:

git clone https://github.com/yourusername/bus_times.git
cd bus_times
pip install .

Usage

Here are some examples of how to use the library:

Get Bus Times

To get bus times for a specific station and bus lines, you can use the get_bus_times function.

from busnearby import BusNearBy
import asyncio

bus = BusNearBy()

async def main():
    station = "34501"
    bus_lines = "609,636,10,15"
    try:
        result = await bus.get_bus_times(station, bus_lines)
        print(result)
    except ValueError as e:
        print(f"Error: {e}")
    except RuntimeError as e:
        print(f"Error: {e}")

asyncio.run(main())

Example Output

{
    "stationName": "שדרות וייצמן/עקיבא",
    "time": "2024-07-22 13:10:43.974935",
    "buses": [
        {
            "lineNumber": "10",
            "arrivalSeconds": 644
        },
        {
            "lineNumber": "15",
            "arrivalSeconds": 1501
        },
        {
            "lineNumber": "609",
            "arrivalSeconds": 2210
        },
        {
            "lineNumber": "636",
            "arrivalSeconds": 3532
        },
        {
            "lineNumber": "636",
            "arrivalSeconds": 6728
        }
    ]
}

Contributing

Contributions are welcome! Please open an issue or submit a pull request on GitHub.

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

busnearby-0.1.2.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

busnearby-0.1.2-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: busnearby-0.1.2.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for busnearby-0.1.2.tar.gz
Algorithm Hash digest
SHA256 24ea435b19fe1f89a9d465b11d84230945c0c8a941cdaf292325a652f93776b6
MD5 327ed5b00030cfe389922793376cfc72
BLAKE2b-256 ea687a401d6c9ae15b48159bd6aa5412126122ed3e420987af07e06576d2d9ae

See more details on using hashes here.

File details

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

File metadata

  • Download URL: busnearby-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for busnearby-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f104db62dac0235a575b383ca9a18b44a3cc572fb6fefb2f3926cad524a7e870
MD5 94c65229aaf311cdcb2cf99dcf5b3cb7
BLAKE2b-256 65dbbcac1b3e1b679cd7b2d8afd650f985330936f4bec7d51c89758f4f01a215

See more details on using hashes here.

Supported by

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