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 install db-hafas-stations
Note: This Git repo does not contain the data, but the npm package does.
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).
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
.
-
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 indb-hafas-stations
. Formats and imports the stops into a Meilisearch instance.
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.