Skip to content

A list of most stations known by Deutsche Bahn, fetched from their APIs.

License

ISC, Unknown licenses found

Licenses found

ISC
license.md
Unknown
license-data.md
Notifications You must be signed in to change notification settings

derhuerst/db-hafas-stations

Repository files navigation

db-hafas-stations

All Deutsche Bahn (DB) stations, including local public transport (buses, trams...) stops, currently about 290k. Returned by their RIS::Stations and StaDa APIs (DB InfraGO, CC BY 4.0 and OpenStreetMap Contributors). These use the same evaNumbers and names as the DB HAFAS that historically has been the source of this data.

npm version ISC-licensed minimum Node.js version support me via GitHub Sponsors chat with me on Twitter

Installation

npm install db-hafas-stations

Note: This Git repo does not contain the data, but the npm package does.

Usage

readSimplifiedStations() is an async generator function yielding Friendly Public Transport Format station and stop objects, read from db-hafas-stations/data.ndjson (~14mb).

import {
	readSimplifiedStations,
	readFullStations,
} from 'db-hafas-stations'

for await const (station of readSimplifiedStations()) {
	console.log(station)
}
{
	type: 'station',
	id: '8000007',
	name: 'Alzey',
	weight: 73.1,
	location: {
		type: 'location',
		latitude: 49.7502,
		longitude: 8.109749
	}
}
// …

readFullStations() is an async generator function yielding objects with more fields, read from db-hafas-stations/full.ndjson (~112mb).

Building

You need to subscribe to both the RIS::Stations and StaDa API and set the corresponding environment variables DB_CLIENT_ID and DB_API_KEY before running npm run fetch to fetch the data from the APIs (run carefully and not frequently, the quotas are very low!) and npm run merge.

Related

  • db-hafas-stations-autocomplete – Search for stations of DB (data from HAFAS).
  • db-stations – A collection of just the train stations of Deutsche Bahn, computed from open data.
  • hafas-find-stations – Given a HAFAS client, find all stations in a bounding box.
  • hafas-discover-stations – Pass in a HAFAS client, discover stations by querying departures.
  • db-stops-search – Search through all stops/stations in db-hafas-stations. Formats and imports the stops into a Meilisearch instance.

Contributing

If you have a question or have difficulties using db-hafas-stations, please double-check your code and setup first. If you think you have found a bug or want to propose a feature, refer to the issues page.

About

A list of most stations known by Deutsche Bahn, fetched from their APIs.

Topics

Resources

License

ISC, Unknown licenses found

Licenses found

ISC
license.md
Unknown
license-data.md

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

  •  

Contributors 2

  •  
  •