DB Navigator

DB Navigator · GPT-Aktionen

Deutsche Bahn API

API for accessing journey information in the Deutsche Bahn network.

  • GET /locationsFind locations based on query

    Retrieves information about locations, including stations, POIs, and addresses.

  • GET /journeysFind journeys from A to B

    Retrieves journey information from one location to another within the Deutsche Bahn network.

Ursprüngliches API-Schema
{
  "openapi": "3.0.0",
  "info": {
    "title": "Deutsche Bahn API",
    "description": "API for accessing journey information in the Deutsche Bahn network.",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://v6.db.transport.rest",
      "description": "Deutsche Bahn API endpoint"
    }
  ],
  "paths": {
    "/locations": {
      "get": {
        "operationId": "findLocations",
        "summary": "Find locations based on query",
        "description": "Retrieves information about locations, including stations, POIs, and addresses.",
        "parameters": [
          {
            "name": "query",
            "in": "query",
            "description": "Search query for the location (e.g., a station name, address, or POI).",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "results",
            "in": "query",
            "description": "Max number of location results to return.",
            "schema": {
              "type": "integer",
              "default": 5
            }
          }
        ],
        "responses": {
          "200": {
            "description": "An array of locations matching the search query",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "type": {
                        "type": "string"
                      },
                      "id": {
                        "type": "string"
                      },
                      "name": {
                        "type": "string"
                      },
                      "latitude": {
                        "type": "number",
                        "format": "double"
                      },
                      "longitude": {
                        "type": "number",
                        "format": "double"
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/journeys": {
      "get": {
        "operationId": "findJourneys",
        "summary": "Find journeys from A to B",
        "description": "Retrieves journey information from one location to another within the Deutsche Bahn network.",
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "description": "Starting location (station ID, POI, or address)",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "to",
            "in": "query",
            "description": "Destination location (station ID, POI, or address)",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "via",
            "in": "query",
            "description": "Optional via location (station ID, POI, or address)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "departure",
            "in": "query",
            "description": "Compute journeys departing at this date/time.",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "arrival",
            "in": "query",
            "description": "Compute journeys arriving at this date/time.",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "results",
            "in": "query",
            "description": "Max number of journeys.",
            "schema": {
              "type": "integer",
              "default": 3
            }
          },
          {
            "name": "transfers",
            "in": "query",
            "description": "Maximum number of transfers.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "An array of journey options",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": null
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}