베를린 및 브란덴부르크 대중교통 서비스(VBB)의 클라이언트입니다. 자세한 API를 기반으로 일관되고 간단한 인터페이스 역할을 합니다.
이 프로젝트는 실제로 hafas-client@6
둘러싼 얇은 래퍼입니다. 해당 문서에는 일반적인 API가 문서화되어 있습니다.
참고 : VBB API를 직접 쿼리하고 싶지 않을 수도 있습니다. vbb-client
는 내 래퍼 API인 vbb-rest
에 대한 API 호환 클라이언트입니다. 브라우저에서도 작동합니다.
npm install vbb-hafas
hafas-client
및 VBB 관련 사용자 정의에 대한 문서를 확인하세요.
const createHafas = require ( 'vbb-hafas' )
const hafas = createHafas ( 'my-awesome-program' )
예를 들어, Berlin Hauptbahnhof 에서 Berlin Charlottenburg 까지의 여정을 검색하겠습니다. 스테이션 ID를 얻으려면 vbb-stations
사용하세요.
hafas . journeys ( '900000003201' , '900000024101' , { results : 1 } )
. then ( ( journeys ) => console . log ( journeys [ 0 ] ) )
. catch ( console . error )
출력은 Friendly Public Transport Format 1.2.1
형식의 journey
개체 배열입니다.
[ {
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'
// …
} ]
transferInfo: true
옵션으로 전달하면 vbb-hafas
vbb-change-positions
에서 전송 정보를 추가하려고 시도합니다.
알려진 환승을 식별하는 경우 이전 구간에는 bestArrivalPosition
이 있고 다음 구간에는 두 플랫폼 간의 최적 환승을 나타내는 departurePosition
가 있습니다. 자세한 내용은 vbb-change-positions
의 마크업을 확인하세요.
hafas-client
관련 프로젝트를 확인해보세요.
질문이 있거나 버그를 발견했거나 기능을 제안하고 싶다면 이슈 페이지를 살펴보세요.