Skip to main content

Get bus predictions from NextBus

Project description

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

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

bustracker-0.0.3.tar.gz (2.8 kB view hashes)

Uploaded Source

Built Distribution

bustracker-0.0.3-py3-none-any.whl (15.6 kB view hashes)

Uploaded Python 3

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