{"id":17369791,"url":"https://github.com/juliuste/lvb","last_synced_at":"2025-04-08T03:34:50.710Z","repository":{"id":54984557,"uuid":"106313381","full_name":"juliuste/lvb","owner":"juliuste","description":"Inofficial LVB (Leipziger Verkehrsbetriebe) API client.","archived":true,"fork":false,"pushed_at":"2021-10-25T10:18:56.000Z","size":70,"stargazers_count":32,"open_issues_count":3,"forks_count":7,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-04-06T19:36:57.514Z","etag":null,"topics":["library","public-transport"],"latest_commit_sha":null,"homepage":null,"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/juliuste.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}},"created_at":"2017-10-09T17:24:03.000Z","updated_at":"2025-04-06T19:26:10.000Z","dependencies_parsed_at":"2022-08-14T08:10:36.906Z","dependency_job_id":null,"html_url":"https://github.com/juliuste/lvb","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliuste%2Flvb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliuste%2Flvb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliuste%2Flvb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliuste%2Flvb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/juliuste","download_url":"https://codeload.github.com/juliuste/lvb/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247772938,"owners_count":20993627,"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":["library","public-transport"],"created_at":"2024-10-16T00:13:53.440Z","updated_at":"2025-04-08T03:34:50.471Z","avatar_url":"https://github.com/juliuste.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# lvb\n\nClient for the [LVB](https://l.de/verkehrsbetriebe) (Leipziger Verkehrsbetriebe) API. Inofficial, please ask LVB for permission before using this module in production. **Actually, there should be no need for projects like this since municipal public transportation endpoints should be open to the public. It's 2021.**\n\n[![npm version](https://img.shields.io/npm/v/lvb.svg)](https://www.npmjs.com/package/lvb)\n[![license](https://img.shields.io/github/license/juliuste/lvb.svg?style=flat)](license)\n\n## Installation\n\n```shell\nnpm install --save lvb\n```\n\n## Usage\n\nThis package mostly returns data in the [*Friendly Public Transport Format*](https://github.com/public-transport/friendly-public-transport-format):\n\n- [`stations(query, [opt])`](#stationsquery-opt) - Search for stations\n- [`departures(station, date = Date.now())`](#departuresstation-date--datenow) - Departures at a given station\n- [`journeys(origin, destination, date = Date.now(), [opt])`](#journeysorigin-destination-date--datenow-opt) - Search for journeys between stations\n\n### `stations(query, [opt])`\n\nUsing `lvb.stations`, you can query stations operated bei LVB.\n\n```js\nconst stations = require('lvb').stations\n\nstations('Nationalbibliothek').then(console.log)\n```\n\nReturns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/promise) that will resolve in an array of `station`s in the [*Friendly Public Transport Format*](https://github.com/public-transport/friendly-public-transport-format) which looks as follows:\n\n```js\n\n[\n    {\n        \"id\": \"11558\",\n        \"type\": \"station\",\n        \"name\": \"Leipzig, Deutsche Nationalbibliothek\",\n        \"coordinates\": {\n            \"longitude\": 12.396131411662,\n            \"latitude\": 51.323542325868\n        }\n    }\n    // …\n]\n```\n\n`defaults`, partially overridden by the `opt` parameter, looks as follows:\n\n```js\nconst defaults = {\n    limit: 5 // Maximum number of returned results. CAUTION: Because of something unlucky that happens to station ids in the API, a `stations` request will spawn (number of results + 1) requests. Keep this in mind when increasing this threshold.\n}\n```\n\n### `departures(station, date = Date.now())`\n\nUsing `lvb.departures`, you can get departures at a given station for a specific date and time.\n\n```js\nconst departures = require('lvb').departures\n\nconst Nationalbibliothek = '11558'\n\ndepartures(Nationalbibliothek, new Date())\n```\n\nReturns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/promise) that will resolve in a list of objects (one object per direction per line) like this:\n\n```js\n[\n    {\n        \"line\": {\n            \"id\": \"16\",\n            \"name\": \"Str   16\", // yeah, that really looks like this :/\n            \"class\": \"StN\",\n            \"operator\": \"LVB\",\n            \"direction\": \"Lößnig über Connewitz, Kreuz\"\n        },\n        \"timetable\": [\n            {\n                \"departure\": \"2017-10-09T16:09:00.000Z\", // JS Date() object\n                \"departureDelay\": 0\n            },\n            {\n                \"departure\": \"2017-10-09T16:19:00.000Z\", // JS Date() object\n                \"departureDelay\": 0\n            },\n            {\n                \"departure\": \"2017-10-09T16:29:00.000Z\", // JS Date() object\n                \"departureDelay\": 0\n            },\n            {\n                \"departure\": \"2017-10-09T16:39:00.000Z\", // JS Date() object\n                \"departureDelay\": 0\n            },\n            {\n                \"departure\": \"2017-10-09T16:51:00.000Z\", // JS Date() object\n                \"departureDelay\": 0\n            }\n        ]\n    }\n    // …\n]\n```\n\n### `journeys(origin, destination, date = Date.now(), [opt])`\n\nUsing `lvb.journeys`, you can get directions and prices for routes from A to B.\n\n```js\nconst journeys = require('lvb').journeys\n\njourneys(origin, destination, date = Date.now(), opt = defaults)\n\nconst Nationalbibliothek = '11558'\nconst Messe = '10818'\nconst date = new Date()\n\njourneys(Nationalbibliothek, Messe, date)\n.then(console.log)\n.catch(console.error)\n```\n\nReturns a [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/promise) that will resolve with an array of `journey`s in the [*Friendly Public Transport Format*](https://github.com/public-transport/friendly-public-transport-format) which looks as follows.\n*Note that the legs are not (fully) spec-compatible, as the `schedule` is missing (see the `line` and `route` keys instead).*\n\n```js\n[\n    {\n        \"type\": \"journey\",\n        \"id\": \"Leipzig, Deutsche Nationalbibliothek@20171009173100@Leipzig, Wilhelm-Leuschner-Platz@20171009173900@SEV16@BUN-Leipzig, Wilhelm-Leuschner-Platz@20171009174200@Leipzig, Messegelände@20171009180800@16@STN\",\n        \"legs\": [\n            {\n                \"origin\": {\n                    \"type\": \"station\",\n                    \"name\": \"Leipzig, Deutsche Nationalbibliothek\",\n                    \"id\": 11558,\n                    \"coordinates\": {\n                        \"longitude\": 12.395702,\n                        \"latitude\": 51.32357\n                    }\n                },\n                \"destination\": {\n                    \"type\": \"station\",\n                    \"name\": \"Leipzig, Wilhelm-Leuschner-Platz\",\n                    \"id\": 12992,\n                    \"coordinates\": {\n                        \"longitude\": 12.375872,\n                        \"latitude\": 51.335876\n                    }\n                },\n                \"line\": {\n                    \"id\": \"SEV16\",\n                    \"class\": \"BUN\",\n                    \"direction\": \"Wilhelm-Leuschner-Platz\",\n                    \"operator\": \"Leipziger Verkehrsbetriebe\",\n                    \"color\": \"#017C46\"\n                },\n                \"route\": [\n                    {\n                        \"type\": \"station\",\n                        \"id\": 11558,\n                        \"name\": \"Leipzig, Deutsche Nationalbibliothek\",\n                        \"coordinates\": {\n                            \"longitude\": 12.395702,\n                            \"latitude\": 51.32357\n                        }\n                    },\n                    {\n                        \"type\": \"station\",\n                        \"id\": 11557,\n                        \"name\": \"Leipzig, Johannisallee\",\n                        \"coordinates\": {\n                            \"longitude\": 12.388807,\n                            \"latitude\": 51.327309\n                        }\n                    }\n                    // …\n                ],\n                \"departure\": \"2017-10-09T15:31:00.000Z\", // JS Date() object\n                \"departureDelay\": 0,\n                \"arrival\": \"2017-10-09T15:39:00.000Z\", // JS Date() object\n                \"arrivalDelay\": 0,\n                \"departurePlatform\": null,\n                \"arrivalPlatform\": null\n            },\n            {\n                \"origin\": {\n                    \"type\": \"station\",\n                    \"name\": \"Leipzig, Wilhelm-Leuschner-Platz\",\n                    \"id\": 12992,\n                    \"coordinates\": {\n                        \"longitude\": 12.375872,\n                        \"latitude\": 51.335876\n                    }\n                },\n                \"destination\": {\n                    \"type\": \"station\",\n                    \"name\": \"Leipzig, Messegelände\",\n                    \"id\": 10818,\n                    \"coordinates\": {\n                        \"longitude\": 12.396583,\n                        \"latitude\": 51.396724\n                    }\n                },\n                \"line\": {\n                    \"id\": \"16\",\n                    \"class\": \"STN\",\n                    \"direction\": \"Messegelände\",\n                    \"operator\": \"Leipziger Verkehrsbetriebe\",\n                    \"color\": \"#017C46\"\n                },\n                \"route\": [\n                    {\n                        \"type\": \"station\",\n                        \"id\": 12992,\n                        \"name\": \"Leipzig, Wilhelm-Leuschner-Platz\",\n                        \"coordinates\": {\n                            \"longitude\": 12.375872,\n                            \"latitude\": 51.335876\n                        }\n                    },\n                    {\n                        \"type\": \"station\",\n                        \"id\": 13002,\n                        \"name\": \"Leipzig, Augustusplatz\",\n                        \"coordinates\": {\n                            \"longitude\": 12.382012,\n                            \"latitude\": 51.338905\n                        }\n                    }\n                    // …\n                ],\n                \"departure\": \"2017-10-09T15:42:00.000Z\", // JS Date() object\n                \"departureDelay\": 0,\n                \"arrival\": \"2017-10-09T16:08:00.000Z\", // JS Date() object\n                \"arrivalDelay\": 0,\n                \"departurePlatform\": null,\n                \"arrivalPlatform\": null\n            }\n        ],\n        \"price\": {\n            \"model\": \"Einzelfahrkarte\",\n            \"amount\": 2.6,\n            \"currency\": \"EUR\",\n            \"fares\": [\n                {\n                    \"type\": \"fare\",\n                    \"model\": \"Einzelfahrkarte\",\n                    \"amount\": 2.6,\n                    \"currency\": \"EUR\"\n                },\n                {\n                    \"type\": \"fare\",\n                    \"model\": \"Einzelfahrkarte Kind\",\n                    \"amount\": 1.2,\n                    \"currency\": \"EUR\"\n                },\n                {\n                    \"type\": \"fare\",\n                    \"model\": \"4-Fahrten-Karte\",\n                    \"amount\": 10.4,\n                    \"currency\": \"EUR\"\n                }\n                // …\n            ]\n        },\n        \"zones\": {\n            \"departure\": \"110\",\n            \"arrival\": \"110\",\n            \"list\": \"110\"\n        }\n    }\n    // …\n]\n```\n\n----\n\n`defaults`, partially overridden by the `opt` parameter, looks like this:\n\n```js\nconst defaults = {\n    via: null // station id\n}\n```\n\n## See also\n\n- [FPTF](https://github.com/public-transport/friendly-public-transport-format) - \"Friendly public transport format\"\n- [FPTF-modules](https://github.com/public-transport/friendly-public-transport-format/blob/master/modules.md) - modules that also use FPTF\n\n## Contributing\n\nIf you found a bug or want to propose a feature, feel free to visit [the issues page](https://github.com/juliuste/lvb/issues).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuliuste%2Flvb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjuliuste%2Flvb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuliuste%2Flvb/lists"}