{"id":17371943,"url":"https://github.com/juliuste/nahsh-hafas","last_synced_at":"2025-04-08T03:34:46.240Z","repository":{"id":53574818,"uuid":"125721393","full_name":"juliuste/nahsh-hafas","owner":"juliuste","description":" JavaScript client for the NAH.SH HAFAS API. ","archived":false,"fork":false,"pushed_at":"2021-03-23T14:49:10.000Z","size":10,"stargazers_count":6,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-23T04:41:13.636Z","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":"2018-03-18T12:13:30.000Z","updated_at":"2025-02-03T18:11:15.000Z","dependencies_parsed_at":"2022-09-19T02:50:43.021Z","dependency_job_id":null,"html_url":"https://github.com/juliuste/nahsh-hafas","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliuste%2Fnahsh-hafas","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliuste%2Fnahsh-hafas/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliuste%2Fnahsh-hafas/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliuste%2Fnahsh-hafas/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/juliuste","download_url":"https://codeload.github.com/juliuste/nahsh-hafas/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-16T01:09:19.318Z","updated_at":"2025-04-08T03:34:45.974Z","avatar_url":"https://github.com/juliuste.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# nahsh-hafas\n\n**Client for the [Nahverkehrsverbund Schleswig-Holstein (NAH.SH)](http://www.nah.sh) HAFAS API.** 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@5`](https://github.com/public-transport/hafas-client/blob/5/readme.md). [Its docs](https://github.com/derhuerst/hafas-client/tree/5/docs) document the API in general.\n\n[![npm version](https://img.shields.io/npm/v/nahsh-hafas.svg)](https://www.npmjs.com/package/nahsh-hafas)\n[![license](https://img.shields.io/github/license/juliuste/nahsh-hafas.svg?style=flat)](LICENSE)\n[![chat on gitter](https://badges.gitter.im/juliuste.svg)](https://gitter.im/juliuste)\n\n## Installing\n\n```shell\nnpm install nahsh-hafas\n```\n\n## API\n\nCheck [the docs for `hafas-client@2`](https://github.com/derhuerst/hafas-client/tree/5/docs) as well as [the NAH.SH-specific customisations](https://github.com/derhuerst/hafas-client/blob/5/p/nahsh/readme.md).\n\n\n## Getting Started\n\n```javascript\nconst createClient = require('nahsh-hafas')\n\nconst client = createHafas('my-awesome-program-useragent')\n```\n\nAs an example, we will search for a route from *Flensburg* to *Kiel Hbf*. To get the station ids, use [`locations(query, [opt])`](https://github.com/derhuerst/hafas-client/blob/5/docs/locations.md).\n\n```javascript\nclient.journeys('8000103', '8000199')\n.then((journeys) =\u003e console.log(journeys[0]))\n.catch(console.error)\n```\n\nThe output will be a [`journey` object in the *Friendly Public Transport Format* `1.0.1` format](https://github.com/public-transport/friendly-public-transport-format/tree/1.0.1/spec#journey):\n\n```javascript\n[ {\n    type: \"journey\",\n    legs: [\n        {\n            origin: {\n                type: \"station\",\n                id: \"8000103\",\n                name: \"Flensburg\",\n                location: {\n                    type: \"location\",\n                    latitude: 54.774043,\n                    longitude: 9.436525\n                },\n                products: {\n                    nationalExp: true,\n                    national: true,\n                    interregional: false,\n                    regional: true,\n                    suburban: false,\n                    bus: false,\n                    ferry: false,\n                    subway: false,\n                    tram: false,\n                    onCall: false\n                }\n            },\n            destination: {\n                type: \"station\",\n                id: \"8000199\",\n                name: \"Kiel Hbf\",\n                location: {\n                    type: \"location\",\n                    latitude: 54.314982,\n                    longitude: 10.131976\n                },\n                products: {\n                    nationalExp: true,\n                    national: true,\n                    interregional: false,\n                    regional: true,\n                    suburban: false,\n                    bus: false,\n                    ferry: false,\n                    subway: false,\n                    tram: false,\n                    onCall: false\n                }\n            },\n            departure: \"2018-03-18T14:04:00.000+01:00\",\n            arrival: \"2018-03-18T15:17:00.000+01:00\",\n            departureDelay: 0,\n            arrivalDelay: 0,\n            id: \"1|36867|6|100|18032018\",\n            line: {\n                type: \"line\",\n                id: \"re72\",\n                name: \"RE72\",\n                public: true,\n                class: 8,\n                productCode: 3,\n                operator: {\n                    type: \"operator\",\n                    id: \"db-regio-ag-nord\",\n                    name: \"DB Regio AG Nord\"\n                },\n                product: \"regional\",\n                mode: \"train\"\n            },\n            direction: \"Kiel Hbf\",\n            departurePlatform: \"4\",\n            arrivalPlatform: \"6a\"\n        }\n    ],\n    origin: {\n        type: \"station\",\n        id: \"8000103\",\n        name: \"Flensburg\",\n        location: {\n            type: \"location\",\n            latitude: 54.774043,\n            longitude: 9.436525\n        },\n        products: {\n            nationalExp: true,\n            national: true,\n            interregional: false,\n            regional: true,\n            suburban: false,\n            bus: false,\n            ferry: false,\n            subway: false,\n            tram: false,\n            onCall: false\n        }\n    },\n    destination: {\n        type: \"station\",\n        id: \"8000199\",\n        name: \"Kiel Hbf\",\n        location: {\n            type: \"location\",\n            latitude: 54.314982,\n            longitude: 10.131976\n        },\n        products: {\n            nationalExp: true,\n            national: true,\n            interregional: false,\n            regional: true,\n            suburban: false,\n            bus: false,\n            ferry: false,\n            subway: false,\n            tram: false,\n            onCall: false\n        }\n    },\n    departure: \"2018-03-18T14:04:00.000+01:00\",\n    arrival: \"2018-03-18T15:17:00.000+01:00\",\n    tickets: [\n        {\n            name: \"Normalpreis - Einzelkarte 2.Kl\",\n            tariff: \"Normalpreis\",\n            variant: \"Einzelkarte 2.Kl\",\n            amount: 18.7,\n            currency: \"EUR\"\n        },\n        {\n            name: \"Normalpreis - Einzelkarte Kind 2.Kl\",\n            tariff: \"Normalpreis\",\n            variant: \"Einzelkarte Kind 2.Kl\",\n            amount: 11.25,\n            currency: \"EUR\"\n        }\n        // …\n    ]\n} ]\n```\n\n\n## Similar Projects\n\n- - [*Friendly Public Transport Format*](https://github.com/public-transport/friendly-public-transport-format#friendly-public-transport-format-fptf) – A format for APIs, libraries and datasets containing and working with public transport data.\n- [db-hafas](https://github.com/derhuerst/db-hafas) – Client for the German Railways (DB).\n- [oebb-hafas](https://github.com/juliuste/oebb-hafas) – Client for the Austrian Railways (ÖBB).\n- [vbb-hafas](https://github.com/derhuerst/vbb-hafas) – Client for the Berlin \u0026 Brandenburg public transport service (VBB).\n\n\n## Contributing\n\nIf you found a bug, want to propose a feature or feel the urge to complain about your life, feel free to visit [the issues page](https://github.com/juliuste/nahsh-hafas/issues).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuliuste%2Fnahsh-hafas","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjuliuste%2Fnahsh-hafas","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuliuste%2Fnahsh-hafas/lists"}