{"id":19196940,"url":"https://github.com/transitapp/gtfsnodelib","last_synced_at":"2026-02-16T18:32:30.777Z","repository":{"id":27970153,"uuid":"115737532","full_name":"TransitApp/gtfsNodeLib","owner":"TransitApp","description":"A Node.js librairie for GTFS","archived":false,"fork":false,"pushed_at":"2023-04-20T02:19:34.000Z","size":363,"stargazers_count":17,"open_issues_count":6,"forks_count":6,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-07-18T14:05:35.853Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TransitApp.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}},"created_at":"2017-12-29T16:27:43.000Z","updated_at":"2025-04-27T19:21:02.000Z","dependencies_parsed_at":"2025-05-09T00:42:34.674Z","dependency_job_id":"a9602acd-e82e-43da-b5c7-0db4dc706fc5","html_url":"https://github.com/TransitApp/gtfsNodeLib","commit_stats":null,"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"purl":"pkg:github/TransitApp/gtfsNodeLib","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TransitApp%2FgtfsNodeLib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TransitApp%2FgtfsNodeLib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TransitApp%2FgtfsNodeLib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TransitApp%2FgtfsNodeLib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TransitApp","download_url":"https://codeload.github.com/TransitApp/gtfsNodeLib/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TransitApp%2FgtfsNodeLib/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267268465,"owners_count":24062156,"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","status":"online","status_checked_at":"2025-07-26T02:00:08.937Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-11-09T12:14:58.194Z","updated_at":"2026-02-16T18:32:30.713Z","avatar_url":"https://github.com/TransitApp.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Node.js light GTFS loading and manipulation\nA Node.js naive library to load and manipulate GTFS datasets.\n\n## Installation\n\n```npm install --save @transit/gtfs```\n\n## Usage\n\nThe tables of the GTFS will be loaded only when accessed, and not upfront. This allows manipulation of the small tables\n(like routes.txt or stops.txt) without having to load the big tables (like stop_times.txt).\n\n## Example\n\nIf you want to remove all the stops called 'Central Station' and the stop_times using this stop:\n\n```js\nconst { Gtfs } = require('@transit/gtfs');\n\nconst gtfs = new Gtfs('pathToTheFolderContainingTheGtfs');\n\ngtfs.forEachStop((stop) =\u003e {\n  if (stop.stop_name === 'Central Station') {\n    gtfs.removeStop(stop);\n  }\n});\n\ngtfs.forEachStopTime((stopTime) =\u003e {\n  if (!gtfs.getStopOfStopTime(stopTime)) {\n    gtfs.removeStopTime(stopTime);\n  }\n});\n\n// Let's also clean up the frequencies, to keep a consistent GTFS.\ngtfs.forEachFrequency((frequency) =\u003e {\n  const fromStop = gtfs.getStopWithId(frequency.from_stop_id);\n  const toStop = gtfs.getStopWithId(frequency.to_stop_id);\n\n  if (!fromStop || !toStop) {\n    gtfs.removeFrequency(frequency);\n  }\n});\n\ngtfs.exportAtPath('somePathWhereYouWantToExportTheGtfs', (error) =\u003e {\n  if (error) { throw error };\n\n  // Done\n});\n```\n\n### Indexes\n\nThe tables are loaded and saved as Maps, to allow o(1) access using the ids. The routes are therefore indexed by the\n`route_id` value, which is therefore saved in `route.route_id` but also as an index.\n\n**This indexing is not automatically kept up to date.**\n\nIf you change the `route_id` just by changing the internal value of the `route` the index **won't** be updated, and\ntherefore the table will be corrupted. To properly update the id of a route, you should replace it:\n\n```js\nconst route = gtfs.getRouteWithId('oldId');\ngtfs.removeRoute(route);\nroute.route_id = 'newId';\ngtfs.addRoute(route);\n```\n\n### Synchronous loading\n\nThe goal of this implementation was to avoid loading upfront all the tables. Therefore, they are loaded only when\nrequired. This makes the code faster to run (if some tables are not required at all).\n\nThe drawback, is that any function could trigger the loading of a table. Since we do not want to turn every function into an async one, the loading of the tables is done synchronously.\n\n## Naming\n\nThe wording used in the official GTFS specification has been followed as much as possible, including the inconsistencies.\nFor example, the table containing the stops is \"stops\", but the table containing the agencies is \"agency\". The reason\nfor this being that, in the specification, the files are named `stops.txt` vs `agency.txt`.\n\nMost of the time, the name of one item of a table is the singular of the table name (routes -\u003e route, stops -\u003e stop),\nbut for the `shapes.txt`, since one item of the table is not a \"shape\" per-se, but just a point, the name used is\n\"shapePoint\" (consistent with the name `shape_pt_sequence`, `shape_pt_lat` and `shape_pt_lon` of the spec).\n\n## Support and contact\n\nPlease post any issues you find on [the repo of the project](https://github.com/TransitApp/gtfsNodeLib/issues). And\ndo not hesitate to contact [Transit App](https://github.com/TransitApp) directly if you have any questions.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftransitapp%2Fgtfsnodelib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftransitapp%2Fgtfsnodelib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftransitapp%2Fgtfsnodelib/lists"}