Ein Kunde für den Verkehrsbetrieb Berlin & Brandenburg (VBB). Es fungiert als konsistente und unkomplizierte Schnittstelle zusätzlich zu einer ausführlichen API.
Dieses Projekt ist eigentlich eine dünne Hülle um hafas-client@6
. Seine Dokumente dokumentieren die API im Allgemeinen.
Hinweis : Möglicherweise möchten Sie die VBB-API nicht selbst abfragen. vbb-client
ist ein API-kompatibler Client für vbb-rest
, meine Wrapper-API. Es funktioniert auch im Browser.
npm install vbb-hafas
Sehen Sie sich die Dokumente für hafas-client
sowie seine VBB-spezifischen Anpassungen an.
const createHafas = require ( 'vbb-hafas' )
const hafas = createHafas ( 'my-awesome-program' )
Als Beispiel suchen wir nach einer Fahrt von Berlin Hauptbahnhof nach Berlin Charlottenburg . Um die Stations-IDs zu erhalten, verwenden Sie vbb-stations
.
hafas . journeys ( '900000003201' , '900000024101' , { results : 1 } )
. then ( ( journeys ) => console . log ( journeys [ 0 ] ) )
. catch ( console . error )
Die Ausgabe wird ein Array von journey
im Friendly Public Transport Format 1.2.1
-Format sein:
[ {
legs : [ {
tripId : '1|50420|0|86|25122017' ,
direction : 'Brandenburg, Hbf' ,
line : {
type : 'line' ,
id : '10' ,
name : 'RE1' ,
public : true ,
mode : 'train' ,
product : 'regional' ,
symbol : 'RE' ,
nr : 1 ,
metro : false ,
express : true ,
night : false ,
class : 64 ,
productCode : 6 ,
operator : {
type : 'operator' ,
id : 'db-regio-ag' ,
name : 'DB Regio AG'
}
} ,
origin : {
type : 'station' ,
id : '900000003201' ,
name : 'S+U Berlin Hauptbahnhof' ,
location : {
type : 'location' ,
latitude : 52.52585 ,
longitude : 13.368928
} ,
products : {
suburban : true ,
subway : true ,
tram : true ,
bus : true ,
ferry : false ,
express : true ,
regional : true
}
} ,
departure : '2017-12-26T00:41:00.000+01:00' ,
plannedDeparture : '2017-12-26T00:41:00.000+01:00' ,
departureDelay : 0 ,
departurePlatform : '14' ,
plannedDeparturePlatform : '13' ,
destination : {
type : 'station' ,
id : '900000024101' ,
name : 'S Charlottenburg' ,
location : {
type : 'location' ,
latitude : 52.504806 ,
longitude : 13.303846
} ,
products : {
suburban : true ,
subway : false ,
tram : false ,
bus : true ,
ferry : false ,
express : false ,
regional : true
}
} ,
arrival : '2017-12-26T00:50:00.000+01:00' ,
plannedArrival : '2017-12-26T00:50:00.000+01:00' ,
arrivalDelay : null ,
arrivalPlatform : '4' ,
plannedArrivalPlatform : '4'
} ] ,
// all these are from the first leg
origin : {
type : 'station' ,
id : '900000003201' ,
name : 'S+U Berlin Hauptbahnhof'
// …
} ,
departure : '2017-12-26T00:41:00.000+01:00' ,
plannedDeparture : '2017-12-26T00:41:00.000+01:00' ,
departureDelay : 0 ,
departurePlatform : '14' ,
plannedDeparturePlatform : '13' ,
// all these are from the last leg
destination : {
type : 'station' ,
id : '900000024101' ,
name : 'S Charlottenburg'
// …
} ,
arrival : '2017-12-26T00:50:00.000+01:00' ,
plannedArrival : '2017-12-26T00:50:00.000+01:00' ,
arrivalDelay : null ,
arrivalPlatform : '4' ,
plannedArrivalPlatform : '4'
// …
} ]
vbb-hafas
wird versuchen, Übertragungsinformationen von vbb-change-positions
hinzuzufügen, wenn Sie transferInfo: true
als Option übergeben.
Wenn ein bekannter Transfer identifiziert wird, hat der vorherige Abschnitt eine bestArrivalPosition
und der nächste Abschnitt departurePosition
, was den optimalen Transfer zwischen beiden Plattformen angibt. Weitere Informationen finden Sie im Markup in vbb-change-positions
.
Überprüfen Sie die zugehörigen Projekte von hafas-client
.
Wenn Sie eine Frage haben , einen Fehler gefunden haben oder eine Funktion vorschlagen möchten, schauen Sie sich die Seite „Probleme“ an.