{"id":17371939,"url":"https://github.com/juliuste/train-ose","last_synced_at":"2025-04-08T03:34:48.269Z","repository":{"id":57378882,"uuid":"134965917","full_name":"juliuste/train-ose","owner":"juliuste","description":"Client for the Greek trainOSE railway API.","archived":true,"fork":false,"pushed_at":"2020-06-01T07:38:47.000Z","size":129,"stargazers_count":6,"open_issues_count":15,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-06T19:22:10.730Z","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":"2018-05-26T13:57:15.000Z","updated_at":"2025-04-06T19:18:08.000Z","dependencies_parsed_at":"2022-09-05T07:01:42.216Z","dependency_job_id":null,"html_url":"https://github.com/juliuste/train-ose","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%2Ftrain-ose","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliuste%2Ftrain-ose/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliuste%2Ftrain-ose/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliuste%2Ftrain-ose/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/juliuste","download_url":"https://codeload.github.com/juliuste/train-ose/tar.gz/refs/heads/master","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","railway"],"created_at":"2024-10-16T01:09:13.392Z","updated_at":"2025-04-08T03:34:48.009Z","avatar_url":"https://github.com/juliuste.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# train-ose\n\nJavaScript client for the Greek 🇬🇷 [trainOSE](https://www.trainose.gr) railway API. Inofficial, using *trainOSE* endpoints. Ask them for permission before using this module in production.\n\n[![npm version](https://img.shields.io/npm/v/train-ose.svg)](https://www.npmjs.com/package/train-ose)\n[![Build Status](https://travis-ci.org/juliuste/train-ose.svg?branch=master)](https://travis-ci.org/juliuste/train-ose)\n[![Greenkeeper badge](https://badges.greenkeeper.io/juliuste/train-ose.svg)](https://greenkeeper.io/)\n[![license](https://img.shields.io/github/license/juliuste/train-ose.svg?style=flat)](license)\n[![fpti-js version](https://fpti-js.badges.juliustens.eu/badge/juliuste/train-ose)](https://fpti-js.badges.juliustens.eu/link/juliuste/train-ose)\n[![chat on gitter](https://badges.gitter.im/juliuste.svg)](https://gitter.im/juliuste)\n\n## Installation\n\n```shell\nnpm install --save train-ose\n```\n\n## Usage\n\n```javascript\nconst trainOSE = require('train-ose')\n```\n\nThe `train-ose` 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 *TrainOSE* network, such as `Αθήνα` (Athens) or `Θεσσαλονίκη` (Thessaloniki) | [✅ 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[`edges()`](#edges) | All pairs of adjacent stations and their distance (as in *edges* of the greek railway network graph) | ❌ no\n\n---\n\n### `stations.all([opt])`\n\nGet **all** stations of the *TrainOSE* network, such as `Αθήνα` (Athens) or `Θεσσαλονίκη` (Thessaloniki). 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 trainOSE = require('train-ose')\nconst stationStream = trainOSE.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: \"ΑΘΗΝ\",\n    name: \"Αθήνα\",\n    nameEnglish: \"Athens\",\n    location: {\n        type: \"location\",\n        longitude: 23.720840454101562,\n        latitude: 37.992610931396484,\n        country: \"GR\",\n        timezone: \"Europe/Athens\"\n    },\n    active: true\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\n**Please note that this module fetches a list of stations using the `stations.all()` method upon initialization, which takes about 1 second.**\n\nAlso note 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/Athens` time zone.\n\n#### Example\n\n```js\nconst athens = 'ΑΘΗΝ' // station id\nconst thessaloniki = { // FPTF station\n\ttype: 'station',\n\tid: 'ΘΕΣΣ'\n\t// …\n}\ntrainOSE.journeys(athens, thessaloniki, { when: new Date('2019-06-27T05:00:00+0200'), transfers: 0 }).then(…)\n```\n\n```js\n{\n    type: \"journey\",\n    legs: [\n        {\n            origin: {\n                type: \"station\",\n                id: \"ΑΘΗΝ\",\n                name: \"Αθήνα\",\n                nameEnglish: \"Athens\",\n                location: {\n                    type: \"location\",\n                    longitude: 23.720840454101562,\n                    latitude: 37.992610931396484,\n                    country: \"GR\",\n                    timezone: \"Europe/Athens\"\n                },\n                active: true\n            },\n            destination: {\n                type: \"station\",\n                id: \"ΘΕΣΣ\",\n                name: \"Θεσσαλονίκη\",\n                nameEnglish: \"Thessaloniki\",\n                location: {\n                    type: \"location\",\n                    longitude: 22.929779052734375,\n                    latitude: 40.6444091796875,\n                    country: \"GR\",\n                    timezone: \"Europe/Athens\"\n                },\n                active: true\n            },\n            departure: \"2019-06-27T06:22:00.000+03:00\",\n            arrival: \"2019-06-27T10:32:00.000+03:00\",\n            mode: \"train\",\n            public: true,\n            operator: {\n                type: \"operator\",\n                id: \"trainOSE\",\n                name: \"trainOSE\",\n                url: \"https://www.trainose.gr\"\n            },\n            line: {\n                type: \"line\",\n                id: \"50\",\n                name: \"50\",\n                mode: \"train\",\n                operator: {\n                    type: \"operator\",\n                    id: \"trainOSE\",\n                    name: \"trainOSE\",\n                    url: \"https://www.trainose.gr\"\n                }\n            },\n            price: {\n                currency: \"EUR\",\n                amount: 25.1,\n                class: \"B\",\n                reduced: false,\n                available: 218\n            },\n            tariffs: [\n                {\n                    currency: \"EUR\",\n                    amount: 35.1,\n                    class: \"A\",\n                    reduced: false,\n                    available: 52\n                },\n                {\n                    currency: \"EUR\",\n                    amount: 20.3,\n                    class: \"A\",\n                    reduced: true,\n                    available: 52\n                },\n                {\n                    currency: \"EUR\",\n                    amount: 25.1,\n                    class: \"B\",\n                    reduced: false,\n                    available: 218\n                },\n                {\n                    currency: \"EUR\",\n                    amount: 20.3,\n                    class: \"B\",\n                    reduced: true,\n                    available: 218\n                }\n            ]\n        }\n    ],\n    price: {\n        amount: 25.1,\n        currency: \"EUR\",\n        class: \"B\",\n        reduced: false,\n        available: 218\n    },\n    id: \"ΑΘΗΝ_2019-06-27T06:22:00.000+03:00_ΘΕΣΣ_2019-06-27T10:32:00.000+03:00_50\"\n}\n```\n\n---\n\n### `edges()`\n\nAll pairs of adjacent stations and their distance (as in *edges* of the greek railway network graph). Returns a `Readable` stream in object mode.\n\n#### Example\n\n```js\nconst edgeStream = trainOSE.edges()\nedgeStream.on('data', item =\u003e {\n    console.log(item)\n})\n```\n\n```js\n{\n    \"source\": \"ΑΓΥΑ\",\n    \"target\": \"ΚΑΣΛ\",\n    \"distance\": 2.1\n}\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/train-ose/issues).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuliuste%2Ftrain-ose","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjuliuste%2Ftrain-ose","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuliuste%2Ftrain-ose/lists"}