{"id":17367444,"url":"https://github.com/juliuste/pkp-ic","last_synced_at":"2025-04-08T03:34:45.587Z","repository":{"id":57325396,"uuid":"122365686","full_name":"juliuste/pkp-ic","owner":"juliuste","description":"PKP Intercity API client.","archived":false,"fork":false,"pushed_at":"2020-06-01T07:38:21.000Z","size":72,"stargazers_count":18,"open_issues_count":6,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-10-27T06:22:28.660Z","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-02-21T17:01:01.000Z","updated_at":"2024-10-11T16:07:32.000Z","dependencies_parsed_at":"2022-09-09T05:50:53.374Z","dependency_job_id":null,"html_url":"https://github.com/juliuste/pkp-ic","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%2Fpkp-ic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliuste%2Fpkp-ic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliuste%2Fpkp-ic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliuste%2Fpkp-ic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/juliuste","download_url":"https://codeload.github.com/juliuste/pkp-ic/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223300827,"owners_count":17122697,"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:41:28.715Z","updated_at":"2024-11-06T07:32:50.703Z","avatar_url":"https://github.com/juliuste.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pkp-ic\n\nJavaScript client for the [PKP intercity](https://www.intercity.pl/) API. Complies with the [friendly public transport format](https://github.com/public-transport/friendly-public-transport-format). Inofficial, using endpoints by *PKP IC*. Ask them for permission before using this module in production. *Still in progress.*\n\n**You should probably refer to the newer [bilkom](https://github.com/juliuste/bilkom) package instead.**\n\n[![npm version](https://img.shields.io/npm/v/pkp-ic.svg)](https://www.npmjs.com/package/pkp-ic)\n[![Build Status](https://travis-ci.org/juliuste/pkp-ic.svg?branch=master)](https://travis-ci.org/juliuste/pkp-ic)\n[![Greenkeeper badge](https://badges.greenkeeper.io/juliuste/pkp-ic.svg)](https://greenkeeper.io/)\n[![dependency status](https://img.shields.io/david/juliuste/pkp-ic.svg)](https://david-dm.org/juliuste/pkp-ic)\n[![dev dependency status](https://img.shields.io/david/dev/juliuste/pkp-ic.svg)](https://david-dm.org/juliuste/pkp-ic#info=devDependencies)\n[![license](https://img.shields.io/github/license/juliuste/pkp-ic.svg?style=flat)](LICENSE)\n[![chat on gitter](https://badges.gitter.im/juliuste.svg)](https://gitter.im/juliuste)\n\n## Installation\n\n```shell\nnpm install --save pkp-ic\n```\n\n## Usage\n\nThis package contains data in the [*Friendly Public Transport Format*](https://github.com/public-transport/friendly-public-transport-format).\n\n### `stations(opt = {})`\n\nGet a list of all stations operated by PKP IC.\n\n```js\nconst pkp = require('pkp-ic')\n\npkp.stations()\n.then(console.log)\n.catch(console.error)\n```\n\n`defaults`, partially overridden by the `opt` parameter, looks like this:\n\n```js\nconst defaults = {\n    language: 'en'\n}\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        type: 'station',\n        id: '005100009',\n        name: 'Gdańsk Główny',\n        location: {\n            type: 'location',\n            longitude: 18.644014,\n            latitude: 54.355936\n        }\n    }\n    // …\n]\n```\n\n### `journeys(origin, destination, date = new Date(), opt = {})`\n\nGet connetions from A to B.\n\n```js\nconst pkp = require('pkp-ic')\n\nconst gdansk = '005100009'\nconst bydgoszcz = '005100005'\n\npkp.journeys(bydgoszcz, gdansk, new Date(), {duration: 24*60*60*1000})\n.then(console.log)\n.catch(console.error)\n```\n`origin` and `destination` can be either station ids or full FPTF station objects. `defaults`, partially overridden by the `opt` parameter, looks like this:\n\n```js\nconst defaults = {\n    // WARNING: If you set \"results\" or \"duration\", a new request will be created for every 3rd connection found since the API exposes max. 3 connections per request\n    results: null, // number of results returned\n    duration: null, // look for the next n milliseconds. if this is set, 'results' must not be set and vice versa.\n    via: null, // station id or FPTF station object\n    dateIsArrival: false, // date parameter should be treated as an arrival date instead of as a departure date\n    direct: false, // direct connetions only\n    bike: false,\n    sleeper: false,\n    couchette: false,\n    language: 'en'\n}\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 in legs, there's a line object instead.*\n\n```js\n[\n    {\n        type: \"journey\",\n        id: \"005100005@1519666620000@005100009@1519673100000@65102\",\n        legs: [\n            {\n                origin: {\n                    type: \"station\",\n                    id: \"005100005\",\n                    name: \"Bydgoszcz Główna\"\n                },\n                destination: {\n                    type: \"station\",\n                    id: \"005100009\",\n                    name: \"Gdańsk Główny\"\n                },\n                departure: \"2018-02-26T17:37:00.000Z\",\n                arrival: \"2018-02-26T19:25:00.000Z\",\n                mode: \"train\",\n                public: true,\n                line: {\n                    type: \"line\",\n                    id: \"65102\",\n                    name: \"IC 65102\",\n                    product: \"IC\",\n                    info: {\n                        95: \"wagon with a platform for disabled travellers\",\n                        JP: \"buffet\",\n                        P1: \"PKP Intercity\",\n                        RP: \"reservation obligatory\",\n                        CC: \"The ability to purchase tickets by mobile phone on m.bilkom.pl\",\n                        FB: \"Number of bicycles conveyed limited\",\n                        KL: \"air conditioning\",\n                        K: \"carriage of parcels\"\n                    }\n                },\n                operator: {\n                    type: \"operator\",\n                    id: \"PKPIC\",\n                    name: \"PKP Intercity\",\n                    url: \"https://www.intercity.pl\"\n                }\n            }\n        ]\n    }\n]\n```\n\n## Similar projects\n\n- [bilkom](https://github.com/juliuste/bilkom) - Client for the new polish Bilkom (PKP) API (includes price information)\n- [koleo](https://github.com/juliuste/koleo/) - Client for the polish Koleo (PKP) train API (includes price information)\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/pkp-ic/issues).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuliuste%2Fpkp-ic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjuliuste%2Fpkp-ic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuliuste%2Fpkp-ic/lists"}