dvbjs
This is an unofficial node module, giving you a few options to query Dresden's public transport system for current bus- and tramstop data.
Want something like this for another language, look no further 🙂
Getting Started
Install the module using npm or yarn
$ npm install dvbjsor$ yarn add dvbjs
and require it in your project
;
HTTP request are handled by axios that supports all modern browsers. See packages/react-example for a browser departure monitor example.
Example Usage
Find stops by name
; // OR const dvb = require("dvbjs"); dvb.findStop"zellesch".then;
{ data: [ { city: 'Dresden', coords: [ 13.745859050200034, 51.0283698098441 ], name: 'Zellescher Weg', id: '33000312', type: 'Stop' }, { city: 'Clausthal-Zellerfeld', coords: [ 10.347333308428196, 51.80899839555576 ], name: 'Eschenbacher Straße', id: '26005221', type: 'Stop' } ]}
Monitor a single stop
; // OR const dvb = require("dvbjs"); ; // Postplatz;; dvb.monitorstopID, timeOffset, numResults.then;
[ { arrivalTime: 2020-07-31T00:40:00.000Z, scheduledTime: 2020-07-31T00:40:00.000Z, id: 'voe:21075: :R:j20', line: '75', direction: 'Postplatz', platform: { name: '8', type: 'Platform' }, arrivalTimeRelative: 21, scheduledTimeRelative: 21, delayTime: 0, state: 'Unknown', mode: { title: 'Bus', name: 'CityBus', iconUrl: 'https://www.dvb.de/assets/img/trans-icon/transport-bus.svg' }, diva: { number: 21075, network: 'voe' } }, { arrivalTime: 2020-07-31T00:45:00.000Z, scheduledTime: 2020-07-31T00:45:00.000Z, id: 'voe:11002: :R:j20', line: '2', direction: 'Kleinzschachwitz', platform: { name: '1', type: 'Platform' }, arrivalTimeRelative: 26, scheduledTimeRelative: 26, delayTime: 0, state: 'Unknown', mode: { title: 'Straßenbahn', name: 'Tram', iconUrl: 'https://www.dvb.de/assets/img/trans-icon/transport-tram.svg' }, diva: { number: 11002, network: 'voe' } }]
Find routes
; // OR const dvb = require("dvbjs"); ; // Helmholtzstraße; // Postplatz;; dvb.routeorigin, destination, startTime, isArrivalTime.then;
{ origin: { id: '33000742', name: 'Helmholtzstraße', city: 'Dresden', coords: [ 13.725468471273134, 51.0255443264448 ] }, destination: { id: '33000037', name: 'Postplatz', city: 'Dresden', coords: [ 13.733543221907427, 51.05055101347277 ] }, trips: [ { nodes: [ { stops: [ { id: '33000742', name: 'Helmholtzstraße', city: 'Dresden', type: 'Stop', platform: undefined, coords: [ 13.725468471273134, 51.0255443264448 ], arrival: 2020-07-31T01:18:00.000Z, departure: 2020-07-31T01:18:00.000Z }, { id: '33000135', name: 'Plauen Nöthnitzer Straße', city: 'Dresden', type: 'Stop', platform: { name: '1', type: 'Platform' }, coords: [ 13.716492082528102, 51.02796893475141 ], arrival: 2020-07-31T01:30:00.000Z, departure: 2020-07-31T01:30:00.000Z } ], departure: { id: '33000742', name: 'Helmholtzstraße', city: 'Dresden', platform: undefined, time: 2020-07-31T01:18:00.000Z, coords: [ 13.725468471273134, 51.0255443264448 ], type: 'Stop' }, arrival: { id: '33000135', name: 'Plauen Nöthnitzer Straße', city: 'Dresden', platform: { name: '1', type: 'Platform' }, time: 2020-07-31T01:30:00.000Z, coords: [ 13.716492082528102, 51.02796893475141 ], type: 'Stop' }, mode: { title: 'Fussweg', name: 'Footpath', iconUrl: 'https://m.dvb.de/img/walk.svg' }, line: 'Fussweg', direction: '', diva: undefined, duration: 12, path: [ [ 13.725468471273134, 51.0255443264448 ], [ 13.725454558079187, 51.025553521653286 ], ... 47 more items ] }, { stops: [ { id: '33000135', name: 'Plauen Nöthnitzer Straße', city: 'Dresden', type: 'Stop', platform: { name: '1', type: 'Platform' }, coords: [ 13.716492082528102, 51.02796893475141 ], arrival: 2020-07-31T01:30:00.000Z, departure: 2020-07-31T01:30:00.000Z }, { id: '33000134', name: 'Münchner Platz', city: 'Dresden', type: 'Stop', platform: { name: '1', type: 'Platform' }, coords: [ 13.721883037345886, 51.02995723597058 ], arrival: 2020-07-31T01:31:00.000Z, departure: 2020-07-31T01:31:00.000Z }, ... 4 more items ], departure: { id: '33000135', name: 'Plauen Nöthnitzer Straße', city: 'Dresden', platform: { name: '1', type: 'Platform' }, time: 2020-07-31T01:30:00.000Z, coords: [ 13.716492082528102, 51.02796893475141 ], type: 'Stop' }, arrival: { id: '33000032', name: 'Hauptbahnhof Nord', city: 'Dresden', platform: { name: '1', type: 'Platform' }, time: 2020-07-31T01:36:00.000Z, coords: [ 13.735187096532323, 51.041491968478326 ], type: 'Stop' }, mode: { title: 'Straßenbahn', name: 'Tram', iconUrl: 'https://www.dvb.de/assets/img/trans-icon/transport-tram.svg' }, line: '3', direction: 'Wilder Mann', diva: { number: 11003, network: 'voe' }, duration: 6, path: [ [ 13.71646358720785, 51.02796935341722 ], [ 13.71649241447995, 51.02797791957738 ], ... 38 more items ] }, ... 2 more items ], departure: { id: '33000742', name: 'Helmholtzstraße', city: 'Dresden', platform: undefined, time: 2020-07-31T01:18:00.000Z, coords: [ 13.725468471273134, 51.0255443264448 ], type: 'Stop' }, arrival: { id: '33000037', name: 'Postplatz', city: 'Dresden', platform: { name: '4', type: 'Platform' }, time: 2020-07-31T01:42:00.000Z, coords: [ 13.733543221907427, 51.05055101347277 ], type: 'Stop' }, duration: 24, interchanges: 1 }, { nodes: [ { stops: [ { id: '33000742', name: 'Helmholtzstraße', city: 'Dresden', type: 'Stop', platform: undefined, coords: [ 13.725468471273134, 51.0255443264448 ], arrival: 2020-07-31T01:48:00.000Z, departure: 2020-07-31T01:48:00.000Z }, { id: '33000135', name: 'Plauen Nöthnitzer Straße', city: 'Dresden', type: 'Stop', platform: { name: '1', type: 'Platform' }, coords: [ 13.716492082528102, 51.02796893475141 ], arrival: 2020-07-31T02:00:00.000Z, departure: 2020-07-31T02:00:00.000Z } ], departure: { id: '33000742', name: 'Helmholtzstraße', city: 'Dresden', platform: undefined, time: 2020-07-31T01:48:00.000Z, coords: [ 13.725468471273134, 51.0255443264448 ], type: 'Stop' }, arrival: { id: '33000135', name: 'Plauen Nöthnitzer Straße', city: 'Dresden', platform: { name: '1', type: 'Platform' }, time: 2020-07-31T02:00:00.000Z, coords: [ 13.716492082528102, 51.02796893475141 ], type: 'Stop' }, mode: { title: 'Fussweg', name: 'Footpath', iconUrl: 'https://m.dvb.de/img/walk.svg' }, line: 'Fussweg', direction: '', diva: undefined, duration: 12, path: [ [ 13.725468471273134, 51.0255443264448 ], [ 13.725454558079187, 51.025553521653286 ], ... 47 more items ] }, { stops: [ { id: '33000135', name: 'Plauen Nöthnitzer Straße', city: 'Dresden', type: 'Stop', platform: { name: '1', type: 'Platform' }, coords: [ 13.716492082528102, 51.02796893475141 ], arrival: 2020-07-31T02:00:00.000Z, departure: 2020-07-31T02:00:00.000Z }, { id: '33000134', name: 'Münchner Platz', city: 'Dresden', type: 'Stop', platform: { name: '1', type: 'Platform' }, coords: [ 13.721883037345886, 51.02995723597058 ], arrival: 2020-07-31T02:01:00.000Z, departure: 2020-07-31T02:01:00.000Z }, ... 4 more items ], departure: { id: '33000135', name: 'Plauen Nöthnitzer Straße', city: 'Dresden', platform: { name: '1', type: 'Platform' }, time: 2020-07-31T02:00:00.000Z, coords: [ 13.716492082528102, 51.02796893475141 ], type: 'Stop' }, arrival: { id: '33000032', name: 'Hauptbahnhof Nord', city: 'Dresden', platform: { name: '1', type: 'Platform' }, time: 2020-07-31T02:06:00.000Z, coords: [ 13.735187096532323, 51.041491968478326 ], type: 'Stop' }, mode: { title: 'Straßenbahn', name: 'Tram', iconUrl: 'https://www.dvb.de/assets/img/trans-icon/transport-tram.svg' }, line: '3', direction: 'Wilder Mann', diva: { number: 11003, network: 'voe' }, duration: 6, path: [ [ 13.71646358720785, 51.02796935341722 ], [ 13.71649241447995, 51.02797791957738 ], ... 38 more items ] }, ... 2 more items ], departure: { id: '33000742', name: 'Helmholtzstraße', city: 'Dresden', platform: undefined, time: 2020-07-31T01:48:00.000Z, coords: [ 13.725468471273134, 51.0255443264448 ], type: 'Stop' }, arrival: { id: '33000037', name: 'Postplatz', city: 'Dresden', platform: { name: '4', type: 'Platform' }, time: 2020-07-31T02:12:00.000Z, coords: [ 13.733543221907427, 51.05055101347277 ], type: 'Stop' }, duration: 24, interchanges: 1 }, ... 3 more items ]}
API Documentation
Table of contents
index.ts
Functions
coords
Find the coordinates for a given POI id.
;
Parameters
Name | Type | Default value | Description |
---|---|---|---|
id | string | the POI ID | |
timeout | number | 5000 | the timeout of the request |
Return type
Promise<number[] | undefined>
findAddress
Lookup address and nearby stops by coordinate.
;
Parameters
Name | Type | Default value | Description |
---|---|---|---|
lng | number | longitude of the coordinate | |
lat | number | latitude of the coordinate | |
timeout | number | 5000 | the timeout of the request |
Return type
Promise<IAddress | undefined>
findPOI
Search for POI in the network of the DVB.
;
Parameters
Name | Type | Default value | Description |
---|---|---|---|
searchString | string | the name of the stop | |
timeout | number | 5000 | the timeout of the request |
Return type
Promise<IPoint[]>
findStop
Search for a single stop in the network of the DVB.
;
Parameters
Name | Type | Default value | Description |
---|---|---|---|
searchString | string | the name of the stop | |
timeout | number | 5000 | the timeout of the request |
Return type
Promise<IPoint[]>
lines
get a list of availible tram/bus lines for a stop.
;
Parameters
Name | Type | Default value | Description |
---|---|---|---|
stopID | string | the stop ID | |
timeout | number | 5000 | the timeout of the request |
Return type
Promise<ILine[]>
monitor
Monitor a single stop to see every bus or tram leaving this stop after the specified time offset.
;
Parameters
Name | Type | Default value | Description |
---|---|---|---|
stopID | string | ID of the stop | |
offset | number | 0 | how many minutes in the future, 0 for now |
amount | number | 0 | number of results |
timeout | number | 5000 | the timeout of the request |
Return type
Promise<IMonitor[]>
pins
Search for different kinds of POIs inside a given bounding box.
;
Parameters
Name | Type | Default value | Description |
---|---|---|---|
swlng | number | the longitude of the south west coordinate | |
swlat | number | the latitude of the south west coordinate | |
nelng | number | the longitude of the north east coordinate | |
nelat | number | the latitude of the north east coordinate | |
pinTypes | PIN_TYPE[] | [PIN_TYPE.stop] | array of pin types |
timeout | number | 5000 | the timeout of the request |
Return type
Promise<IPin[]>
route
Query the server for possible routes from one stop to another.
;
Parameters
Name | Type | Default value | Description |
---|---|---|---|
originID | string | the id of the origin stop | |
destinationID | string | the id of the destination stop | |
time | Date | new Date() | starting at what time |
isArrivalTime | boolean | true | is time the arrival time |
timeout | number | 15000 | the timeout of the request |
Return type
Promise<IRoute>
Interfaces
IDiva
Properties
Name | Type | Optional |
---|---|---|
number | number | false |
network | string | true |
IPlatform
Properties
Name | Type | Optional |
---|---|---|
name | string | false |
type | string | false |
IPin
- The id for PIN_TYPE.platform is always an empty string.
- PIN_TYPE.platform conatins platform_nr.
- PIN_TYPE.stop contains connections.
- PIN_TYPE.parkandride contains info.
Properties
Name | Type | Optional |
---|---|---|
id | string | false |
type | PIN_TYPE | false |
name | string | false |
coords | Array | false |
platformNr | string | true |
connections | IConnection[] | true |
info | string | true |
IConnection
Properties
Name | Type | Optional |
---|---|---|
line | string | false |
mode | IMode | true |
IMode
Properties
Name | Type | Optional |
---|---|---|
title | string | false |
name | string | false |
iconUrl | string | true |
IAddress
Extends
Properties
Name | Type | Optional |
---|---|---|
stops | IPoint[] | false |
ILine
Properties
Name | Type | Optional |
---|---|---|
name | string | false |
mode | IMode | true |
diva | IDiva | true |
directions | string[] | false |
IMonitor
Properties
Name | Type | Optional |
---|---|---|
arrivalTime | Date | false |
scheduledTime | Date | false |
id | string | false |
line | string | false |
direction | string | false |
platform | IPlatform | true |
arrivalTimeRelative | number | false |
scheduledTimeRelative | number | false |
delayTime | number | false |
state | string | false |
mode | IMode | true |
diva | IDiva | true |
ILocation
Properties
Name | Type | Optional |
---|---|---|
id | string | false |
name | string | false |
city | string | false |
coords | Array | false |
IPoint
Extends
Properties
Name | Type | Optional |
---|---|---|
type | POI_TYPE | false |
IStop
Extends
Properties
Name | Type | Optional |
---|---|---|
type | string | false |
platform | IPlatform | true |
arrival | Date | false |
departure | Date | false |
IStopLocation
Extends
Properties
Name | Type | Optional |
---|---|---|
platform | IPlatform | true |
time | Date | false |
type | string | false |
INode
Properties
Name | Type | Optional |
---|---|---|
stops | IStop[] | false |
departure | IStopLocation | true |
arrival | IStopLocation | true |
mode | IMode | true |
line | string | false |
direction | string | false |
diva | IDiva | true |
duration | number | false |
path | Array[] | false |
ITrip
Properties
Name | Type | Optional |
---|---|---|
departure | IStopLocation | true |
arrival | IStopLocation | true |
duration | number | false |
interchanges | number | false |
nodes | INode[] | false |
IRoute
Properties
Name | Type | Optional |
---|---|---|
origin | ILocation | true |
destination | ILocation | true |
trips | ITrip[] | false |
Types
coord
WGS84 coordinates [lng, lat]
;
Type
number[]
Enums
POI_TYPE
Members
Name | Value |
---|---|
Address | "Address" |
Coords | "Coords" |
POI | "POI" |
Stop | "Stop" |
PIN_TYPE
Members
Name | Value |
---|---|
stop | "stop" |
platform | "platform" |
poi | "poi" |
rentabike | "rentabike" |
ticketmachine | "ticketmachine" |
carsharing | "carsharing" |
parkandride | "parkandride" |
unknown | "unknown" |