{"id":17368135,"url":"https://github.com/juliuste/korail","last_synced_at":"2025-04-08T03:34:49.750Z","repository":{"id":73761458,"uuid":"137059849","full_name":"juliuste/korail","owner":"juliuste","description":"Client for the South Korean korail railway API.","archived":true,"fork":false,"pushed_at":"2020-06-18T22:11:55.000Z","size":90,"stargazers_count":47,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-06T19:36:57.248Z","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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-06-12T11:05:58.000Z","updated_at":"2025-04-06T19:27:59.000Z","dependencies_parsed_at":null,"dependency_job_id":"7a65b559-0585-4940-8393-22beb54e0787","html_url":"https://github.com/juliuste/korail","commit_stats":{"total_commits":47,"total_committers":2,"mean_commits":23.5,"dds":"0.021276595744680882","last_synced_commit":"a75f82570c1b920d994f730a1794cd5ea3af1dba"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliuste%2Fkorail","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliuste%2Fkorail/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliuste%2Fkorail/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliuste%2Fkorail/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/juliuste","download_url":"https://codeload.github.com/juliuste/korail/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-15T23:58:30.513Z","updated_at":"2025-04-08T03:34:49.733Z","avatar_url":"https://github.com/juliuste.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# korail\n\nJavaScript client for the South Korean 🇰🇷 [korail](https://www.letskorail.com) railway API. Inofficial, using *korail* endpoints. Ask them for permission before using this module in production.\n\nThis 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.\n\n[![npm version](https://img.shields.io/npm/v/korail.svg)](https://www.npmjs.com/package/korail)\n[![Build Status](https://travis-ci.org/juliuste/korail.svg?branch=master)](https://travis-ci.org/juliuste/korail)\n[![license](https://img.shields.io/github/license/juliuste/korail.svg?style=flat)](license)\n[![fpti-js version](https://fpti-js.badges.juliustens.eu/badge/juliuste/korail)](https://fpti-js.badges.juliustens.eu/link/juliuste/korail)\n[![chat on gitter](https://badges.gitter.im/juliuste.svg)](https://gitter.im/juliuste)\n\n## Installation\n\n```shell\nnpm install korail\n```\n\n## Usage\n\n```javascript\nconst korail = require('korail')\n```\n\nThe `korail` 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 *Korail* network, such as `서울`, `부산` or `목포` | [✅ 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[`tripStopovers(tripId)`](#tripStopoverstripid) | All stopovers for a trip (all stations a given train passes) | ❌ no\n\n---\n\n### `stations.all([opt])`\n\nGet **all** stations of the *Korail* network, such as `서울`, `부산` or `목포`. 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 korail = require('korail')\nconst stationStream = korail.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: \"0001\",\n    name: \"서울\",\n    location: {\n        type: \"location\",\n        longitude: 126.9708191,\n        latitude: 37.551856\n    },\n    group: \"7\",\n    major: \"1\"\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`product` | Filter journey for specific train type | ❌ | Enum (`String`) | `KTX`, `새마을`, `무궁화` (includes 누리로), `청춘`\n\n**Please note that this module fetches a list of stations using the `stations.all()` method upon initialization, which takes about 3-4 seconds.**\n\n#### Example\n\n```js\nconst seoul = '0001' // station id\nconst busan = { // FPTF station\n\ttype: 'station',\n\tid: '0020'\n\t// …\n}\nkorail.journeys(seoul, busan, { when: new Date('2019-06-27T05:00:00+0200'), product: 'KTX', transfers: 0 }).then(…)\n```\n\n```js\n{\n    type: \"journey\",\n    id: \"0001-2019-06-27t12-00-00-000-09-00-0020-2019-06-27t14-42-00-000-09-00-ktx-127\",\n    legs: [\n        {\n            origin: {\n                type: \"station\",\n                id: \"0001\",\n                name: \"서울\",\n                location: {\n                    type: \"location\",\n                    longitude: 126.9708191,\n                    latitude: 37.551856\n                },\n                group: \"7\",\n                major: \"1\"\n            },\n            destination: {\n                type: \"station\",\n                id: \"0020\",\n                name: \"부산\",\n                location: {\n                    type: \"location\",\n                    longitude: 129.0415717,\n                    latitude: 35.1150906\n                },\n                group: \"6\",\n                major: \"21\"\n            },\n            departure: \"2019-06-27T12:00:00.000+09:00\",\n            arrival: \"2019-06-27T14:42:00.000+09:00\",\n            mode: \"train\",\n            public: true,\n            operator: {\n                type: \"operator\",\n                id: \"korail\",\n                name: \"korail\",\n                url: \"https://www.letskorail.com\"\n            },\n            line: {\n                type: \"line\",\n                id: \"127\",\n                name: \"KTX 127\",\n                product: {\n                    id: \"100\",\n                    name: \"KTX\"\n                },\n                mode: \"train\",\n                operator: {\n                    type: \"operator\",\n                    id: \"korail\",\n                    name: \"korail\",\n                    url: \"https://www.letskorail.com\"\n                }\n            },\n            tripId: \"127###20190627\"\n        }\n    ],\n    price: {\n        amount: 59800,\n        currency: \"KRW\"\n    }\n}\n```\n\n---\n\n### `tripStopovers(tripId)`\n\nAll stopovers for a given trip (all stations a given train passes). Obtain a `tripId` 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 tripId = '127###20190627' // taken from the journeys example above\nkorail.tripStopovers(tripId).then(…)\n```\n\n```js\n[\n    {\n        type: \"stopover\",\n        stop: {\n            type: \"station\",\n            id: \"0001\",\n            name: \"서울\"\n        },\n        arrival: null,\n        departure: \"2019-06-27T12:00:00.000+09:00\"\n    },\n    {\n        type: \"stopover\",\n        stop: {\n            type: \"station\",\n            id: \"0501\",\n            name: \"광명\"\n        },\n        arrival: \"2019-06-27T12:15:00.000+09:00\",\n        departure: \"2019-06-27T12:16:00.000+09:00\"\n    },\n    {\n        type: \"stopover\",\n        stop: {\n            type: \"station\",\n            id: \"0502\",\n            name: \"천안아산\"\n        },\n        arrival: \"2019-06-27T12:37:00.000+09:00\",\n        departure: \"2019-06-27T12:39:00.000+09:00\"\n    },\n    // …\n    {\n        type: \"stopover\",\n        stop: {\n            type: \"station\",\n            id: \"0020\",\n            name: \"부산\"\n        },\n        arrival: \"2019-06-27T14:42:00.000+09:00\",\n        departure: null\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/korail/issues).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuliuste%2Fkorail","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjuliuste%2Fkorail","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuliuste%2Fkorail/lists"}