NAME
Travel::Routing::DE::DBRIS - Interface to the bahn.de itinerary service
SYNOPSIS
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
version 0.01
DESCRIPTION
Travel::Routing::DE::DBRIS is an interface to the bahn.de itinerary service.
METHODS
- $ris = Travel::Routing::DE::DBRIS->new(%opt)
-
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.
- origin => stop (mandatory)
-
A Travel::Status::DE::DBRIS::Location(3pm) instance describing the origin of the requested itinerary.
- destination => stop (mandatory)
-
A Travel::Status::DE::DBRIS::Location(3pm) instance describing the destination of the requested itinerary.
- cache => cache
-
A Cache::File(3pm) instance used for caching bahn.de requests.
- datetime => datetime
-
Request departures on or after datetime (DateTime(3pm) instance). Default: now.
- language => lang
-
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.
- modes_of_transit => arrayref
-
Only request connections using the modes of transit specified in arrayref. Default: ICE, EC_IC, IR, REGIONAL, SBAHN, BUS, SCHIFF, UBAHN, TRAM, ANRUFPFLICHTIG.
- discounts => arrayref
-
Consider discounts specified in arrayref when determining offer prices. Supported items: bc25, bc25-first, bc50, bc50-first, bc100, bc100-first. Default: none.
- user_agent => user agent
-
Use user agent for requests. Default: A new LWP::UserAgent(3pm) object with env_proxy enabled and a timeout of ten seconds.
- lwp_options => hashref
-
Pass hashref to
LWP::UserAgent->new
. Default:{ timeout => 10 }
.
- $ris->errstr
-
Returns a string describing a HTTP or bahn.de error, if any such error occured. Returns undef otherwise.
- $ris->connections
-
Returns a list of Travel::Routing::DE::DBRIS::Connection(3pm) objects, each of which describes a singre connction from origin to destination.
DIAGNOSTICS
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.
DEPENDENCIES
Class::Accessor(3pm)
DateTime(3pm)
DateTime::Format::Strptime(3pm)
LWP::UserAgent(3pm)
Travel::Status::DE::DBRIS(3pm)
BUGS AND LIMITATIONS
This module is very much work-in-progress.
SEE ALSO
Travel::Routing::DE::DBRIS::Connection(3pm)
AUTHOR
Copyright (C) 2025 by Birte Kristina Friesel <derf@finalrewind.org>
LICENSE
This module is licensed under the same terms as Perl itself.