How To Use Our Perl Exchange Rates API

We offer an easy to use, accurate and reliable exchange rate API for Perl that's perfect for both personal and professional use.

Fetching exchange rates using our Perl currency conversion API is as easy as making GET requests. This means you can easily integrate our API into your Perl project however you'd prefer.

For more details on the different types of request we support please see our Main Documentation.

Alternatively simply use the Perl library code below to get started with our exchange rate data as fast as you can copy & paste!

Simple Perl Currency Conversion Example


use LWP::UserAgent;
use HTTP::Request;
use JSON;

# Making request
my $base_code = "USD";
my $URL = "https://api.exchangerate-api.com/v4/latest/".$base_code;
my $ua = LWP::UserAgent->new(ssl_opts => { verify_hostname => 1 });
my $header = HTTP::Request->new(GET => $URL);
my $request = HTTP::Request->new('GET', $URL, $header);
my $response = $ua->request($request);
my $content = $response->content;

# Parsing JSON
$json = JSON->new->allow_nonref;
$decoded = $json->decode( $content );
foreach $to_code (keys %{$decoded->{rates}}){
   print "Exchange Rate $base_code/$to_code = $decoded->{rates}->{$to_code}";
}
				

This will return the exchange rates from USD to all other currencies we support:

{
	"base": "USD",
	"date": "2019-03-20",
	"time_last_updated": 1553092232,
	"rates": {
		"USD": 1,
		"AUD": 1.408403,
		"CAD": 1.329501,
		"CHF": 0.999398,
		"CNY": 6.711962,
		"EUR": 0.880807,
		"GBP": 0.755043
		"HKD": 7.850285,
		"...": 1.311357,
		"...": 7.4731, etc. etc.
	}
}

Please see our main documentation for further information on this query type & error response details.

Additionally, please email us if you'd like to submit a better code example, we'll credit you!