Get Instant Access to our Exchange Rates API

Get access instantly - 1000 requests free p/m.


How To Use Our Perl Currency Converter

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://v3.exchangerate-api.com/bulk/YOUR-API-KEY/".$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:

{
	"result": "success",
	"from": "USD",
	"rates": {
		"AUD": ((AUD in terms of USD)),
		"BGN": 1.8096,
		"BRL": 3.1143,
		"...": 1.3113,
		"...": 7.473, etc. etc.
	}
}

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



We also offer automatic localization requests:



Automatic Currency Localization for Perl


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

# Getting visitor IP
$ip = $ENV{'REMOTE_ADDR'};

# Making request
my $url = "https://v3.exchangerate-api.com/local/YOUR-API-KEY/USD/" . $ip;
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);

# Parsing JSON
my $json = JSON($response);
				

This will return the exchange rate from your base currency to the visitor currency & i18n data on your visitor.

In the example API response below your prices are in USD and a customer was visiting from a Bulgarian IP address so BGN is returned as the appropriate currency for a Bulgarian visitor.

{
	"result": "success",
	"from": "USD",
	"to": "BGN",
	"country_code": "BG",
	"currency_symbol": "43b,432",
	"rate": 1.81
}

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!