WWW::Efa - inofficial interface to the German itinerary service


    use WWW::Efa;

    my $efa = WWW::Efa->new(
        from => ['Essen', 'HBf'],
        to   => ['Duisburg', 'HBf'],


    for my $con ($efa->connections()) {
        for my $c (@{$con}) {
                "%-5s ab  %-30s %-20s %s\n%-5s an  %-30s\n\n",,
                @{$c}{'dep_time', 'dep_stop', 'train_line', 'train_dest'},
                @{$c}{'arr_time', 'arr_stop'},
        print "\n\n";


WWW::Efa is a client for the web interface. You pass it the start/stop of your journey, maybe a time and a date and more details, and it returns the up-to-date scheduled connections between those two stops.

It uses LWP::USerAgent and XML::LibXML for this.



Returns a new WWW::Efa object and sets up its POST data via %conf.

Valid hash keys and their values are:

from => [ city, stop [ , type ] ]

Mandatory. Sets the origin, which is the start of the journey. type is optional and may be one of stop (default), address (street and house number) or poi ("point of interest").

to => [ city, stop [ , type ] ]

Mandatory. Sets the destination, see from.

via => [ city, stop [ , type ] ]

Optional. Specifies a intermediate stop which the resulting itinerary must contain. See from for arguments.

arrive => HH:MM

Sets the journey end time

depart => HH:MM

Sets the journey start time

date => DD.MM.[YYYY]

Set journey date, in case it is not today

exclude => \@exclude

Do not use certain transport types for itinerary. Acceptep arguments: zug, s-bahn, u-bahn, stadtbahn, tram, stadtbus, regionalbus, schnellbus, seilbahn, schiff, ast, sonstige

max_interchanges => num

Set maximum number of interchanges

prefer => speed|nowait|nowalk

Prefer either fast connections (default), connections with low wait time or connections with little distance to walk

proximity => int

Try using near stops instead of the given start/stop one if int is true.

include => local|ic|ice

Include only local trains into itinarery (default), or all but ICEs, or all.

walk_speed => slow|fast|normal

Set walk speed. Default: normal

bike => int

If true: Prefer connections allowing to take a bike along

When encountering invalid hash keys, a WWW::Efa::Error object is stored to be retrieved by $efa->error();


In case a WWW::Efa operation encountered an error, this returns a WWW::Efa::Error object related to the exact error. Otherwise, returns undef.


Submit the query to %opts is passed on to LWP::UserAgent->new(%opts).


Parse the reply. returns a true value on success. Upon failure, returns undef and sets $efa->error() to a WWW::Efa::Error object.


Returns an array of connection elements. Each connection element is an arrayref of connection part, and each connecton part is a hash containing the following elements:

* dep_time

Departure time as a string in HH:MM format

* dep_stop

Departure stop, e.g. "Essen HBf"

* train_line

Name of the train line, e.g. "S-Bahn S6"

* arr_time

Arrival time as a string in HH:MM format

* arr_stop

Arrival stop, e.g. "Berlin HBf"