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

brail2stoptimes

v0.0.2

Published

Scrapes the Belgian Railway company's website for stoptimes

Downloads

8

Readme

Belgian Rail 2 stoptimes

This project generates a stream of real stoptimes between 2 time intervals for a list of stops

A stoptime?

Yes! A stoptime is 1 arrival and departure of 1 train on 1 location (a platform or station).

We particularly use the term "stoptime", as we use the stoptime ontology defined by the Open Knowledge Open Transport Working Group.

1 stoptime looks something like this:

{ "stop" : "http://irail.be/stations/NMBS/008821121#10",
  "departureTime" : "2014-12-15T18:02:00Z",
  "headsign" : "Antwerpen-Centraal",
  "@id" : "http://irail.be/stations/NMBS/008821121/stoptimes/201411115IC4517#stoptime",
  "arrivalTime" : "2014-12-15T18:00:00Z",
  "provenance" : "Charleroi-Sud"
}

How do I use it?

Easy! You install this repo using npm in your own project and you can start doing fun things:

npm install brail2stoptimes --save

And now use it in your project as follows:

var BRail2StopTimesStream = require("brail2stoptimes");
//you can find these identifiers in our https://github.com/iRail/stations repository or check the bin/example.js file
var stations = ["008718201","008718206","008500010","008832664"];
var stoptimesstream = new BRail2StopTimesStream(stations, "en", new Date(), new Date() + 2); //get for 2 days
stoptimesstream.on("data", function (stoptime) {
  //do something with it:
  if (stoptime) {
    console.log(stoptime);
  }
});

What now?

You can ingest this data in e.g., mongodb (check the bin directory) or start creating data dumps such as a GTFS dump. If you've done something, please let me know through the issue tracker.

How does it work?

It works in two steps:

  • It scrapes all stations for arrival and departure times
  • It looks up the train numbers and fetches a link to the nextStopTime

For each stoptime, we need max 4 requests:

  1. To obtain the departures in a station
  2. To obtain the arrivals in a station and link them to the departures
  3. To obtain the nextStopTime link (will be cached per train number)
  4. To obtain the nextStopTime data itself (will be cached per train number)