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

slovenske-zeleznice

v1.0.0

Published

Slovenske železnice (SŽ, Slovenian Railways) API client.

Downloads

34

Readme

slovenske-zeleznice

JavaScript client for the Slovenian 🇸🇮 Slovenske železnice (SŽ) railway API. Inofficial, using endpoints. Ask them for permission before using this module in production.

npm version Build Status Greenkeeper badge fpti-js version chat on gitter

Installation

npm install --save slovenske-zeleznice

Usage

const sz = require('slovenske-zeleznice')

The slovenske-zeleznice module conforms to the FPTI-JS 0.3.2 standard for JavaScript public transportation modules and exposes the following methods:

Method | Feature description | FPTI-JS 0.3.2 -------|---------------------|-------------------------------------------------------------------- stations.all([opt]) | All stations of the network, such as Ljubljana or Maribor | ✅ yes journeys(origin, destination, [opt]) | Journeys between stations | ✅ yes legStopovers(legId) | All stopovers for a leg (all stations the train passes on that leg) | ❌ no


stations.all([opt])

Get all stations of the network, such as Ljubljana or Maribor. See this method in the FPTI-JS 0.3.2 spec.

Supported Options

There currently aren't any supported options for this method, but this might change in a future release.

Example

const sz = require('slovenske-zeleznice')
const stationStream = sz.stations.all()

stationStream.on('data', item => {
    // item is an FPTF station object
    console.log(item)
})
{
    type: "station",
    id: "42357",
    name: "Ljubljana Brinje"
}

journeys(origin, destination, [opt])

Find journeys between stations. See this method in the FPTI-JS 0.3.2 spec.

Supported Options

Attribute | Description | FPTI-spec | Value type | Default ----------|-------------|------------|------------|-------- when | Journey date, synonym to departureAfter | ✅ | Date | new Date() departureAfter | List journeys with a departure (first leg) after this date | ✅ | Date | new Date() results | Max. number of results returned | ✅ | Number | null interval | Results for how many minutes after when/departureAfter | ✅ | Number | null transfers | Max. number of transfers | ✅ | Number | null

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/Ljubljana time zone.

Example

const ljubljana = '42300'
const maribor = { // FPTF station
	type: 'station',
	id: '43400'
	// …
}
sz.journeys(ljubljana, maribor, { when: new Date('2019-06-27T05:00:00+0200'), transfers: 0 }).then(…)
{
    type: "journey",
    id: "2004###2019-06-27###42300###43400",
    info: "Timetable valid from 9. Dec. 2018 do 14. Dec. 2019.",
    legs: [
        {
            origin: {
                type: "station",
                id: "42300",
                name: "Ljubljana"
            },
            destination: {
                type: "station",
                id: "43400",
                name: "Maribor"
            },
            departure: "2019-06-27T10:50:00.000+02:00",
            arrival: "2019-06-27T13:35:00.000+02:00",
            mode: "train",
            public: true,
            line: {
                type: "line",
                id: "2004",
                name: "LPV 2004",
                number: "2004",
                product: "LPV",
                mode: "train",
                public: true,
                operator: {
                    type: "operator",
                    id: "sž",
                    name: "Slovenske železnice",
                    url: "http://www.slo-zeleznice.si"
                }
            },
            operator: {
                type: "operator",
                id: "sž",
                name: "Slovenske železnice",
                url: "http://www.slo-zeleznice.si"
            },
            bicycle: true,
            wifi: false,
            id: "2004###2019-06-27###42300###43400"
        }
    ],
    price: {
        amount: 9.56,
        currency: "EUR"
    }
}

legStopovers(legId)

All stopovers for a given leg (all stations the train passes on that leg). Obtain a legId using the journeys(origin, destination, [opt]) method. Returns a Promise that resolves in a list of stopovers.

Example

const legId = '2004###2019-06-27###42300###43400' // taken from the journeys example above
sz.legStopovers(legId).then(…)
[
    {
        type: "stopover",
        stop: {
            type: "station",
            id: "42300",
            name: "Ljubljana"
        },
        departure: "2019-06-27T10:50:00.000+02:00",
        arrival: null
    },
    {
        type: "stopover",
        stop: {
            type: "station",
            id: "42212",
            name: "Ljubljana Polje"
        },
        departure: "2019-06-27T10:56:00.000+02:00",
        arrival: "2019-06-27T10:55:00.000+02:00"
    },
    // …
    {
        type: "stopover",
        stop: {
            type: "station",
            id: "43304",
            name: "Maribor Tezno"
        },
        departure: "2019-06-27T13:32:00.000+02:00",
        arrival: "2019-06-27T13:31:00.000+02:00"
    },
    {
        type: "stopover",
        stop: {
            type: "station",
            id: "43400",
            name: "Maribor"
        },
        departure: null,
        arrival: "2019-06-27T13:35:00.000+02:00"
    }
]

Contributing

If you found a bug or want to propose a feature, feel free to visit the issues page.