npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

pkp-ic

v1.0.1

Published

PKP Intercity API client

Downloads

39

Readme

pkp-ic

JavaScript client for the PKP intercity API. Complies with the friendly public transport format. Inofficial, using endpoints by PKP IC. Ask them for permission before using this module in production. Still in progress.

You should probably refer to the newer bilkom package instead.

npm version Build Status Greenkeeper badge dependency status dev dependency status license chat on gitter

Installation

npm install --save pkp-ic

Usage

This package contains data in the Friendly Public Transport Format.

stations(opt = {})

Get a list of all stations operated by PKP IC.

const pkp = require('pkp-ic')

pkp.stations()
.then(console.log)
.catch(console.error)

defaults, partially overridden by the opt parameter, looks like this:

const defaults = {
    language: 'en'
}

Returns a Promise that will resolve in an array of stations in the Friendly Public Transport Format which looks as follows:

[
    {
        type: 'station',
        id: '005100009',
        name: 'Gdańsk Główny',
        location: {
            type: 'location',
            longitude: 18.644014,
            latitude: 54.355936
        }
    }
    // …
]

journeys(origin, destination, date = new Date(), opt = {})

Get connetions from A to B.

const pkp = require('pkp-ic')

const gdansk = '005100009'
const bydgoszcz = '005100005'

pkp.journeys(bydgoszcz, gdansk, new Date(), {duration: 24*60*60*1000})
.then(console.log)
.catch(console.error)

origin and destination can be either station ids or full FPTF station objects. defaults, partially overridden by the opt parameter, looks like this:

const defaults = {
    // 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
    results: null, // number of results returned
    duration: null, // look for the next n milliseconds. if this is set, 'results' must not be set and vice versa.
    via: null, // station id or FPTF station object
    dateIsArrival: false, // date parameter should be treated as an arrival date instead of as a departure date
    direct: false, // direct connetions only
    bike: false,
    sleeper: false,
    couchette: false,
    language: 'en'
}

Returns a Promise that will resolve with an array of journeys in the Friendly Public Transport Format which looks as follows. Note that the legs are not fully spec-compatible, as the schedule is missing in legs, there's a line object instead.

[
    {
        type: "journey",
        id: "005100005@1519666620000@005100009@1519673100000@65102",
        legs: [
            {
                origin: {
                    type: "station",
                    id: "005100005",
                    name: "Bydgoszcz Główna"
                },
                destination: {
                    type: "station",
                    id: "005100009",
                    name: "Gdańsk Główny"
                },
                departure: "2018-02-26T17:37:00.000Z",
                arrival: "2018-02-26T19:25:00.000Z",
                mode: "train",
                public: true,
                line: {
                    type: "line",
                    id: "65102",
                    name: "IC 65102",
                    product: "IC",
                    info: {
                        95: "wagon with a platform for disabled travellers",
                        JP: "buffet",
                        P1: "PKP Intercity",
                        RP: "reservation obligatory",
                        CC: "The ability to purchase tickets by mobile phone on m.bilkom.pl",
                        FB: "Number of bicycles conveyed limited",
                        KL: "air conditioning",
                        K: "carriage of parcels"
                    }
                },
                operator: {
                    type: "operator",
                    id: "PKPIC",
                    name: "PKP Intercity",
                    url: "https://www.intercity.pl"
                }
            }
        ]
    }
]

Similar projects

  • bilkom - Client for the new polish Bilkom (PKP) API (includes price information)
  • koleo - Client for the polish Koleo (PKP) train API (includes price information)

Contributing

If 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.