WebService::KVV::Live::Stop - Arrival times for Trams/Buses in the Karlsruhe metropolitan area
use WebService::KVV::Live::Stop; use utf8; use open qw( :encoding(UTF-8) :std ); my $stop = WebService::KVV::Live::Stop->new("Siemensallee"); print "Arrival time: $_->{time} $_->{route} $_->{destination}\n" for $stop->departures;
Print departure table:
use WebService::KVV::Live::Stop; use utf8; use open qw( :encoding(UTF-8) :std ); use Data::Dumper::Table; use Data::Visitor::Callback; $stop = WebService::KVV::Live::Stop->new($ARGV[0] // 'Kronenplatz'); my @entries = $stop->departures; Data::Visitor::Callback->new('JSON::PP::Boolean' => sub { $_ = $_ ? 'true' : 0 })->visit(@entries); my $departure_table = Tabulate \@entries; $departure_table =~ s/^.*\n//; # remove object type print $departure_tabletable;
API for searching for bus/tram stops in the Karlsruhe Metropolitan Area (Karlsruhe Verkehrsvertriebe network to be exact) and for listing departure times at said stops.
Not really an API, just a client for http://live.kvv.de. See kvvlive.json for details.
The client is based on Net::HTTP::Spore and has some workarounds: It overrides a method from Net::HTTP::Spore that doesn't handle colons properly and throws a generic message on errors instead of the more specific HTTP error messages.
Net::HTTP::Spore
Search for matching local transport stops. $id are identifiers starting with "de:". $name need not be an exact match.
$id
"de:"
$name
Returns a list of WebService::KVV::Live::Stops in list context. In scalar context returns the best match.
WebService::KVV::Live::Stop
Returns a list of departures for a WebService::KVV::Live::Stop. Results can be restricted to a particular route (Linie) by the optional argument.
http://github.com/athreef/WebService-KVV-Live-Stop
http://live.kvv.de
Ahmad Fatoum <athreef@cpan.org>, http://a3f.at
<athreef@cpan.org>
Copyright (C) 2016 Ahmad Fatoum
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install WebService::KVV::Live::Stop, copy and paste the appropriate command in to your terminal.
cpanm
cpanm WebService::KVV::Live::Stop
CPAN shell
perl -MCPAN -e shell install WebService::KVV::Live::Stop
For more information on module installation, please visit the detailed CPAN module installation guide.