Travel::Routing::DE::DBRIS - Interface to the bahn.de itinerary service
use Travel::Routing::DE::DBRIS; # use Travel::Status::DE::DBRIS to obtain $from and $to objects # (must be Travel::Status::DE::DBRIS::Location instances) my $ris = Travel::Routing::DE::DBRIS->new( from => $from_location, to => $to_location, ); if (my $err = $ris->errstr) { die("Request error: ${err}\n"); } for my $con ( $ris->connections ) { for my $seg ($con->segments) { if ( not ($seg->is_transfer or $seg->is_walk) ) { printf("%s -> %s\n%s ab %s\n%s an %s\n\n", $seg->train_mid, $seg->direction, $seg->dep->strftime('%H:%M'), $seg->dep_name, $seg->arr->strftime('%H:%M'), $seg->arr_name, ); } } print "\n\n"; }
version 0.04
Travel::Routing::DE::DBRIS is an interface to the bahn.de itinerary service.
Request connections as specified by %opt and return a new Travel::Routing::DE::DBRIS instance with the results. Dies if the wrong %opt were passed. The origin and destination keys are mandatory.
A Travel::Status::DE::DBRIS::Location(3pm) instance describing the origin of the requested itinerary.
A Travel::Status::DE::DBRIS::Location(3pm) instance describing the destination of the requested itinerary.
An arrayref containing up to two hashrefs that describe stopovers which must be part of the requested itinerary. Each hashref consists of two keys: stop (Travel::Status::DE::DBRIS::Location(3pm) object, mandatory) and duration (stopover duration in minutes, optional, default: 0).
A Cache::File(3pm) instance used for caching bahn.de requests.
Request departures on or after datetime (DateTime(3pm) instance). Default: now.
Request text components to be provided in lang (ISO 639-1 language code). Known supported languages are: cs da de en es fr it nl pl. Default: de.
Only request connections using the modes of transit specified in arrayref. Default: ICE, EC_IC, IR, REGIONAL, SBAHN, BUS, SCHIFF, UBAHN, TRAM, ANRUFPFLICHTIG.
Use passengers as defined by arrayref when determining offer prices. Each entry describes a single person with a type (string) and discounts (arrayref). type must be adult (27 to 64 years old), junior (15 to 26 years old), or senior (65 years or older). Supported discounts are: bc25, bc25-first, bc50, bc50-first, bc100, bc100-first.
Default: single adult, no discounts.
Use user agent for requests. Default: A new LWP::UserAgent(3pm) object with env_proxy enabled and a timeout of ten seconds.
Pass hashref to LWP::UserAgent->new
.
Default: { timeout => 10 }
.
Returns a string describing a HTTP or bahn.de error, if any such error occured. Returns undef otherwise.
Returns a list of Travel::Routing::DE::DBRIS::Connection(3pm) objects, each of which describes a singre connction from origin to destination.
when the developer_mode argument to new is set to a true value, Travel::Routing::DE::DBRIS prints raw bahn.de requests and responses to stdout.
None.
This module is very much work-in-progress.
Travel::Routing::DE::DBRIS::Connection(3pm)
Copyright (C) 2025 by Birte Kristina Friesel <derf@finalrewind.org>
This module is licensed under the same terms as Perl itself.