# vbb

> A JavaScript API for Berlin & Brandenburg public transport.

Latest version **0.3.2** (published 2015-08-14) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install vbb
pnpm add vbb
yarn add vbb
bun add vbb
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.3.2 |
| Published | 2015-08-14 |
| First published | 2015-08-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 33 |
| Author | Jannis R |
| Maintainers | derhuerst |
| Keywords | vbb, berlin, brandenburg, public transport, api, open data, hafas, json, rest, fahrinfo, javascript |

## Links

- npm: https://www.npmjs.com/package/vbb
- Repository: https://github.com/derhuerst/vbb
- Issues: https://github.com/derhuerst/vbb/issues
- npm.io page: https://npm.io/package/vbb

## Dependencies (6)

- [q](https://npm.io/package/q.md) ^1.4.1
- [extend](https://npm.io/package/extend.md) ^3.0.0
- [request](https://npm.io/package/request.md) ^2.60.0
- [bluebird](https://npm.io/package/bluebird.md) ^2.9.34
- [vbb-util](https://npm.io/package/vbb-util.md) ^0.3.0
- [vbb-stations-autocomplete](https://npm.io/package/vbb-stations-autocomplete.md) ^0.1.1

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.3.2 (latest) — 2015-08-14
- 0.3.1 — 2015-08-14
- 0.3.0 — 2015-08-14
- 0.2.0 — 2015-08-06
- 0.1.1 — 2015-08-03
- 0.1.0 — 2015-08-01

## README

# vbb

*vbb* is a JavaScript **API for the Berlin & Brandenburg public transport service** (VBB). It puts a consistent and straightforward [promise](https://github.com/petkaantonov/bluebird#what-are-promises-and-why-should-i-use-them)-based interface on top of the verbose [HAFAS](http://hacon.de/hafas) REST API. *vbb* is **[MIT-licensed](LICENSE)** and embraces [prototypal programming](http://davidwalsh.name/javascript-objects-deconstruction#simpler-object-object).

[![npm version](https://img.shields.io/npm/v/vbb.svg)](https://www.npmjs.com/package/vbb)
[![dependency status](https://img.shields.io/david/derhuerst/vbb.svg)](https://david-dm.org/derhuerst)



## Installing

```shell
npm install vbb
```



## Getting Started

We `require` the *vbb* factory function and pass the [API key](http://www.vbb.de/de/article/webservices/schnittstellen-fuer-webentwickler/5070.html#testserver).

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

We have access to three methods now:

- [`locations`](docs/locations.md) to find stations, addresses and [POI](https://en.wikipedia.org/wiki/Point_of_interest)s
- [`routes`](docs/routes.md) to get routes between locations
- [`departures`](docs/departures.md) to query the next departures at a station

As an example, we will search for a route [from *Berlin Hauptbahnhof* to *Berlin Charlottenburg*](https://www.google.de/maps/dir/Berlin+Hauptbahnhof,+Europaplatz,+Berlin/S+Berlin-Charlottenburg/@52.5212391,13.3287227,13z).

First, we have to look up the `id`s of those two stations:

```javascript
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:

```javascript
{
  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](docs/index.md)



## Contributing

If you **have a question**, **found a bug** or want to **propose a feature**, have a look at [the issues page](https://github.com/derhuerst/vbb/issues).

---
_Source: https://npm.io/package/vbb · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
