Skip to content

cpparnell/ctabustracker-v2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CTA Bus Tracker API Wrapper

A simple Python 3 client for the Chicago Transit Authority (CTA) Bus Tracker API. This library wraps common endpoints, providing a straightforward way to query real-time bus information such as routes, directions, stops, and predictions.

Features

  • Fetch current system time from CTA Bus Tracker
  • Get vehicles by route or vehicle ID
  • Get predictions by stop ID, vehicle ID, or route
  • List all currently enabled routes
  • Retrieve directions for a route
  • Retrieve stops for a route + direction
  • Retrieve patterns (geospatial paths)
  • Retrieve service bulletins

Requirements

  • Python 3.7+

Installation

pip install ctabustracker-api-v2

Usage

YOUR_CTA_API_KEY = "YOUR_API_KEY_HERE"
cta_client = CTABusTrackerAPI(YOUR_CTA_API_KEY)

# Get system time
time_response = cta_client.get_time()
print("System Time:", time_response)

# Get all routes
routes_response = cta_client.get_routes()
print("All Routes:", routes_response)

# Example: get directions for route #22
directions_response = cta_client.get_directions("22")
print("Directions for Route 22:", directions_response)

# Example: get stops for route #22, Eastbound
stops_response = cta_client.get_stops("22", "Eastbound")
print("Stops for Route 22 Eastbound:", stops_response)

# Example: get predictions for stop(s)
# (Replace 'STOP_ID' with a valid stop ID from above stops_response)
predictions_response = cta_client.get_predictions(stpid=["STOP_ID"])
print("Predictions for STOP_ID:", predictions_response)

About

Python 3 wrapper of the CTA's Bus Tracker API (v2)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages