canonical: https://jentic.com/apis/open-api.bahn.de/deutsche-bahn

# Open Api Bahn De DB Fahrplan API

Jentic publishes the only available OpenAPI specification for DB Fahrplan API, keeping it validated and agent-ready. Deutsche Bahn's Fahrplan (timetable) API exposes train and station data for Germany and connecting European routes. The four endpoints cover station search by name, departure and arrival boards for a station, and detail lookups for a specific journey leg. It is the canonical agent-readable view of DB schedule data and is suitable for travel-assistance, journey-planning, and station-monitor use cases.

## For AI agents

Look up Deutsche Bahn stations, retrieve live departure and arrival boards, and fetch detail for a specific train journey across Germany's rail network.

## Scope

Does not sell tickets, calculate fares, or book reservations - use for German rail station, departure-board, arrival-board, and journey-detail lookups only.

## Capabilities

- Resolve a free-text station name to a structured DB station record with coordinates
- Pull the live departure board for a station with platform and delay information
- Pull the live arrival board for a station with origin and arrival-time data
- Fetch the detailed stop list for a specific train journey between two stations
- Build journey-planning prompts that resolve a station name and immediately read its board

## Use cases

### Live Station Departure Board

Render an up-to-date list of trains leaving a German station, including platform, scheduled time, and any delay. GET /departureBoard takes a station id resolved from /location.name and returns a structured board that an agent can summarise back to a traveller in plain language.

Example prompt: Resolve 'Berlin Hbf' via GET /location.name, then call GET /departureBoard for that station id and return the next 10 departures with platform and delay.

### Arrival Tracking for Pickups

Track when a train will arrive at a station so a connecting traveller or a meet-and-greet agent knows when to be there. GET /arrivalBoard returns the inbound board for a station with origin and live arrival time, suitable for a station-monitor display or a notification flow.

Example prompt: Call GET /arrivalBoard for station 8011160 (Berlin Hbf) and return arrivals from origin 'Hamburg Hbf' in the next hour.

### Journey Detail Drill-Down

Expand a single departure into its full stop list to show a traveller every station on the line, the dwell times, and the platform at each stop. GET /journeyDetail accepts the journey reference returned from a board and returns the complete leg, which is the canonical input for an itinerary-rendering agent.

Example prompt: After picking a departure, call GET /journeyDetail with that journey reference and return the ordered list of stations and platforms for the trip.

### AI Agent Travel Assistant

Let a Jentic-orchestrated travel agent answer 'when is the next train' questions about German rail without holding the DB API key. The agent resolves the station name, reads the board, and returns a natural-language summary, all without seeing the raw authKey query parameter.

Example prompt: Search Jentic for 'next train departures from a German station', load the GET /departureBoard schema, and execute it for 'Frankfurt Hbf' returning the next 5 departures.

## Key endpoints

| Method | Path | Description |
| --- | --- | --- |
| GET | /location.name | Resolve a station name to a station id and coordinates |
| GET | /departureBoard | Live departures for a station |
| GET | /arrivalBoard | Live arrivals for a station |
| GET | /journeyDetail | Full stop list for a specific journey |

## Key resources

- **Stations** — Resolve a free-text station name to a DB station record.
- **Departure Board** — Live departures from a station with platform and delay.
- **Arrival Board** — Live arrivals into a station with origin and arrival time.
- **Journey Detail** — Full stop list and timing for a specific train journey.

## Why Jentic

- **Setup:** Wiring the DB Fahrplan API by hand means appending your authKey query parameter to every request and resolving station names before you can read boards yourself. Through Jentic you install once, import the DB Fahrplan API from the API Directory, store the auth key once, and your agent calls it.
- **Permission scoping:** The DB Fahrplan API is read-only and takes its station and journey targets as query parameters rather than a resource id in the URL path, so limit the agent to the operations it needs, such as resolving a station, reading a departure board, or fetching journey detail. You credit the agent only with the operations you allow.
- **Credential handling:** Your DB Fahrplan auth key is stored once, encrypted, by your own Jentic One instance and injected at execution time. It never enters the agent's prompt, logs, or context.
- **Discovery method:** Agents search Jentic by intent such as 'find live departures for a station' or 'resolve a station name to an id', and Jentic returns the matching DB Fahrplan operation with its input schema so the agent calls the right endpoint without browsing the reference docs.

## Related APIs

- **Transit App API** — Multi-modal public-transit data covering many cities globally.
- **Navitia API** — Open-data multi-modal journey-planning API covering European networks.
- **Transport for London Unified API** — London transit data with similar station, board, and journey concepts.

## FAQ

### Why is there no official OpenAPI spec for DB Fahrplan API?

Deutsche Bahn publishes the Fahrplan API documentation on developer pages and a SwaggerHub mirror but does not maintain a canonical OpenAPI document on its own developer site. Jentic generates and maintains this spec so AI agents and developers can call DB Fahrplan API via structured tooling. It is validated against the live API and kept up to date. Get started with Jentic One, the self-hosted execution layer.

### What authentication does the DB Fahrplan API use?

The Fahrplan API authenticates with an authKey query parameter on every request. Through Jentic the authKey is held in the vault and appended at execution time so the agent never sees the raw key in URLs or logs.

### Can I plan a multi-leg journey with this API?

The four endpoints in this spec do not include a journey-planner that takes an origin and destination and returns a routed trip. Use GET /location.name to resolve stations and GET /departureBoard plus GET /journeyDetail to assemble a leg. For full route planning, combine with a routing API.

### What are the rate limits for the DB Fahrplan API?

Deutsche Bahn does not document a single rate-limit value in this spec; access is governed per developer key. Plan for throttling, cache board results that change at most once per minute, and back off on 429 responses.

### How do I look up the next train from a station through Jentic?

Run pip install jentic and search for 'next train departures from a German station'. Jentic returns the GET /departureBoard operation; resolve the station id first with GET /location.name and then load and execute the board schema with that id.

### Does this API cover regional and S-Bahn services?

The Fahrplan dataset includes long-distance, regional, and many S-Bahn services that DB operates, returned through the same departure and arrival boards. Operator coverage outside DB depends on the agreements behind the dataset and is not guaranteed for every regional network.

### Can I limit what my agent is allowed to do with the DB Fahrplan API?

Yes. The DB Fahrplan API is read-only and takes its station and journey targets as query parameters, so in your own self-hosted Jentic One instance you decide which of its operations the agent may call. You can allow only what a given agent needs, such as resolving a station name with GET /location.name, reading a departure board with GET /departureBoard, reading an arrival board with GET /arrivalBoard, or fetching a stop list with GET /journeyDetail. Your rules govern both the permitted operations and the credential the agent uses, so the agent runs with exactly the access you grant and no more.
