bahn.de APIbahn.de ↗
Search Deutsche Bahn train stations by name and find connections with live pricing, schedules, transfers, and leg-level stop data via the bahn.de API.
curl -X GET 'https://api.parse.bot/scraper/49ba8b8c-c4c8-4861-a1e8-3e46e71c6656/autocomplete_station?query=K%C3%B6ln' \ -H 'X-API-Key: $PARSE_API_KEY'
Search for train stations or locations by name. Returns station names, IDs, coordinates, and available transport products.
| Param | Type | Description |
|---|---|---|
| limit | integer | Max number of results to return |
| queryrequired | string | Partial or full name of the station (e.g. 'Berlin', 'Hamburg Hbf') |
{
"type": "object",
"fields": {
"data": "array of station objects with id, extId, name, type, lat, lon, and products"
},
"sample": {
"data": [
{
"id": "A=1@O=Berlin Hbf@X=13369549@Y=52525589@U=80@L=8011160@p=1778524813@i=U×008065969@",
"lat": 52.524925,
"lon": 13.369629,
"name": "Berlin Hbf",
"type": "ST",
"extId": "8011160",
"products": [
"ICE",
"EC_IC",
"IR",
"REGIONAL",
"SBAHN",
"BUS",
"UBAHN",
"TRAM"
]
}
],
"status": "success"
}
}About the bahn.de API
The bahn.de API exposes 2 endpoints covering Deutsche Bahn's station network and train connection search. The autocomplete_station endpoint resolves partial station names into structured records with coordinates and transport product flags, while search_connections returns full journey options between two stations including per-connection pricing, transfer counts, duration in seconds, and individual leg breakdowns with intermediate stops.
Station Search
The autocomplete_station endpoint accepts a query string — anything from a partial city name like Berl to a full station name like Hamburg Hbf — and returns an array of matching station objects. Each object includes a numeric id, an extId for external cross-referencing, a human-readable name, a type classification, geographic coordinates (lat, lon), and a products field that lists which transport modes (ICE, S-Bahn, regional rail, bus, etc.) serve that station. An optional limit parameter caps the result count.
Connection Search
The search_connections endpoint takes an origin and destination station name, a date in YYYY-MM-DD format, and a time in HH:MM format, then returns a list of available connections departing at or after that time. Each connection object carries departure and arrival timestamps, a human-readable duration, a durationSeconds integer useful for sorting or filtering programmatically, a transfers count, and a totalPrice field reflecting current DB fare data. The legs array inside each connection breaks the journey into individual segments, each with its own stop sequence.
Coverage and Data Shape
The optional class parameter accepts '1' (first class) or '2' (second class) and affects the totalPrice returned. Station names passed to search_connections follow the same naming conventions as results from autocomplete_station, so the two endpoints compose naturally: resolve an ambiguous name first, then pass the canonical name into the connection search. The API covers DB's domestic network; cross-border international routes may appear where DB operates them directly.
- Display station autocomplete suggestions in a travel booking UI using name, lat, and lon fields.
- Compare journey options by transfer count and totalPrice to surface the cheapest direct route.
- Build a fare-monitoring tool that polls search_connections daily on a fixed route and tracks totalPrice changes.
- Calculate exact journey durations in seconds using durationSeconds for logistics or scheduling applications.
- Filter connections by class parameter to show first- vs. second-class pricing side by side.
- Geocode Deutsche Bahn stations by extracting lat/lon from autocomplete_station results.
- Identify which transport products (ICE, S-Bahn, regional) serve a given station using the products field.
| Tier | Price | Credits/month | Rate limit |
|---|---|---|---|
| Free | $0/mo | 100 | 5 req/min |
| Hobby | $30/mo | 1,000 | 20 req/min |
| Developer | $100/mo | 5,000 | 250 req/min |
One credit = one API call regardless of which marketplace API you call. Exceeding the rate limit returns a 429 response. Authenticate with the X-API-Key header.