{"id":28098536,"url":"https://github.com/arrismo/nyctrains","last_synced_at":"2026-04-11T16:02:37.376Z","repository":{"id":288093455,"uuid":"879400102","full_name":"arrismo/nyctrains","owner":"arrismo","description":"MTA API Python Package","archived":false,"fork":false,"pushed_at":"2025-04-25T15:03:54.000Z","size":5975,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-01T16:39:49.598Z","etag":null,"topics":["fastapi","python"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/nyctrains/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/arrismo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-10-27T19:54:22.000Z","updated_at":"2025-04-25T15:05:44.000Z","dependencies_parsed_at":"2026-01-02T00:05:41.066Z","dependency_job_id":null,"html_url":"https://github.com/arrismo/nyctrains","commit_stats":null,"previous_names":["arrismo/nyctrains","arrismo/nyctrains-dashboard"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/arrismo/nyctrains","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arrismo%2Fnyctrains","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arrismo%2Fnyctrains/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arrismo%2Fnyctrains/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arrismo%2Fnyctrains/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arrismo","download_url":"https://codeload.github.com/arrismo/nyctrains/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arrismo%2Fnyctrains/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29733121,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-22T20:09:16.275Z","status":"ssl_error","status_checked_at":"2026-02-22T20:09:13.750Z","response_time":110,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["fastapi","python"],"created_at":"2025-05-13T17:58:04.470Z","updated_at":"2026-02-23T00:40:31.314Z","avatar_url":"https://github.com/arrismo.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nyctrains API\n[![Python Versions](https://img.shields.io/pypi/pyversions/nyctrains.svg)](https://pypi.python.org/pypi/nyctrains)\n[![PyPI](https://img.shields.io/pypi/v/nyctrains)](https://pypi.org/project/nyctrains/#history)\n[![PyPI Downloads](https://img.shields.io/pypi/dm/nyctrains)](https://pypistats.org/packages/nyctrains)\n[![Repo Status](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)\n[![codecov](https://codecov.io/gh/arrismo/nyctrains/graph/badge.svg?token=AGXZZYUQU3)](https://codecov.io/gh/arrismo/nyctrains)\n[![CI Build](https://github.com/arrismo/nyctrains/actions/workflows/ci-tests.yaml/badge.svg)](https://github.com/arrismo/nyctrains/actions/workflows/ci-tests.yaml)\n\nA FastAPI-based backend and Python package for working with the MTA's real-time subway and LIRR GTFS-RT data feeds. This project fetches, parses, and exposes real-time feeds as human-readable JSON, including stop names and (for LIRR) route names. You can use it as an HTTP API or as a Python library in your own projects.\n\n## Supported Feeds\n- `ace` (A, C, E)\n- `bdfm` (B, D, F, M)\n- `g` (G)\n- `jz` (J, Z)\n- `nqrw` (N, Q, R, W)\n- `l` (L)\n- `si` (Staten Island Railway)\n- `1234567` (1, 2, 3, 4, 5, 6, 7, S)\n- `lirr` (Long Island Rail Road)\n\n## Installation\n\nInstall using pip:\n\n```sh\npip install nyctrains\n```\n\n## Static GTFS Data\n\nThis package relies on static GTFS data files being present in the `resources/` directory for full functionality (e.g., adding stop names, route details).\n\nRequired files:\n- `resources/stops.txt` (NYC Subway + LIRR stops)\n- `resources/routes.txt` (NYC Subway + LIRR routes)\n- `resources/trips.txt`\n- `resources/stop_times.txt`\n\n*Note: The simple mappings for LIRR stop names (`stops-lirr.txt`) and route names (`routes-lirr.txt`) used in earlier versions have been replaced by the requirement for the full static GTFS files.* You can typically download these files from the MTA developer resources page.\n\nThe application loads these files into pandas DataFrames at startup using the `nyctrains.static_gtfs` module.\n\n## Usage\n\nThis package provides Python tools and a FastAPI backend for working with MTA GTFS-RT subway and LIRR data. **No API key is required** to use the package or access the feeds.\n\n### Running the API Server\n\n```sh\n# Make sure you have the static GTFS files in ./resources/\nuvicorn nyctrains.main:app --reload\n```\n\nAccess the API documentation at `http://127.0.0.1:8000/docs`.\n\nMake requests to the feed endpoint, e.g.:\n`http://127.0.0.1:8000/subway/ace/json`\n\n### Using as a Library\n\n#### Example: Fetching a GTFS Feed\n\n```python\nfrom nyctrains.mta_client import MTAClient\nimport asyncio\n\nclient = MTAClient()\nfeed_path = \"nyct%2Fgtfs-ace\"  # Example feed\n\ndata = asyncio.run(client.get_gtfs_feed(feed_path))\n# data contains the raw protobuf bytes\nprint(f\"Feed data length: {len(data)} bytes\")\n```\n\n#### Example: Loading Static GTFS Data\n\n```python\nfrom nyctrains import static_gtfs\n\n# Load static data (caches results)\nstops_df = static_gtfs.get_stops()\nroutes_df = static_gtfs.get_routes()\n\nif stops_df is not None:\n    print(f\"Loaded {len(stops_df)} stops.\")\nif routes_df is not None:\n    print(f\"Loaded {len(routes_df)} routes.\")\n```\n\n## Example Output\n```json\n{\n  \"header\": {\n    \"gtfs_realtime_version\": \"2.0\",\n    \"timestamp\": \"2025-04-15T21:04:02+00:00\"\n  },\n  \"entity\": [\n    {\n      \"id\": \"GO304_25_809_T\",\n      \"trip_update\": {\n        \"trip\": {\n          \"trip_id\": \"GO304_25_809\",\n          \"start_date\": \"20250415\",\n          \"schedule_relationship\": 0,\n          \"route_id\": \"6\",\n          \"route_long_name\": \"Long Beach Branch\",\n          \"direction_id\": 1\n        },\n        \"stop_time_update\": [\n          {\n            \"stop_id\": \"LBG\",\n            \"stop_name\": \"Long Beach\"\n          }\n        ]\n      }\n    }\n  ]\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farrismo%2Fnyctrains","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farrismo%2Fnyctrains","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farrismo%2Fnyctrains/lists"}