Overview

The Deutsche Bahn (DB) Fahrplan API provides train schedule data for Germany's national railway network, including departure and arrival times, station information, and journey details. A free API key can be obtained via the DB developer portal. It is the go-to data source for building German rail travel applications.

Beginner Tip

Get a free API key by registering at developer.deutschebahn.com, then include it as the Authorization: Bearer header in requests. Start with the /location endpoint to look up station IDs before querying timetables.

Available Data

The kind of data this API exposes, based on its documentation. We could not call the endpoint to confirm the exact field names.

match scores and results
team standings
player statistics
schedule and fixtures
Response fields: deutschebahn com
Use case: Integrate deutsche bahn (db) api data into web and mobile applications

Example Response

Illustrative shape only — we were not able to call this endpoint (it requires credentials or exposes no public sample URL), so the fields below show the kind of data this API returns rather than a recorded response.

JSON Response · Illustrative
{
  "route": "Line 1",
  "origin": "Station A",
  "destination": "Station B",
  "departure": "08:30",
  "arrival": "09:15",
  "status": "On Time",
  "delays_min": 0
}

Field Reference

id EVA number — the unique station identifier used in DB systems
name Official name of the railway station
lon Longitude of the station location
lat Latitude of the station location
products Bitmask indicating which train products serve this station

Implementation Example

Calls a real endpoint of this API. Replace any placeholder credentials with your own key.

Request
const url = "https://apis.deutschebahn.com/db-api-marketplace/apis/fahrplan/v1/location/Berlin";
// Replace headers or query params with the values required by this API.
const response = await fetch(url, {
  headers: {
  "X-API-Key": "YOUR_API_KEY"
  }
});
if (!response.ok) throw new Error(`Request failed: ${response.status}`);
const data = await response.json();
console.log(data);

What Can You Build?

Note: These code examples are AI-generated and unverified. Always refer to the official API documentation for accurate usage.

Common Errors & Troubleshooting

Generated guidance based on this API's documentation, not observed by us. Treat it as a starting point and check against the provider's own error reference.

401 Unauthorized Missing or incorrect API credentials in the headers
Register at developer.deutschebahn.com, generate credentials, and send both DB-Client-Id and DB-Api-Key headers
Station not found The station name query returned no results
Try using the official German spelling (e.g., "München" not "Munich") when searching for station locations
404 Not Found for timetable Using an incorrect station EVA number or date format
Get the station EVA number from the /location endpoint and use YYYY-MM-DD date format in your timetable queries

Metadata Score Breakdown

Estimated from metadata — endpoint not independently tested

This score is estimated from observable metadata — HTTPS support, authentication model, declared CORS, and documentation reachability — because the API requires authentication or exposes no publicly testable endpoint. The five-signal breakdown is only shown for live-tested APIs.

Metadata estimate · endpoint not independently tested

Technical Specifications

Auth API Key
HTTPS NO
CORS UNKNOWN
Category Transportation
Difficulty Intermediate
Listing details not endpoint-verified

Related Tags

Similar APIs

View All →