{"id":18449441,"url":"https://github.com/public-transport/vbb-hafas","last_synced_at":"2025-04-08T01:33:00.637Z","repository":{"id":57391006,"uuid":"39252707","full_name":"public-transport/vbb-hafas","owner":"public-transport","description":"A JavaScript client for Berlin \u0026 Brandenburg public transport HAFAS API.","archived":false,"fork":false,"pushed_at":"2022-12-15T16:24:49.000Z","size":331,"stargazers_count":31,"open_issues_count":3,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-14T07:11:20.695Z","etag":null,"topics":["api","berlin","bvg","search","transit","transport","vbb"],"latest_commit_sha":null,"homepage":"https://github.com/public-transport/vbb-hafas","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/public-transport.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"license.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"patreon":"derhuerst","github":"derhuerst"}},"created_at":"2015-07-17T12:19:03.000Z","updated_at":"2023-09-19T23:15:30.000Z","dependencies_parsed_at":"2023-01-29T03:46:04.227Z","dependency_job_id":null,"html_url":"https://github.com/public-transport/vbb-hafas","commit_stats":null,"previous_names":["derhuerst/vbb"],"tags_count":60,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/public-transport%2Fvbb-hafas","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/public-transport%2Fvbb-hafas/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/public-transport%2Fvbb-hafas/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/public-transport%2Fvbb-hafas/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/public-transport","download_url":"https://codeload.github.com/public-transport/vbb-hafas/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222683362,"owners_count":17022463,"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":["api","berlin","bvg","search","transit","transport","vbb"],"created_at":"2024-11-06T07:20:03.122Z","updated_at":"2024-11-06T07:20:03.823Z","avatar_url":"https://github.com/public-transport.png","language":"JavaScript","funding_links":["https://patreon.com/derhuerst","https://github.com/sponsors/derhuerst"],"categories":[],"sub_categories":[],"readme":"# vbb-hafas\n\n**A client for the Berlin \u0026 Brandenburg public transport service (VBB).** It acts as a consistent and straightforward interface on top of a verbose API.\n\nThis project is actually a thin wrapper around [`hafas-client@6`](https://github.com/public-transport/hafas-client/tree/6#hafas-client). [Its docs](https://github.com/public-transport/hafas-client/tree/6/docs) document the API in general.\n\n*Note*: You may not want to query the VBB API by yourself. [`vbb-client`](https://github.com/derhuerst/vbb-client) is an API-compatible client for [`vbb-rest`](https://github.com/derhuerst/vbb-rest), my wrapper API. It also works in the browser.\n\n[![npm version](https://img.shields.io/npm/v/vbb-hafas.svg)](https://www.npmjs.com/package/vbb-hafas)\n[![build status](https://api.travis-ci.org/public-transport/vbb-hafas.svg?branch=master)](https://travis-ci.org/public-transport/vbb-hafas)\n![ISC-licensed](https://img.shields.io/github/license/public-transport/vbb-hafas.svg)\n![minimum Node.js version](https://img.shields.io/node/v/vbb-hafas.svg)\n[![support Jannis via GitHub Sponsors](https://img.shields.io/badge/support%20Jannis-donate-fa7664.svg)](https://github.com/sponsors/derhuerst)\n[![chat with Jannis on Twitter](https://img.shields.io/badge/chat%20with%20Jannis-on%20Twitter-1da1f2.svg)](https://twitter.com/derhuerst)\n\n\n## Installing\n\n```shell\nnpm install vbb-hafas\n```\n\n\n## API\n\nCheck [the docs for `hafas-client`](https://github.com/public-transport/hafas-client/tree/6/docs) as well as [its VBB-specific customisations](https://github.com/public-transport/hafas-client/blob/6/p/vbb/readme.md).\n\n\n## Usage\n\n```javascript\nconst createHafas = require('vbb-hafas')\n\nconst hafas = createHafas('my-awesome-program')\n```\n\nAs an example, we will search for a journey [from *Berlin Hauptbahnhof* to *Berlin Charlottenburg*](https://www.google.de/maps/dir/Berlin+Hauptbahnhof,+Europaplatz,+Berlin/S+Berlin-Charlottenburg/@52.5212391,13.3287227,13z). To get the station IDs, [use `vbb-stations`](https://github.com/derhuerst/vbb-stations#usage).\n\n```javascript\nhafas.journeys('900000003201', '900000024101', {results: 1})\n.then((journeys) =\u003e console.log(journeys[0]))\n.catch(console.error)\n```\n\nThe output will be an array of [`journey` objects in the *Friendly Public Transport Format* `1.2.1` format](https://github.com/public-transport/friendly-public-transport-format/tree/1.2.1/spec#journey):\n\n```javascript\n[ {\n\tlegs: [ {\n\t\ttripId: '1|50420|0|86|25122017',\n\t\tdirection: 'Brandenburg, Hbf',\n\t\tline: {\n\t\t\ttype: 'line',\n\t\t\tid: '10',\n\t\t\tname: 'RE1',\n\t\t\tpublic: true,\n\t\t\tmode: 'train',\n\t\t\tproduct: 'regional',\n\t\t\tsymbol: 'RE',\n\t\t\tnr: 1,\n\t\t\tmetro: false,\n\t\t\texpress: true,\n\t\t\tnight: false,\n\t\t\tclass: 64,\n\t\t\tproductCode: 6,\n\t\t\toperator: {\n\t\t\t\ttype: 'operator',\n\t\t\t\tid: 'db-regio-ag',\n\t\t\t\tname: 'DB Regio AG'\n\t\t\t}\n\t\t},\n\n\t\torigin: {\n\t\t\ttype: 'station',\n\t\t\tid: '900000003201',\n\t\t\tname: 'S+U Berlin Hauptbahnhof',\n\t\t\tlocation: {\n\t\t\t\ttype: 'location',\n\t\t\t\tlatitude: 52.52585,\n\t\t\t\tlongitude: 13.368928\n\t\t\t},\n\t\t\tproducts: {\n\t\t\t\tsuburban: true,\n\t\t\t\tsubway: true,\n\t\t\t\ttram: true,\n\t\t\t\tbus: true,\n\t\t\t\tferry: false,\n\t\t\t\texpress: true,\n\t\t\t\tregional: true\n\t\t\t}\n\t\t},\n\t\tdeparture: '2017-12-26T00:41:00.000+01:00',\n\t\tplannedDeparture: '2017-12-26T00:41:00.000+01:00',\n\t\tdepartureDelay: 0,\n\t\tdeparturePlatform: '14',\n\t\tplannedDeparturePlatform: '13',\n\n\t\tdestination: {\n\t\t\ttype: 'station',\n\t\t\tid: '900000024101',\n\t\t\tname: 'S Charlottenburg',\n\t\t\tlocation: {\n\t\t\t\ttype: 'location',\n\t\t\t\tlatitude: 52.504806,\n\t\t\t\tlongitude: 13.303846\n\t\t\t},\n\t\t\tproducts: {\n\t\t\t\tsuburban: true,\n\t\t\t\tsubway: false,\n\t\t\t\ttram: false,\n\t\t\t\tbus: true,\n\t\t\t\tferry: false,\n\t\t\t\texpress: false,\n\t\t\t\tregional: true\n\t\t\t}\n\t\t},\n\t\tarrival: '2017-12-26T00:50:00.000+01:00',\n\t\tplannedArrival: '2017-12-26T00:50:00.000+01:00',\n\t\tarrivalDelay: null,\n\t\tarrivalPlatform: '4',\n\t\tplannedArrivalPlatform: '4'\n\t} ],\n\n\t// all these are from the first leg\n\torigin: {\n\t\ttype: 'station',\n\t\tid: '900000003201',\n\t\tname: 'S+U Berlin Hauptbahnhof'\n\t\t// …\n\t},\n\tdeparture: '2017-12-26T00:41:00.000+01:00',\n\tplannedDeparture: '2017-12-26T00:41:00.000+01:00',\n\tdepartureDelay: 0,\n\tdeparturePlatform: '14',\n\tplannedDeparturePlatform: '13',\n\n\t// all these are from the last leg\n\tdestination: {\n\t\ttype: 'station',\n\t\tid: '900000024101',\n\t\tname: 'S Charlottenburg'\n\t\t// …\n\t},\n\tarrival: '2017-12-26T00:50:00.000+01:00',\n\tplannedArrival: '2017-12-26T00:50:00.000+01:00',\n\tarrivalDelay: null,\n\tarrivalPlatform: '4',\n\tplannedArrivalPlatform: '4'\n\n\t// …\n} ]\n```\n\n\n### Transfer information for journeys\n\n`vbb-hafas` will try to add transfer information from [`vbb-change-positions`](https://github.com/juliuste/vbb-change-positions) if you pass `transferInfo: true` as an option.\n\nIf it identifies a known transfer, the previous leg will have a `bestArrivalPosition` and the next leg will have a `departurePosition`, indicating the optimal transfer between both platforms. Check out the markup in [`vbb-change-positions`](https://github.com/juliuste/vbb-change-positions) for more details.\n\n\n## Related\n\nCheck [`hafas-client`'s related projects](https://github.com/public-transport/hafas-client/blob/6/readme.md#related-projects).\n\n\n## Contributing\n\nIf you **have a question**, **found a bug** or want to **propose a feature**, have a look at [the issues page](https://github.com/public-transport/vbb-hafas/issues).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpublic-transport%2Fvbb-hafas","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpublic-transport%2Fvbb-hafas","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpublic-transport%2Fvbb-hafas/lists"}