Chicago Transit Authority API
The CTA has three public endpoints for tracking CTA trains. This client supports those endpoints.
The CTAClient has methods for each endpoints. Namely,
- arrivals: Arrival information for a given station(s) or stop(s).
- follow: Follow specific train by runnumber.
- locations: Get all trains for a given route(s).
More endpoint specific documentation found here
This API requires a key which can be easily received here.
Follow the .env.example file for setting.
Installation
This package is available on pip. Install with:
$ pip install python-cta
Getting Started
from cta import CTAClient
damen_blue_line_mapid = 40590
# Get arrival information for damen blue line station.
cta_client = CTAClient()
arrival_response = cta_client.arrivals(mapid=damen_blue_line_mapid)
df_arrivals = arrival_response.to_frame()
print(df_arrivals)
# Follow specific train
runnumber = df_arrivals["rn"].tolist()[0]
follow_response = cta_client.follow(runnumber=runnumber)
df_follow = follow_response.to_frame()
print(df_follow)
from cta import Route
# Get the location of all Blue Line trains.
location_response = cta_client.locations(Route.BLUE)
df_locations = location_response.to_frame()
print(df_locations)
# Or all trains on the track
location_response = cta_client.locations(route=[route for route in Route])
df_locations = location_response.to_frame()
print(df_locations)
Information about the stations can be found with the Stations class. Below is an
example to find the mapid for Damen blue line.
from cta import Stations
stations = Stations()
df_stations = stations.data
print(df_stations)
df_damen = stations.lookup("Damen", route=Route.BLUE)
print(df_damen)
Try this example for yourself in scripts/readme_example.py
Metadata
Release files for python-cta 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| python-cta-0.0.2.tar.gz | 5.4 kB | Without provenance | Details for python-cta-0.0.2.tar.gz |
Release files / python-cta-0.0.2.tar.gz
| Download URL | python-cta-0.0.2.tar.gz |
|---|---|
| Size | 5.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0fe3f1af84b2e71dc7ab980ed00ca66dd49ccbd902378c6e6bf133bd76bee97d
|
|
BLAKE2b-256 checksum How to use checksums |
e92609ddf49135f0ea2272814815f43aff19e62953cf3bca6b23dda2a3405ec4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.9.9
|
Security for python-cta 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.