Giter Site home page Giter Site logo

kaycee-okoye / nextbus_api_parser Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 45 KB

A simple and efficient python project for interacting with the NextBus API, which offers public transit information. The author's primary goal is to provide a valuable reference that can save you time and effort in your future projects.

License: MIT License

Python 100.00%
api bus-tracking command-line-tool nextbus public-api public-transport python3 trip-planning xml-parsing package

nextbus_api_parser's Introduction

NextBus API Python Parser

This Python package provides a simple and efficient way to interact with the NextBus API, which offers information on bus agencies, bus routes, bus stops, bus paths, and bus predictions in the United States. The repository includes four essential files:

  1. api_handler.py: This module acts as a controller for making API calls to the NextBus API. It also handles the parsing of API responses into appropriate model classes.

  2. data_classes.py: This module contains the model data classes used to represent and handle data parsed from the NextBus API. These classes help structure the data for easier manipulation and usage within your applications.

  3. xml_handler.py: The XML handler module includes classes that inherit from xml.sax.ContentHandler. These classes are responsible for parsing XML feeds from the NextBus API and transforming the data into the corresponding model classes.

  4. nextbus_predictor.py: This module implements a command-line interface (CLI) for requesting and displaying bus predictions for a selected bus stop along a selected route within a chosen bus agency. This module serves as a practical example of how to use the other components to interact with the NextBus API.

API documentation: https://retro.umoiq.com/xmlFeedDocs/NextBusXMLFeed.pdf

Getting Started

To get started with this project, follow these steps:

  1. Install the package to your local machine:

    pip install --upgrade pip
    pip install https://github.com/kaycee-okoye/nextbus_api_parser.git
  2. You can now use the provided command-line interface (CLI) to interact with the NextBus API and retrieve bus predictions.

Usage

The nextbus_predictor.py script provides a user-friendly CLI for interacting with the NextBus API. Here's how to use it:

python nextbus_predictor.py # you might need to provide the absolute path to this file

Follow the prompts to select a bus agency, route, and bus stop. The script will then fetch and display bus predictions for the chosen stop along the selected route.

Example

Welcome to the NextBus API Python Parser CLI!

Please select a bus agency:
1. Agency A
2. Agency B
3. Agency C
...

Enter your choice (1-10): 2

Please select a bus route:
1. Route X
2. Route Y
3. Route Z
...

Enter your choice (1-5): 1

Please select a bus stop:
1. Stop 1
2. Stop 2
3. Stop 3
...

Enter your choice (1-20): 3

Bus predictions for Route Y - Stop 3 (Agency B):

1. Prediction 1: Next bus in 5 minutes
2. Prediction 2: Next bus in 12 minutes
3. Prediction 3: Next bus in 20 minutes
...

Thank you for using the NextBus API Python Parser CLI!

Contributions Guidelines

Please read Contribution Guidelines for details on the author's code of conduct, and contribution guidelines.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Acknowledgments

Special thanks to the NextBus API team for providing access to real-time bus information, making public transportation more accessible to everyone.

Happy coding!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.