Developer
Menü

Bahnhöfe

Bahnhöfe finden und ihre Stammdaten lesen. Jeder Bahnhof hat eine EVA-Nummer, die alle anderen Endpunkte als station_id nehmen.

Objekte

Objekt Bahnhof

FeldTypBeschreibung
idstringEVA-Nummer (7 Ziffern, bei manchen Haltestellen 6). Für alle anderen Endpunkte die station_id.
namestringName wie bei der DB
ds100??stringBetriebsstellenkürzel (Ril 100), z. B. BLS
location??object{ lat, lon } in WGS84
related?string[]IDs von Teilbahnhöfen, die zum selben Bahnhof gehören (z. B. Berlin Hbf tief und S-Bahn)
{
  "id": "8011160",
  "name": "Berlin Hbf",
  "ds100": "BLS",
  "location": {
    "lat": 52.525592,
    "lon": 13.369545
  },
  "related": [
    "8089021",
    "8089522",
    "8098160"
  ]
}

Objekt Gleis

FeldTypBeschreibung
platformstringGleisbezeichnung, wie sie am Bahnsteig steht
linesstring[]Linien bzw. Gattungen, die dort halten
viewstringsbahn (S-Bahn-Berlin-Anzeiger) oder db (DB-Anzeiger): so zeigt der Zugzielanzeiger dieses Gleis
{
  "platform": "3",
  "lines": [
    "S3",
    "S5",
    "S7",
    "S9"
  ],
  "view": "sbahn"
}

Bahnhöfe suchen

GET/v1/stationsEimer standard

Sucht nach Namen. Bahnhöfe in Berlin und Brandenburg kommen zuerst, Hauptbahnhöfe vor anderen. Höchstens 10 Treffer.

Query-Parameter

FeldTypBeschreibung
queryPflichtstringSuchbegriff, mindestens 2 Zeichen

Antwort

Liste von Bahnhof (nur id und name)

[
  {
    "id": "8089028",
    "name": "Berlin Ostkreuz"
  },
  {
    "id": "8011113",
    "name": "Berlin Südkreuz"
  }
]

Beispiel

curl
curl "https://developer.bahnhoftafel.de/v1/stations?query=Ostkreuz" \
  -H "Authorization: Bearer $BT_SCHLUESSEL"
JavaScript
const antwort = await fetch("https://developer.bahnhoftafel.de/v1/stations?query=Ostkreuz", {
  method: "GET",
  headers: { Authorization: `Bearer ${process.env.BT_SCHLUESSEL}`, },
});
const daten = await antwort.json();
Python
import os, requests

antwort = requests.get(
    "https://developer.bahnhoftafel.de/v1/stations?query=Ostkreuz",
    headers={"Authorization": f"Bearer {os.environ['BT_SCHLUESSEL']}"},
    timeout=30,
)
daten = antwort.json()

Alle Bahnhöfe

GET/v1/stations/allEimer standard, 5 Marken

Alle 10.256 Bahnhöfe und Haltestellen der DB mit Kürzel und Lage, seitenweise nach id sortiert. Für die nächste Seite after auf die letzte id setzen.

Info

Kostet 5 Marken im Eimer standard. Die Liste ändert sich selten, einmal am Tag laden reicht.

Query-Parameter

FeldTypBeschreibung
afterstringNur Bahnhöfe mit größerer id (Blättern)
limitintegerEinträge je SeiteStandard: 5001 bis 1000

Antwort

Objekt { total, stations: Bahnhof[], next }. next ist der Wert für after oder null am Ende

Beispiel

curl
curl "https://developer.bahnhoftafel.de/v1/stations/all" \
  -H "Authorization: Bearer $BT_SCHLUESSEL"
JavaScript
const antwort = await fetch("https://developer.bahnhoftafel.de/v1/stations/all", {
  method: "GET",
  headers: { Authorization: `Bearer ${process.env.BT_SCHLUESSEL}`, },
});
const daten = await antwort.json();
Python
import os, requests

