Skip to main content

Bus Tracker (NextBus)

PyPI version Build Status

Python module to get bus data from NextBus

This is an ongoing project. If you have any requests or contributions, please create a ticket

Install

From PyPI with pip

pip install bustracker

Usage examples

from bustracker import BusTracker
# Agency list is from http://webservices.nextbus.com/service/publicXMLFeed?command=agencyList
agency = 'ttc'
bus = BusTracker(agency)

# get prediction for bus stops
stops = [
    {'routeTag': 506, 'stopTag': 3292}
]

predictions = bus.get_predictions(stops)

print(predictions)

The result is a dictionary of predictions

{
    "predictions": {
        "message": {
            "text": "TTC Information 416-393-4636 (INFO)",
            "priority": "Normal"
        },
        "agencyTitle": "Toronto Transit Commission",
        "routeTag": "506",
        "routeTitle": "506-Carlton",
        "direction": {
            "title": "West - 506 Carlton towards High Park",
            "prediction": [
                {
                    "isDeparture": "false",
                    "minutes": "2",
                    "seconds": "134",
                    "tripTag": "38216487",
                    "vehicle": "4189",
                    "block": "506_9_90",
                    "branch": "506",
                    "dirTag": "506_1_506",
                    "epochTime": "1563543576881"
                },
                ...
            ]
        },
        "stopTitle": "Gerrard St East At Jones Ave",
        "stopTag": "3292"
    },
    "copyright": "All data copyright Toronto Transit Commission 2019."
}

For development

Testing

pytest tests/test.py

References

NextBus Guide Get Agency List

Metadata

Release files for bustracker 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bustracker 0.0.3
File Size Uploaded
bustracker-0.0.3.tar.gz 2.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for bustracker 0.0.3
File Interpreter ABI Platform
bustracker-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 18.4 kB

Release files / bustracker-0.0.3.tar.gz

Download URL bustracker-0.0.3.tar.gz
Size 2.8 kB
Tags Source
SHA-256 checksum
How to use checksums
9784ac271f281072ea652d6cb97014504e3b2d81c58399eca1db9cd08c987416
BLAKE2b-256 checksum
How to use checksums
4c63218f025cab03da7a18389ade72935c51124c929f70094d5905a42d0d5a65
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.0

Release files / bustracker-0.0.3-py3-none-any.whl

Download URL bustracker-0.0.3-py3-none-any.whl
Size 15.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f2dfbb983b3fd2149fce5a898ed3250a54feb3eec591b1137e52a49f757bbc88
BLAKE2b-256 checksum
How to use checksums
3bb4ce39e7405aaee6dcdb66cc7401cf8a855f37abbcd4a7fbdb161b5d765822
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.0

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page