NAME

WebService::OANDA::ExchangeRates - A Perl wrapper for the OANDA Exchange Rates API

SYNOPSIS

my $api = WebService::OANDA::ExchangeRates->new(api_key => 'YOUR_API_KEY');

# all API methods return a response object

# get_currencies
my $response = $api->get_currencies();
if ($response->is_success) {
    print $response->data->{USD}; # US Dollar
}
else {
  print $response->error_message # an error message
}

# get the number of quotes remaining
$response = $api->get_remaining_quotes();
print $response->data->{remaining_quotes} if $response->is_success;

# get a series of quotes for a base currency
$response = $api->get_rates(
    base_currency => 'USD',
    quote         => [ qw{ EUR CAD } ],
);
if ($response->is_success) {
    my $base_currency = $response->data->{base_currency};
    print "Base Currency: $base_currency\n";
    foreach my $quote_currency (keys %{$response->data->{quotes}) {
        my $quote = $response->data->{quotes}{$quote_currency};
        print "  $quote_currency:\n";
        print "    BID: ", $quote->{bid}, "\n";
        print "    ASK: ", $quote->{ask}, "\n";
    }
}

DESCRIPTION

This module provides a simple wrapper around the OANDA Exchange Rates API using LWP::UserAgent. Go to the API documentation page for a full reference of all the methods. This service requires you to sign up for a trial or paying subscription to obtain an API key.

METHODS

Constructor

API Methods

All API methods return a WebService::OANDA::ExchangeRates::Response object that provides access to the HTTP::Response object and has deserialized the JSON response into a native Perl data structure.

get_currencies(%options)

get_remaining_quotes

get_rates

Accessors

api_key

The originally supplied api_key.

base_url

Returns a URI object

proxy

Returns a URI object

timeout

The request timeout

user_agent

SEE ALSO

SUPPORT

Bug/Feature requests

Please file a ticket at the repository for this code on github at:

https://github.com/oanda/perl-webservice-oanda-exchangerates

AUTHOR

Dave Doyle <ddoyle@oanda.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2014 by OANDA Corporation.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.