Search Deutsche Bahn (bahn.de) train journeys and prices
Input
origin requiredThe departure place: a place's id from bahn.de/suggest_locations, unchanged.
destination requiredThe arrival place: a place's id from bahn.de/suggest_locations, unchanged.
date optionalThe travel date, YYYY-MM-DD. Give date or daysAhead, not both.
time optionalHH:mm, local time of the place: journeys departing from this time, or arriving by it with timeIs 'arrival'.
Default: "08:00"class optionalTravel class the prices are for.
Default: 2modes optionalThe transport modes to use: ICE, EC_IC (Eurocity and Intercity), IR (Interregio), REGIONAL, SBAHN, BUS, SCHIFF (boat), UBAHN, TRAM, ANRUFPFLICHTIG (on-demand). All by default.
Default: ["ICE","EC_IC","IR","REGIONAL","SBAHN","BUS","SCHIFF","UBAHN","TRAM","ANRUFPFLICHTIG"]cursor optionallaterCursor or earlierCursor of an earlier answer to the same search: returns the next or previous journeys.
timeIs optionalWhether time is the departure time or the arrival time.
Default: "departure"bicycle optionalOnly journeys on which a bicycle can travel.
Default: falsefastest optionalShow fastest connections only, as bahn.de does by default. False also lists slower connections that may be cheaper.
Default: trueseatOnly optionalBook seat only: prices are for a seat reservation, for travellers who already hold a ticket.
Default: falsedaysAhead optionalThe travel date as a number of days after today (UTC), for searches that run on a schedule. Give date or daysAhead, not both.
directOnly optionalDirect services only: journeys with no change.
Default: falsetravellers optionalWho travels, as groups of one kind. bahn.de prices the journey for all of them.
Default: [{"type":"adult","count":1,"discount":"none"}]viableOnly optionalViable connections only: leave out the journeys bahn.de expects to miss a change, for delays or cancellations.
Default: falseincludeStops optionalAlso return every stop of each leg, with its times and platform.
Default: falsehasDeutschlandTicket optionalThe travellers hold a Deutschland-Ticket: bahn.de prices only the parts it does not cover.
Default: falsedeutschlandTicketOnly optionalOnly journeys that the Deutschland-Ticket is valid for.
Default: falseOutput
journeys requiredThe journeys bahn.de lists, in its order. Empty when it has no connection.
laterCursor requiredPass back as cursor, with the same search, for the journeys after these.
earlierCursor requiredPass back as cursor, with the same search, for the journeys before these.
