Glitnir - A Perl module for accessing Glitnir's online bank system
use Glitnir;
my $glitnir = Glitnir->new();
# Get a hash listing today's exchange rates
my $rates = $glitnir->exchange_rates();
# Logging in
$glitnir->login($user, $password); # Set programmatically
$glitnir->login($glitnir->get_login()); # .. or ask the user
# Get a reference to a hash of accounts
my $accounts = $glitnir->accounts();
# Get a reference to a list of transactions
my $transactions = $glitnir->transactions('543-26-12345');
# Same, for a credit-card (note the format may differ from bank statmens)
my $transactions = $glitnir->transactions('5432100000199909');
This object provides a high-level programmatic interface to Glitnir's online mobile banking system at http://m.glitnir.is/.
Obviously if Glitnir change their HTML then some or all of this stuff might break. I've attempted to document the current state of things within this module, however exploring the returned values using something like Data::Dumper and building lots of sanity checks into any programs using this code is highly recommended.
This module uses perl ``exceptions'' to handle errors, any method may die if it fails to do it's job. Use eval blocks to catch such errors and handle them if you don't want errors to abort your programs:
eval { # try
... some Glitnir calls ...
};
if ($@) # catch
{
... handle exception $@ ...
}
This module was written by Bjarni R. Einarsson, <http://bre.klaki.net/>.
It may be freely used and distributed under the same terms as Perl itself.
debug => 1 # Enable debug messages to STDERR base => $hostname # Use something other than m.glitnir.is session_id => $s # Resume an old session logged_in => 1 # Assume resumed session is logged-in
{
"USD" => {
Kaup => 74,
Sala => 75,
...
},
"EUR" => {
...
}
}
Note that the actual currencies described and the field names within each hash are determined by the info in the Glitnir mobile bank.
The code is written so that if they reorder their tables, it shouldn't matter as long as the columns retain the same descriptive headings (Kaup, Sala, ...). However, if they change their naming conventions all bets are off.
The structure returned looks like this:
[
[ "dd.mm", "description", "amount" ],
[ "dd.mm", "description", "amount" ],
...
]
Note that column order is determined by the Glitnir mobile bank, if they reorder things, programs using this method will break.
The structure returned looks like this:
{
"012-23-4234" => {
nr => "012-23-4234",
url => $path_to_transaction_page,
name => $some_text,
balance => $number,
currency => $currency_TLA,
},
...
}
Credit-card accounts have neither a balance nor a currency and their identifying numbers are 16 digits long.
This is all a hack and any changes to the mobile bank may break the functionality of this module and programs based on it. However, I hope it is a useful proof-of-concept demonstrating to the bank how useful (and simple!) it would be to provide a proper web-service API to 3rd party developers.
Transferring money between accounts is not supported. This is a deliberate omission, as I currently have no use for such features and don't intend to assist cyber-criminals by writing their tools for them.