antwort = requests.get(
    "https://developer.bahnhoftafel.de/v1/stations/all",
    headers={"Authorization": f"Bearer {os.environ['BT_SCHLUESSEL']}"},
    timeout=30,
)
daten = antwort.json()

Bahnhöfe in der Nähe

GET/v1/stations/nearbyEimer standard

Bahnhöfe im Umkreis eines Punktes, die nächsten zuerst.

Query-Parameter

FeldTypBeschreibung
latPflichtnumberBreitengrad47 bis 56
lonPflichtnumberLängengrad5 bis 16
radiusintegerUmkreis in MeternStandard: 2000100 bis 20000
limitintegerHöchstzahlStandard: 101 bis 50

Antwort

Liste von Bahnhof mit zusätzlichem Feld distance (Meter)

[
  {
    "id": "8011160",
    "name": "Berlin Hbf",
    "ds100": "BLS",
    "location": {
      "lat": 52.525592,
      "lon": 13.369545
    },
    "distance": 412
  }
]

Beispiel

curl
curl "https://developer.bahnhoftafel.de/v1/stations/nearby?lat=52.5219&lon=13.4132" \
  -H "Authorization: Bearer $BT_SCHLUESSEL"
JavaScript
const antwort = await fetch("https://developer.bahnhoftafel.de/v1/stations/nearby?lat=52.5219&lon=13.4132", {
  method: "GET",
  headers: { Authorization: `Bearer ${process.env.BT_SCHLUESSEL}`, },
});
const daten = await antwort.json();
Python
import os, requests

antwort = requests.get(
    "https://developer.bahnhoftafel.de/v1/stations/nearby?lat=52.5219&lon=13.4132",
    headers={"Authorization": f"Bearer {os.environ['BT_SCHLUESSEL']}"},
    timeout=30,
)
daten = antwort.json()

Bahnhof abrufen

GET/v1/stations/{station_id}Eimer standard

Stammdaten eines Bahnhofs: Name, Kürzel, Lage und zugehörige Teilbahnhöfe.

Pfad-Parameter

FeldTypBeschreibung
station_idPflichtstringEVA-Nummer

Antwort

Bahnhof

Beispiel

curl
curl "https://developer.bahnhoftafel.de/v1/stations/8011160" \
  -H "Authorization: Bearer $BT_SCHLUESSEL"
JavaScript
const antwort = await fetch("https://developer.bahnhoftafel.de/v1/stations/8011160", {
  method: "GET",
  headers: { Authorization: `Bearer ${process.env.BT_SCHLUESSEL}`, },
});
const daten = await antwort.json();
Python
import os, requests

antwort = requests.get(
    "https://developer.bahnhoftafel.de/v1/stations/8011160",
    headers={"Authorization": f"Bearer {os.environ['BT_SCHLUESSEL']}"},
    timeout=30,
)
daten = antwort.json()

Gleise eines Bahnhofs

GET/v1/stations/{station_id}/platformsEimer standard

Alle Gleise mit den Linien, die dort halten. Für S-Bahn-Gleise in Berlin aus dem VBB, sonst aus dem Fahrplan der DB.

Pfad-Parameter

FeldTypBeschreibung
station_idPflichtstringEVA-Nummer

Antwort

Objekt { station, platforms: Gleis[] }

Beispiel

curl
curl "https://developer.bahnhoftafel.de/v1/stations/8011160/platforms" \
  -H "Authorization: Bearer $BT_SCHLUESSEL"
JavaScript
const antwort = await fetch("https://developer.bahnhoftafel.de/v1/stations/8011160/platforms", {
  method: "GET",
  headers: { Authorization: `Bearer ${process.env.BT_SCHLUESSEL}`, },
});
const daten = await antwort.json();
Python
import os, requests

antwort = requests.get(
    "https://developer.bahnhoftafel.de/v1/stations/8011160/platforms",
    headers={"Authorization": f"Bearer {os.environ['BT_SCHLUESSEL']}"},
    timeout=30,
)
daten = antwort.json()