Transport for Germany API

Transportation / API Key Intermediate HTTP
Varies by plan (check documentation)

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

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

JSON Response
{
  "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

Request
const url = "http://data.deutschebahn.com/dataset/api-fahrplan";
// 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

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
Verified: 2026-04-04

Related Tags

Similar APIs

View All →