{"id":16586700,"url":"https://github.com/wd60622/cta","last_synced_at":"2025-03-06T08:16:05.356Z","repository":{"id":57679730,"uuid":"459339736","full_name":"wd60622/cta","owner":"wd60622","description":"Python Client for Chicago Transit Authority ","archived":false,"fork":false,"pushed_at":"2023-03-04T10:53:29.000Z","size":27,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-22T12:20:06.667Z","etag":null,"topics":["chicago","chicago-data-portal","chicago-transit-authority","cta","mobility-data","public-transportation","python","python3"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wd60622.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2022-02-14T22:02:32.000Z","updated_at":"2024-03-04T11:37:48.000Z","dependencies_parsed_at":"2022-09-03T00:00:58.103Z","dependency_job_id":"e4caea1c-c853-496d-a073-20c055b2d0a8","html_url":"https://github.com/wd60622/cta","commit_stats":{"total_commits":11,"total_committers":3,"mean_commits":"3.6666666666666665","dds":"0.18181818181818177","last_synced_commit":"d06c9c090712d0349f1ec1405ad49947d3e9c9a6"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wd60622%2Fcta","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wd60622%2Fcta/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wd60622%2Fcta/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wd60622%2Fcta/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wd60622","download_url":"https://codeload.github.com/wd60622/cta/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242171480,"owners_count":20083557,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chicago","chicago-data-portal","chicago-transit-authority","cta","mobility-data","public-transportation","python","python3"],"created_at":"2024-10-11T22:52:19.331Z","updated_at":"2025-03-06T08:16:05.312Z","avatar_url":"https://github.com/wd60622.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Chicago Transit Authority API\n\nThe CTA has three public endpoints for tracking CTA trains. This client supports\nthose endpoints.\n\nThe `CTAClient` has methods for each endpoints. Namely,\n- arrivals: Arrival information for a given station(s) or stop(s).\n- follow: Follow specific train by runnumber.\n- locations: Get all trains for a given route(s).\n\nMore endpoint specific documentation found [here](\nhttps://www.transitchicago.com/developers/ttdocs/)\n\nThis API requires a key which can be easily received [here](https://www.transitchicago.com/developers/traintrackerapply/).\nFollow the `.env.example` file for setting.\n\n## Installation\n\nThis package is available on `pip`. Install with:\n\n```bash\n$ pip install python-cta\n```\n\n## Getting Started\n\n```python\nfrom cta import CTAClient\ndamen_blue_line_mapid = 40590\n\n# Get arrival information for damen blue line station.\ncta_client = CTAClient()\narrival_response = cta_client.arrivals(mapid=damen_blue_line_mapid)\ndf_arrivals = arrival_response.to_frame()\nprint(df_arrivals)\n\n# Follow specific train\nrunnumber = df_arrivals[\"rn\"].tolist()[0]\nfollow_response = cta_client.follow(runnumber=runnumber)\ndf_follow = follow_response.to_frame()\nprint(df_follow)\n```\n\n```python\nfrom cta import Route\n\n# Get the location of all Blue Line trains.\nlocation_response = cta_client.locations(Route.BLUE)\ndf_locations = location_response.to_frame()\nprint(df_locations)\n\n# Or all trains on the track\nlocation_response = cta_client.locations(route=[route for route in Route])\ndf_locations = location_response.to_frame()\nprint(df_locations)\n```\n\nInformation about the stations can be found with the `Stations` class. Below is an\nexample to find the mapid for Damen blue line.\n\n```python\nfrom cta import Stations\n\nstations = Stations()\ndf_stations = stations.data\nprint(df_stations)\n\ndf_damen = stations.lookup(\"Damen\", route=Route.BLUE)\nprint(df_damen)\n```\n\nTry this example for yourself in `scripts/readme_example.py`\n\n## Notes\n\nThis currently doesn't support the [CTA bus API endpoints](https://www.transitchicago.com/developers/bustracker/). However, it might in the future.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwd60622%2Fcta","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwd60622%2Fcta","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwd60622%2Fcta/lists"}