{"id":17367458,"url":"https://github.com/juliuste/slovenske-zeleznice","last_synced_at":"2025-04-08T03:34:39.148Z","repository":{"id":57363402,"uuid":"109589436","full_name":"juliuste/slovenske-zeleznice","owner":"juliuste","description":"Slovenske železnice (SŽ, Slovenian Railways) API client.","archived":false,"fork":false,"pushed_at":"2020-05-25T04:08:41.000Z","size":94,"stargazers_count":12,"open_issues_count":9,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-02T04:35:54.953Z","etag":null,"topics":["library","public-transport","railway"],"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-11-05T15:04:07.000Z","updated_at":"2025-01-24T15:25:23.000Z","dependencies_parsed_at":"2022-09-26T16:32:16.598Z","dependency_job_id":null,"html_url":"https://github.com/juliuste/slovenske-zeleznice","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliuste%2Fslovenske-zeleznice","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliuste%2Fslovenske-zeleznice/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliuste%2Fslovenske-zeleznice/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliuste%2Fslovenske-zeleznice/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/juliuste","download_url":"https://codeload.github.com/juliuste/slovenske-zeleznice/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247535521,"owners_count":20954576,"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","railway"],"created_at":"2024-10-15T22:56:58.778Z","updated_at":"2025-04-08T03:34:38.890Z","avatar_url":"https://github.com/juliuste.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# slovenske-zeleznice\n\nJavaScript client for the Slovenian 🇸🇮 [Slovenske železnice (SŽ)](http://www.slo-zeleznice.si/) railway API. Inofficial, using *SŽ* endpoints. Ask them for permission before using this module in production.\n\n[![npm version](https://img.shields.io/npm/v/slovenske-zeleznice.svg)](https://www.npmjs.com/package/slovenske-zeleznice)\n[![Build Status](https://travis-ci.org/juliuste/slovenske-zeleznice.svg?branch=master)](https://travis-ci.org/juliuste/slovenske-zeleznice)\n[![Greenkeeper badge](https://badges.greenkeeper.io/juliuste/slovenske-zeleznice.svg)](https://greenkeeper.io/)\n[![fpti-js version](https://fpti-js.badges.juliustens.eu/badge/juliuste/slovenske-zeleznice)](https://fpti-js.badges.juliustens.eu/link/juliuste/slovenske-zeleznice)\n[![chat on gitter](https://badges.gitter.im/juliuste.svg)](https://gitter.im/juliuste)\n\n## Installation\n\n```shell\nnpm install --save slovenske-zeleznice\n```\n\n## Usage\n\n```javascript\nconst sz = require('slovenske-zeleznice')\n```\n\nThe `slovenske-zeleznice` module conforms to the [FPTI-JS `0.3.2` standard](https://github.com/public-transport/fpti-js/tree/0.3.2) for JavaScript public transportation modules and exposes the following methods:\n\nMethod | Feature description | [FPTI-JS `0.3.2`](https://github.com/public-transport/fpti-js/tree/0.3.2)\n-------|---------------------|--------------------------------------------------------------------\n[`stations.all([opt])`](#stationsallopt) | All stations of the *SŽ* network, such as `Ljubljana` or `Maribor` | [✅ yes](https://github.com/public-transport/fpti-js/blob/0.3.2/docs/stations-stops-regions.all.md)\n[`journeys(origin, destination, [opt])`](#journeysorigin-destination-opt) | Journeys between stations | [✅ yes](https://github.com/public-transport/fpti-js/blob/0.3.2/docs/journeys.md)\n[`legStopovers(legId)`](#legStopoverslegid) | All stopovers for a leg (all stations the train passes on that leg) | ❌ no\n\n---\n\n### `stations.all([opt])`\n\nGet **all** stations of the *SŽ* network, such as `Ljubljana` or `Maribor`. See [this method in the FPTI-JS `0.3.2` spec](https://github.com/public-transport/fpti-js/blob/0.3.2/docs/stations-stops-regions.all.md).\n\n#### Supported Options\n\nThere currently aren't any supported options for this method, but this might change in a future release.\n\n#### Example\n\n```js\nconst sz = require('slovenske-zeleznice')\nconst stationStream = sz.stations.all()\n\nstationStream.on('data', item =\u003e {\n    // item is an FPTF station object\n    console.log(item)\n})\n```\n\n```js\n{\n    type: \"station\",\n    id: \"42357\",\n    name: \"Ljubljana Brinje\"\n}\n```\n\n---\n\n### `journeys(origin, destination, [opt])`\n\nFind journeys between stations. See [this method in the FPTI-JS `0.3.2` spec](https://github.com/public-transport/fpti-js/blob/0.3.2/docs/journeys.md).\n\n#### Supported Options\n\nAttribute | Description | FPTI-spec | Value type | Default\n----------|-------------|------------|------------|--------\n`when` | Journey date, synonym to `departureAfter` | ✅ | [`Date`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/date) | `new Date()`\n`departureAfter` | List journeys with a departure (first leg) after this date | ✅ | [`Date`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/date) | `new Date()`\n`results` | Max. number of results returned | ✅ | `Number` | `null`\n`interval` | Results for how many minutes after `when`/`departureAfter` | ✅ | `Number` | `null`\n`transfers` | Max. number of transfers | ✅ | `Number` | `null`\n\nNote that, unless `opt.interval` is specified, the module will return journeys that start after `when`/`departureAfter`, but before the beginning of the following calendar day in `Europe/Ljubljana` time zone.\n\n#### Example\n\n```js\nconst ljubljana = '42300'\nconst maribor = { // FPTF station\n\ttype: 'station',\n\tid: '43400'\n\t// …\n}\nsz.journeys(ljubljana, maribor, { when: new Date('2019-06-27T05:00:00+0200'), transfers: 0 }).then(…)\n```\n\n```js\n{\n    type: \"journey\",\n    id: \"2004###2019-06-27###42300###43400\",\n    info: \"Timetable valid from 9. Dec. 2018 do 14. Dec. 2019.\",\n    legs: [\n        {\n            origin: {\n                type: \"station\",\n                id: \"42300\",\n                name: \"Ljubljana\"\n            },\n            destination: {\n                type: \"station\",\n                id: \"43400\",\n                name: \"Maribor\"\n            },\n            departure: \"2019-06-27T10:50:00.000+02:00\",\n            arrival: \"2019-06-27T13:35:00.000+02:00\",\n            mode: \"train\",\n            public: true,\n            line: {\n                type: \"line\",\n                id: \"2004\",\n                name: \"LPV 2004\",\n                number: \"2004\",\n                product: \"LPV\",\n                mode: \"train\",\n                public: true,\n                operator: {\n                    type: \"operator\",\n                    id: \"sž\",\n                    name: \"Slovenske železnice\",\n                    url: \"http://www.slo-zeleznice.si\"\n                }\n            },\n            operator: {\n                type: \"operator\",\n                id: \"sž\",\n                name: \"Slovenske železnice\",\n                url: \"http://www.slo-zeleznice.si\"\n            },\n            bicycle: true,\n            wifi: false,\n            id: \"2004###2019-06-27###42300###43400\"\n        }\n    ],\n    price: {\n        amount: 9.56,\n        currency: \"EUR\"\n    }\n}\n```\n\n---\n\n### `legStopovers(legId)`\n\nAll stopovers for a given leg (all stations the train passes on that leg). Obtain a `legId` using the [`journeys(origin, destination, [opt])`](#journeysorigin-destination-opt) method. Returns a `Promise` that resolves in a list of stopovers.\n\n#### Example\n\n```js\nconst legId = '2004###2019-06-27###42300###43400' // taken from the journeys example above\nsz.legStopovers(legId).then(…)\n```\n\n```js\n[\n    {\n        type: \"stopover\",\n        stop: {\n            type: \"station\",\n            id: \"42300\",\n            name: \"Ljubljana\"\n        },\n        departure: \"2019-06-27T10:50:00.000+02:00\",\n        arrival: null\n    },\n    {\n        type: \"stopover\",\n        stop: {\n            type: \"station\",\n            id: \"42212\",\n            name: \"Ljubljana Polje\"\n        },\n        departure: \"2019-06-27T10:56:00.000+02:00\",\n        arrival: \"2019-06-27T10:55:00.000+02:00\"\n    },\n    // …\n    {\n        type: \"stopover\",\n        stop: {\n            type: \"station\",\n            id: \"43304\",\n            name: \"Maribor Tezno\"\n        },\n        departure: \"2019-06-27T13:32:00.000+02:00\",\n        arrival: \"2019-06-27T13:31:00.000+02:00\"\n    },\n    {\n        type: \"stopover\",\n        stop: {\n            type: \"station\",\n            id: \"43400\",\n            name: \"Maribor\"\n        },\n        departure: null,\n        arrival: \"2019-06-27T13:35:00.000+02:00\"\n    }\n]\n```\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/slovenske-zeleznice/issues).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuliuste%2Fslovenske-zeleznice","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjuliuste%2Fslovenske-zeleznice","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuliuste%2Fslovenske-zeleznice/lists"}