Skip to content

[work in progess] – Subscribe to data from a VDV 453 API.

License

Notifications You must be signed in to change notification settings

derhuerst/vdv-453-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vdv-453-client

A client for VDV-453 v2.6.1/VDV-454 v2.2.1 client. Can be used to connect to German public transport realtime data backends (Datendrehscheiben).

Note: This client does not support the latest spec versions VDV-453 v3.0/VDV-454 v3.0.

npm version ISC-licensed minimum Node.js version chat with me on Twitter

Installation

npm install derhuerst/vdv-453-client

Usage

With the organisation providing the VDV 453 API, you will have to agree upon a Leitstellenkennung, which is a bit like an HTTP User-Agent:

6.1.3 Leitstellenkennung Um Botschaften verschiedener Kommunikationspartner innerhalb eines Dienstes unterscheiden zu können, enthält jede Nachricht eine eindeutige Leitstellenkennung (Attribut Sender) des nachfragenden Systems. […]

const LEITSTELLE = '…'
import {createClient as createVdv453Client} from 'vdv-453-client'

const {
	httpServer,
	data,
	dfiSubscribe,
	dfiUnsubscribe,
	ausSubscribe,
	ausUnsubscribe,
} = createVdv453Client({
	leitstelle: LEITSTELLE,
	endpoint: '…', // HTTP(s) URL
})

// start HTTP server
await new Promise((resolve, reject) => {
	httpServer.listen(3000, (err) => {
		if (err) reject(err)
		else resolve()
	})
})

// subscribe to VDV-453 DFI service
const {aboId: dfiAboId} = await dfiSubscribe()
data.on('dfi:AZBNachricht', (azbNachricht) => console.log(azbNachricht))

// subscribe to VDV-454 AUS service
const {aboId: ausAboId} = await ausSubscribe()
data.on('aus:IstFahrt', (istFahrt) => console.log(istFahrt))

process.once('SIGINT', {
	Promise.all([
		dfiUnsubscribe(dfiAboId),
		ausUnsubscribe(ausAboId),
	])
	.then(() => {
		httpServer.close()
	})
	.catch(abortWithError)
})

Contributing

If you have a question or need support using vdv-453-client, please double-check your code and setup first. If you think you have found a bug or want to propose a feature, use the issues page.

About

[work in progess] – Subscribe to data from a VDV 453 API.

Resources

License

Stars

Watchers

Forks

Releases

No releases published