Socket
Socket
Sign inDemoInstall

vbb

Package Overview
Dependencies
62
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    vbb

A JavaScript API for Berlin & Brandenburg public transport.


Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Install size
6.26 MB
Created
Weekly downloads
 

Readme

Source

vbb

vbb is a JavaScript API for the Berlin & Brandenburg public transport service (VBB). It puts a consistent and straightforward promise-based interface on top of the verbose HAFAS REST API. vbb is MIT-licensed and embraces prototypal programming.

npm version dependency status

Installing

npm install vbb

Getting Started

We require the vbb factory function and pass the API key.

var vbb = require('vbb');
var client = vbb('<your API key>');

We have access to three methods now:

  • locations to find stations, addresses and POIs
  • routes to get routes between locations
  • departures to query the next departures at a station

As an example, we will search for a route from Berlin Hauptbahnhof to Berlin Charlottenburg.

First, we have to look up the ids of those two stations:

var Promise = require('bluebird');

Promise.join(
	client.locations('Berlin Hauptbahnhof'),   // start query promise
	client.locations('Berlin Charlottenburg'),   // dest. query promise
	function (startResults, destResults) {   // the results of both promises
		var startId = startResults[0].id;
		var destId = destResults[0].id;

		return client.routes({
			from: startId,
			to: destId
		});
	}
).then(function (routes) {
	console.log(routes[0]);
});

The output will have the following structure:

{
  duration: 600000,   // milliseconds
  parts: [   // all "sections" of the route
    {
      from: {
        title: 'S+U Berlin Hauptbahnhof',
        latitude: 52.525849,
        longitude: 13.368928,
        id: 9003201,
        type: 'station',
        notes: {
          lift: true,
          tactilePaving: true,
          escalator: true
        },
        when: Sat Aug 01 2015 15:48:00 GMT+0200 (CEST)   // `Date` object
      },
      to: {
        title: 'S Charlottenburg Bhf (Berlin)',
        latitude: 52.505048,
        longitude: 13.305212,
        id: 9024101,
        type: 'station',
        notes: {},
        when: Sat Aug 01 2015 15:58:00 GMT+0200 (CEST)   // `Date` object
      },
      transport: 'public',   // another value: `'walk'`
      type: 'suburban',   // another value: `'subway'`
      direction: 'S Spandau Bhf (Berlin)',
      notes: {}
    }
  ]
}

Documentation

vbb API Dokumentaion

Contributing

If you have a question, found a bug or want to propose a feature, have a look at the issues page.

Keywords

FAQs

Last updated on 14 Aug 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc