Discover/bahn.com API
live

bahn.com APIbahn.com

Access Deutsche Bahn station data, train connections, ticket offers, and regional transit associations via the bahn.com API. 5 endpoints.

Endpoints
5
Updated
10d ago
Try it
Station name search query (e.g., 'Berlin', 'München')
api.parse.bot/scraper/7dfccc04-525c-426d-8322-a10e7d62cd3b/<endpoint>
Ready to send
Fill in the parameters and hit sign in to send to see live response data here.
Use it in your codegrab a free API key at signup
curl -X GET 'https://api.parse.bot/scraper/7dfccc04-525c-426d-8322-a10e7d62cd3b/get_station_autocomplete?query=Berlin' \
  -H 'X-API-Key: $PARSE_API_KEY'
All endpoints · 5 totalclick to expand

Search for stations by name. Returns a list of stations with their internal HAFAS IDs, coordinates, and available transport products.

Input
ParamTypeDescription
queryrequiredstringStation name search query (e.g., 'Berlin', 'München')
Response
{
  "type": "object",
  "fields": {
    "data": "array of station objects with id, extId, name, lat, lon, type, and products fields",
    "status": "string indicating success"
  },
  "sample": {
    "data": [
      {
        "id": "A=1@O=Berlin Hbf@X=13369549@Y=52525589@U=80@L=8011160@p=1777919315@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.com API

The bahn.com API provides 5 endpoints covering Deutsche Bahn station lookup, train connection search, and ticket offer retrieval. Use get_station_autocomplete to search stations by name and receive HAFAS IDs, coordinates, and transport product flags. Other endpoints expose traveler types, BahnCard discount codes, and regional transit association metadata for Germany's rail network.

Station and Reference Data

The get_station_autocomplete endpoint accepts a query string (e.g., 'Berlin' or 'München') and returns an array of matching station objects. Each object includes an id, an extId (the full HAFAS identifier used in connection searches), name, lat/lon coordinates, a type field, and a products field indicating which transport modes serve that station (e.g., long-distance rail, S-Bahn, bus).

The get_metadata endpoint requires no inputs and returns a structured object with five arrays: reisendenTypen (traveler types such as adult or child), reisendenTypenAll, ermaessigungsArten (BahnCard discount types), einstiegsTypen (boarding/entry types), and produktInfo (product definitions). This data is useful for populating dropdowns or validating parameters before submitting connection searches. get_transit_associations similarly requires no inputs and returns a list of German regional transit associations (Verkehrsverbünde), each with a code, kuerzel (abbreviation), description, shortDescription, logo URL, and a hatShop boolean indicating whether that association has an online shop.

Connection Search and Ticket Offers

search_connections accepts an origin_id and destination_id (both full HAFAS IDs from get_station_autocomplete) and an optional ISO 8601 departure_time. It returns a data object containing connection options with journey times, durations, and pricing where available. Note that this endpoint may be blocked in some environments due to WAF restrictions on the source site, so expect variable availability. Once you have a connection result, each journey includes a ctxRecon token. Pass that token to get_ticket_offers to retrieve detailed fare and ticket offer data for that specific connection.

Coverage Scope

All five endpoints are oriented around Deutsche Bahn's domestic and cross-border rail network. Station lookups cover DB-served stations with HAFAS identifiers. Transit association data covers German Verkehrsverbünde only. The connection search and ticket endpoints depend on HAFAS IDs obtained from the station autocomplete endpoint, so that lookup is the natural entry point for any journey-planning workflow.

Common use cases
  • Build a station autocomplete widget using name, lat, lon, and products fields from get_station_autocomplete
  • Populate BahnCard discount dropdowns in a booking form using ermaessigungsArten from get_metadata
  • Map all regional transit associations in Germany with their logos and shop links using get_transit_associations
  • Query train connections between two cities by passing HAFAS extId values to search_connections
  • Retrieve fare breakdowns for a specific journey by passing a ctxRecon token to get_ticket_offers
  • Filter stations by transport product type (e.g., only ICE-served stations) using the products field
  • Validate traveler type inputs in a booking UI using reisendenTypen from get_metadata
Pricing & limitsSee full pricing →
TierPriceCredits/monthRate limit
Free$0/mo1005 req/min
Hobby$30/mo1,00020 req/min
Developer$100/mo5,000250 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.

Frequently asked questions
Does Deutsche Bahn offer an official developer API?+
Deutsche Bahn publishes a limited set of APIs under the DB API Marketplace at developers.deutschebahn.com, covering areas like timetables and station data. Coverage and access tiers differ from what this bahn.com API exposes.
What does `get_station_autocomplete` return beyond station names?+
Each station object includes an id, an extId (the full HAFAS identifier required by search_connections), lat/lon coordinates, a type classification, and a products field that indicates which transport modes — such as long-distance rail, regional rail, S-Bahn, or bus — serve that station.
Is real-time departure or delay information available?+
Not currently. The API covers connection search with scheduled times and ticket offers, plus static reference data (stations, metadata, transit associations). Real-time delay or live departure board data is not exposed. You can fork this API on Parse and revise it to add an endpoint targeting live departure information.
Are international routes outside Germany supported by `search_connections`?+
The connection search uses HAFAS IDs, which can include cross-border stations served by Deutsche Bahn (e.g., Amsterdam, Paris, Zürich) if those stations appear in get_station_autocomplete results. Coverage reflects Deutsche Bahn's own booking inventory and is not a general European rail aggregator.
What is the `ctxRecon` token and when is it needed?+
ctxRecon is a reconstruction token returned inside a connection result from search_connections. It uniquely identifies a specific journey and must be passed as the sole input to get_ticket_offers to retrieve the fare and ticket options for that journey. Without a valid ctxRecon from a prior search, get_ticket_offers cannot return meaningful data.
Page content last updated . Spec covers 5 endpoints from bahn.com.
Related APIs in TravelSee all →
opentable.ca API
Search and discover restaurants on OpenTable, view detailed information like menus and reviews, and check real-time dining availability across metro areas. Find top-rated restaurants in your location and instantly see which tables are open for your preferred date and time.
fandango.com API
Search for movies and retrieve nearby theater listings with showtimes by ZIP code and date, plus showtimes for a specific movie at nearby theaters.
data.lime.bike API
Access real-time availability data for Lime bikes and scooters, including station locations, vehicle status, system alerts, and geofencing zones across multiple cities. Monitor micromobility inventory and service information to find nearby vehicles or plan your trips effectively.
turo.com API
Search for peer-to-peer car rentals across Turo by location and dates to browse available vehicles with pricing, specifications, and real-time availability. Get detailed information on specific cars to compare features and make rental decisions.
reservation.pc.gc.ca API
Access real-time campground availability and reservation data from the Parks Canada booking system. Search locations, retrieve available campsites and cabins, filter by equipment type, and review operating date schedules across the national park network. Includes detailed resource metadata and map-based availability overviews.
united.com API
Search United Airlines flights, check real-time flight status, and view detailed seat maps to plan your perfect trip. Compare fare options and use airport autocomplete to quickly find your departure and arrival cities.
thetrainline.com API
Search UK train stations and find the cheapest fares across date ranges, then generate direct booking links to complete your purchase on Trainline.com. Get real-time journey information to compare prices and book your tickets in seconds.
thefork.it API
Search and discover Italian restaurants by cuisine, location, or ratings, then access detailed information like menus, reviews, and availability across major cities in Italy. Find top-rated dining options and compare restaurant details to plan your perfect meal.
Bahn.com API – Deutsche Bahn Stations & Routes · Parse