API Documentation

currencylayer API

Currencylayer provides a simple REST API with real-time and historical exchange rates for 168 world currencies, delivering currency pairs in universally usable JSON format - compatible with any of your applications.

Spot exchange rate data is retrieved from several major forex data providers in real-time, validated, processed and delivered hourly, every 10 minutes, or even within the 60-second market window.

Providing the most representative forex market value available ("midpoint" value) for every API request, the currencylayer API powers currency converters, mobile applications, financial software components and back-office systems all around the world.


Specs & Overview

API Access Key & Authentication

After signing up, every user is assigned a personal API access key - a unique "password" provided to access any of the API's data endpoints (see API Endpoints).

To authenticate with the currencylayer API, simply attach your access_key to your preferred endpoint URL:

http://apilayer.net/api/live?access_key=YOUR_ACCESS_KEY  
                

Get your free API access key


API Response

The standard API response is an easily parseable JSON file consisting of different objects and properties. (see API Response Properties)

{
  "terms": "https://currencylayer.com/terms",
  "privacy": "https://currencylayer.com/privacy",
    "timestamp": 1430401802,
    "source": "USD",
    "quotes": {
        "USDAED": 3.672982,
        "USDAFN": 57.8936,
        "USDALL": 126.1652,
        "USDAMD": 475.306,
        "USDANG": 1.78952,
        "USDAOA": 109.216875,
        "USDARS": 8.901966,
        "USDAUD": 1.269072,
        "USDAWG": 1.792375,
        "USDAZN": 1.04945,
        "USDBAM": 1.757305,
    [...]
    }
}              
                

Along with the source currency, a timestamp and some legal reminders, the API will return a quotes object containing all available or specified currency pairs with their respective exchange rate values (quotes).


Supported Currencies


A full list of supported currencies can be accessed both in JSON Format (access key required) and on this website.

In order to access a JSON file containing all currently supported currencies (3-letter currency code and full currency name), simply attach your access_key to the currencylayer API's list endpoint:

API request:

http://apilayer.net/api/list
    ? access_key = YOUR_ACCESS_KEY
                

API response:

Upon execution of this API request you the API will deliver a JSON file containing all currently 168 supported world currencies.

{
  [...]
  "currencies": {
    "AED": "United Arab Emirates Dirham",
    "AFN": "Afghan Afghani",
    "ALL": "Albanian Lek",
    "AMD": "Armenian Dram",
    "ANG": "Netherlands Antillean Guilder",  
    [...] 
    }
}              
                

API Endpoints

The currencylayer API offers up to 5 customizable endpoints, all of which providing different kinds of data and starting out with the following base URL:

http://apilayer.net/api/

Take a look at the following two API endpoints: (If you would like to try them out, get a Free Plan and don't forget to attach your access key to the URL)

                
// "live" - get the most recent exchange rate data
http://apilayer.net/api/live

// "historical" - get historical rates for a specific day  
http://apilayer.net/api/historical?date=YYYY-MM-DD     

                

Each API endpoint is explained in detail below in the API Features section.


256-bit HTTPS Encryption
Basic Pro Enterprise

Paid Customers may establish a secure connection (industry-standard SSL) to the currencylayer API and all data provided by and accessible through it.

To connect securely, simply attach an s to the HTTP Protocol. (resulting in https://)


API Response Properties

currencylayer API results are delivered in JSON format for maximum usability. Find below descriptions for the JSON properties returned by the API:


Property Description
"success" true if your query succeeds, and false, if not. (see API Error Codes)
"terms" All data and services provided are for informational purposes only and all usage is at your own risk.
"privacy" Legal reminder for the user to take a look at our Privacy Policy.
"timestamp" Exact date and time (UNIX) the exchange rates were collected.
"source" The currency to which all exchange rates are relative. (default: USD)
"quotes" Contains all Exchange Rate values, consisting of the currency pairs and their respective Conversion rates.

API Error Codes

If your query fails, the currencylayer API will return a 3-digit error-code and a plain text "info" property containing suggestions for the user.

Find below an example error - triggered when a user's monthly API request volume has been reached or exceeded:

{
  "success": false,
  "error": {
    "code": 104,
    "info": "Your monthly usage limit has been reached. Please upgrade your subscription plan."    
  }
}
                


Common API errors:


Code Info [affected API endpoints]
404 User requested a resource which does not exist.
101 User did not supply an access key.
101 User entered an invalid access key.
103 User requested a non-existent API function.
104 User has reached or exceeded his subscription plan's monthly API request allowance.
105 The user's current subscription plan does not support the requested API Function.
106 The user's query did not return any results.

show all errors



JSONP Callbacks

The currencylayer API also supports JSONP Callbacks. To use this feature, simply attach:

callback = CALLBACK_FUNCTION

to any API endpoint, and the result set will be returned as the callback function you specified.

Example query:

http://apilayer.net/api/live?callback=CALLBACK_FUNCTION  
                

Not sure about what JSONP does? Here's a helpful Stack Overflow thread.

Example response:

CALLBACK_FUNCTION ({
  "success": true,
  "terms": "https://currencylayer.com/terms",
  "privacy": "https://currencylayer.com/privacy",
  "timestamp": 1432480209,
  "source": "USD",
  "quotes": {
    "USDAED": 3.67315,
    "USDAFN": 60.790001,
    "USDALL": 126.194504,
    "USDAMD": 477.359985,
    "USDANG": 1.790403,
    [...]
  }
})                
                

Note: The API also supports Access-Control (CORS) headers.


JSON Formatting

In order to enhance readability the currencylayer API features a built-in JSON format function, which displays the API's response in typically JSON-structured format.

To enable this function, simply attach format=1 to any valid API endpoint URL:

http://apilayer.net/api/live
    ? access_key = YOUR_ACCESS_KEY
    & format = 1      
                

Please be aware that enabling format increases the API response's file size, which might have a negative on your application's performance.


HTTP ETags

In order to reduce your request bandwidth, the currencylayer API has built in support for HTTP ETags. These may be very useful optimizing the performance of your application.

Definition:

An Etag ("Entity Tag") is an HTTP response header used to determine whether the content stored in the browser cache still matches the content or entity on the server. As long as the content at that URL is not modified in any way, the Etag remains identical. If that content ever changes, a new and different ETag is assigned.

In our case, ETags allow you to check whether or not exchange rates have changed since your last API request. If the rates have not been modified, your API response will be considerably smaller in size than if they have. Practically, ETags provide a mechanism to cache exchange rate data as long as it is not updated.


HTTP ETags - A Quickstart Guide


Step 1:

Making a request to the currencylayer API will create both an ETag and a Date entry. The ETag works like a fingerprint for the specific result set returned by the API. The Date represents the time at which this data was last modified. Find below examples for both of these properties:

ETag: "1872ade88f3013edeb33decd74a4f947"  
Date: Fri, 10 Apr 2015 12:10:04 GMT
                  

Now you need to cache the entire API result set, including the ETag and Date headers.

Step 2:

The next time you query the API, you need to add the If-None-Match header (containing the ETag value of your previous API request). You also need to include the If-Modified-Since header (containing the Date value of your previous successful API request).

Find below an example of the described headers:

If-None-Match: "1872ade88f3013edeb33decd74a4f947"  
If-Modified-Since: Fri, 10 Apr 2015 12:10:04 GMT
                  

Step 3:

Now, what happens next depends on whether or not the rates have changes since your last request:

304 – Not Modified will be returned if the data has not changed. In this case, the API response will only be around 0.2kb in size. (the whole idea of ETags is to save bandwidth)

• If the data has changed since your last request, the most up-to-date rates will be returned - as ususal - via the API's live endpoint.


API Features

Real-time Rates
Free Basic Pro Enterprise

Both free and paid users may access real-time exchange rates using the currencylayer API's live endpoint.

Optionally, it is possible to define an additional source currency, or specific output currencies using the currencies parameter.

Example query:

http://apilayer.net/api/live
    ? access_key = YOUR_ACCESS_KEY
    & currencies = AUD,EUR,GBP,PLN 
                

Exchange rate data is refreshed every 60 minutes for Free & Basic Customers, every 10 minutes for the Professional Plan, and every 60 seconds for Enterprise Customers.

Example response:

Inside the quotes object, the API will now return the latest available exchange rates for the currencies specified in the currencies parameter (AUD, EUR, GBP and PLN).

{
  "success": true,
  "terms": "https://currencylayer.com/terms",
  "privacy": "https://currencylayer.com/privacy",
  "timestamp": 1432400348,
  "source": "USD",
  "quotes": {
    "USDAUD": 1.278342,
    "USDEUR": 0.908019,
    "USDGBP": 0.645558,
    "USDPLN": 3.731504
  }
}                
                

Historical Rates
Free Basic Pro Enterprise

The currencylayer API provides accurate historical exchange rate data for every past day of the last 16 years.

Historical rates may be accessed by simply attaching the date parameter with a valid date (Format: YYYY-MM-DD) to the API's historical endpoint.

Syntax:

http://apilayer.net/api/historical
    ? access_key = YOUR_ACCESS_KEY
    & date = YYYY-MM-DD      
                

Example query:

http://apilayer.net/api/historical
    ? access_key = YOUR_ACCESS_KEY
    & date = 2005-02-01      
                

Example response:

Inside the quotes object, the API will now return all available exchange rates for your specified date.

{
  "success": true,
  "terms": "https://currencylayer.com/terms",
  "privacy": "https://currencylayer.com/privacy",
  "historical": true,
  "date": "2005-02-01",
  "timestamp": 1107302399,
  "source": "USD",
  "quotes": {
    "USDAED": 3.67266,
    "USDALL": 96.848753,
    "USDAMD": 475.798297,
    "USDANG": 1.790403,
    "USDARS": 2.918969,
    "USDAUD": 1.293878,
    [...]
  }
}
                

Please be aware that Exchange Rate data for certain currencies may not be available for each requested day (e.g. Bitcoin was only introduced in 2009).


Specify Output Currencies
Free Basic Pro Enterprise

For both live and historical rates, you may limit your API request to a set of specific currencies by attaching the currencies parameter followed by any available 3-letter currency codes (divided by commas) of your choice.

Example query:

http://apilayer.net/api/live
    ? access_key = YOUR_ACCESS_KEY
    & currencies = AUD,CHF,EUR,GBP,PLN     
                

The currencies parameter is supported by each of the API's endpoints (except for the Currency Conversion Endpoint) and has no limits in size.

Example response:

Find below an API response containing only five specified output currencies. (AUD, CHF, EUR, GBP and PLN)

{
  "success": true,
  "terms": "https://currencylayer.com/terms",
  "privacy": "https://currencylayer.com/privacy",
  "timestamp": 1430068515,
  "source": "USD",
  "quotes": {
    "USDAUD": 1.278384,
    "USDCHF": 0.953975,
    "USDEUR": 0.919677,
    "USDGBP": 0.658443,
    "USDPLN": 3.713873
  }
}
                

Why the use of this feature is highly recommended

Limiting your API request to only the currencies you really need can reduce the API response's file size by a factor of 10x to 20x, which may have a substantial effect on the performance of your application.

Numbers speak for themselves: Requesting quotes for all 168 currencies from the API's live endpoint results in a file size of slightly over 4KB. Limiting the query to only 6 specific currencies, the response size drops to less than 600B. The illustrated margin is even more significant when wotking with Time-Frame Queries.


Source Currency Switching
Basic Pro Enterprise

Definition: Source Currency

The Source Currency (often also referred to as "base currency") is the currency to which all quote values in an API result set are relative (default value: USD). The Source Currency can be found in the API response's source object. It is also the first 3-letter currency code of a returned currency pair. (e.g. USDEUR, where USD is the Source Currency)

Source Currency Switching

As a paid customer, you may request exchange rates relative to a different source currency than US Dollars, simply by attaching the source parameter followed by the 3-letter currency code of your choice.

Example query:

http://apilayer.net/api/live
    ? access_key = YOUR_ACCESS_KEY
    & source = GBP           
                

The source parameter is supported by each of the API's endpoints (except for the Currency Conversion Endpoint).

Example response:

Using this query all quote values will be returned relative to the source currency you specified (in our example: GBP). The source currency can be found both in the result set's source object and in the listed currency pairs themselves. (the first 3-letter code of each pair represents the Source Currency)

{
  "success": true,
  "terms": "https://currencylayer.com/terms",
  "privacy": "https://currencylayer.com/privacy",
  "timestamp": 1430068515,
  "source": "GBP",
  "quotes": {
    "GBPAED": 5.578448,
    "GBPAFN": 87.869413,
    "GBPALL": 196.414724,
    "GBPAMD": 719.087298,
    "GBPANG": 2.717836,
    "GBPAOA": 165.601846,
    "GBPARS": 13.514458,
    "GBPAUD": 1.941526,
    [...]
    }
}      
                

Please note that only currencies that are part of the respective result set can be set as source currency.


Currency Conversion Endpoint
Basic Pro Enterprise

Using the convert endpoint, you may request the currencylayer API to perform a Single currency conversion on your behalf.

Simply specify a from Currency Code, a to Currency Code, and the amount you would like to convert.

Example query:

http://apilayer.net/api/convert
    ? access_key = YOUR_ACCESS_KEY
    & from = USD
    & to = GBP       
    & amount = 10       
                

As long as you don't specify an additional date along with these properties, the latest available exchange rates will be used for your conversion.

Example response:

A conversion API response contains more information than standard result sets. Your requested query is returned in the query object. It contains the specified from, to, and amount properties. Additionally, the API will return an info object, which indicates how up-to-date the used exchange rates are (timestamp) and at which conversion rate (rate) your specified amount was converted.

At the end of the response, there will be a result property containing your successfully converted amount.

{
  "success": true,
  "terms": "https://currencylayer.com/terms",
  "privacy": "https://currencylayer.com/privacy",
  "query": {
    "from": "USD",
    "to": "GBP",
    "amount": 10
  },
  "info": {
    "timestamp": 1430068515,
    "quote": 0.658443
  },
  "result": 6.58443
}
                



Currency Conversion using Historical Rates


The currencylayer API also supports currency conversions using historical exchange rates. Simply attach an additional date property with a valid date (Format: YYYY-MM-DD) to your query.

Example query:

http://apilayer.net/api/convert
    ? access_key = YOUR_ACCESS_KEY
    & from = USD
    & to = GBP
    & amount = 10
    & date = 2005-01-01
                

Example response:

Additionally to the above mentioned properties and objects, the API will return "historical" : true to confirm your request, and the date you specified (also indicated by the timestamp property).

{
  "success": true,
  "terms": "https://currencylayer.com/terms",
  "privacy": "https://currencylayer.com/privacy",
  "query": {
    "from": "USD",
    "to": "GBP",
    "amount": 10
  },
  "info": {
    "timestamp": 1104623999,
    "quote": 0.51961
  },
  "historical": true,
  "date": "2005-01-01",
  "result": 5.1961
}
                

Please note that historical currency conversions can only be performed if exchange rate data for the respective currencies are available at the specified date.


Time-Frame Queries
Pro Enterprise

If your subscription plan features the timeframe API endpoint, you may request historical exchange rates for a time-period of your choice. (maximum range: 365 days)

Simply specify your preferred time-frame, consisting of a start_date and an end_date, both of the format YYYY-MM-DD.

Example query:

http://apilayer.net/api/timeframe
    ? access_key = YOUR_ACCESS_KEY
    & start_date = 2010-03-01
    & end_date = 2010-04-01
    & currencies = USD,GBP,EUR
                

Example response:

Along with "timeframe": true, the start_date, and the end_date, the API response's quotes object will contain the specified exchange rates divided into "sub-objects" for each of the days within the requested time-frame.

{
  "success": true,
  "terms": "https://currencylayer.com/terms",
  "privacy": "https://currencylayer.com/privacy",
  "timeframe": true,
  "start_date": "2010-03-01",
  "end_date": "2010-04-01",
  "source": "USD",
  "quotes": {
    "2010-03-01": {
      "USDUSD": 1,
      "USDGBP": 0.668525,
      "USDEUR": 0.738541
    },
    "2010-03-02": {
      "USDUSD": 1,
      "USDGBP": 0.668827,
      "USDEUR": 0.736145
    },
    [...]
  }
}    
                

Please note: Since the currencylayer API allows time-frames of up to 365 days, not limiting your query in output currencies may result in very large file sizes. For optimum performance and a lower server-load, it is highly recommended to use this feature combined with the currencies parameter, which allows you to output a custom selection of currencies.


Currency-Change Queries
Enterprise

Using the API's change endpoint, you may request the change (both margin and percentage) of one or more currencies, relative to a Source Currency, within a specific time-frame (optional).

Unlike with Time-Frame Queries, performing a Currency-Change Query does not require you to specify a time-frame. If you do not provide a time-frame, the API will automatically return the change values ranging from yesterday's EOD (End Of Day) data, to the latest available exchange rates of today.

However, if you decide to specify a start_date and and end_date (both of the format YYYY-MM-DD), the API will return change values for your preferred time-frame.

Example query:

http://apilayer.net/api/change
    ? access_key = YOUR_ACCESS_KEY
    & start_date = 2005-01-01
    & end_date = 2010-01-01
    & currencies = AUD,EUR,MXN
                

Example response:

To indicate that you are performing a change query, the API will return "change": true. Right below, your specified start_date and end_date will be part of the API response as well.

Just like when performing a Time-Frame Query, the API response's quotes object will be divided in sub-objects (one for each requested currency).

The four properties contained in these sub-objects are explained below in Code View:

start_rate     the respective currency's exchange rate at the  
               beginning of the specified period
               
end_rate       the respective currency's exchange rate at the  
               end of the specified period
               
change         the margin between the currency's start_rate
               end_rate
               
change_pct     the currency's percentage change within the 
               specified time-frame               
                

This is how the complete API response will look like:

{
  "success": true,
  "terms": "https://currencylayer.com/terms",
  "privacy": "https://currencylayer.com/privacy",
  "change": true,
  "start_date": "2005-01-01",
  "end_date": "2010-01-01",
  "source": "USD",
  "quotes": {
    "USDAUD": {
      "start_rate": 1.281236,
      "end_rate": 1.108609,
      "change": -0.1726,
      "change_pct": -13.4735
    },
    "USDEUR": {
      "start_rate": 0.73618,
      "end_rate": 0.697253,
      "change": -0.0389,
      "change_pct": -5.2877
    },
    "USDMXN":{
      "start_rate": 11.149362,
      "end_rate": 13.108757,
      "change": 1.9594,
      "change_pct": 17.5741
    }
  }
} 
                

If the decimal values contained both in the change and in the change_pct property are positive, the value of the respective currency increased over the course of the specified time-frame. (e.g. "change_pct": 17.5741 would be a +17.57% increase). If the values are negative, it decreased. (e.g. "change_pct": -5.2877 would be a -5.29% decrease)


"change": 0

If the change and change_pct properties equal zero, either the specified currency's exchange rate value has not changed over the course of the entire time-frame, or an exchange rate value for the respective currency on at least one of the specified dates is "unavailable".

Please note: Since foreign exchange (forex) markets are only open from Sunday 5 PM ET to Friday 5 PM ET, change parameters may converge to zero during weekends.


Code Examples

PHP (CURL)

Accessing Real-time exchange rates:

Find below an example for how to access the latest exchange rate data via PHP (CURL):

// set API Endpoint and access key (and any options of your choice)
$endpoint = 'live';
$access_key = 'YOUR_ACCESS_KEY';

// Initialize CURL:
$ch = curl_init('http://apilayer.net/api/'.$endpoint.'?access_key='.$access_key.'');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

// Store the data:
$json = curl_exec($ch);
curl_close($ch);

// Decode JSON response:
$exchangeRates = json_decode($json, true);

// Access the exchange rate values, e.g. GBP:
echo $exchangeRates['quotes']['USDGBP'];
                

Performing a Currency Conversion:

Converting one currency to another in PHP (CURL) is as simple as:

// set API Endpoint, access key, required parameters
$endpoint = 'convert';
$access_key = 'YOUR_ACCESS_KEY';

$from = 'USD';
$to = 'EUR';
$amount = 10;

// initialize CURL:
$ch = curl_init('http://apilayer.net/api/'.$endpoint.'?access_key='.$access_key.'&from='.$from.'&to='.$to.'&amount='.$amount.'');   
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

// get the (still encoded) JSON data:
$json = curl_exec($ch);
curl_close($ch);

// Decode JSON response:
$conversionResult = json_decode($json, true);

// access the conversion result
echo $conversionResult['result'];
                

JavaScript (jQuery.ajax)

Echange Rates can be easily accessed by using jQuery to make an AJAX call. Using this method is widely used and highly recommend due to ease of integration.

Accessing Real-time exchange rates:

Find below an example for how to access the latest exchange rate data via jQuery.ajax:

// set endpoint and your access key
endpoint = 'live'
access_key = 'YOUR_ACCESS_KEY';

// get the most recent exchange rates via the "live" endpoint:
$.ajax({
    url: 'http://apilayer.net/api/' + endpoint + '?access_key=' + access_key,   
    dataType: 'jsonp',
    success: function(json) {

        // exchange rata data is stored in json.quotes
        alert(json.quotes.USDGBP);
        
        // source currency is stored in json.source
        alert(json.source);
        
        // timestamp can be accessed in json.timestamp
        alert(json.timestamp);
        
    }
});
                

Performing a Currency Conversion:

Converting one currency to another in jQuery.ajax is as simple as:

// set endpoint and your access key
endpoint = 'convert';
access_key = 'YOUR_ACCESS_KEY';

// define from currency, to currency, and amount
from = 'EUR';
to = 'GBP';
amount = '10';

// execute the conversion using the "convert" endpoint:
$.ajax({
    url: 'http://apilayer.net/api/' + endpoint + '?access_key=' + access_key +'&from=' + from + '&to=' + to + '&amount=' + amount,   
    dataType: 'jsonp',
    success: function(json) {

        // access the conversion result in json.result
        alert(json.result);
                
    }
});
                

Java

Making use of a variety of Apache HTTP Components, there is a fairly simple way to query the API using Java. Based on the following integration methods for the API's live and convert endpoints, we will try to provide a general idea of how currencylayer JSON data can be accessed using Java.

Accessing Real-time exchange rates:

Find below an example for how to access and display the latest exchange rate data using Java:

package org.json.poc;

// necessary components are imported
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.apache.http.HttpEntity;
import org.apache.http.ParseException;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.json.JSONException;
import org.json.JSONObject;

public class LiveResponseDemo{

    // essential URL structure is built using constants
    public static final String ACCESS_KEY = "YOUR_ACCESS_KEY";
    public static final String BASE_URL = "http://apilayer.net/api/";
    public static final String ENDPOINT = "live";

    // this object is used for executing requests to the (REST) API
    static CloseableHttpClient httpClient = HttpClients.createDefault();

    
    /**
     * 
     * Notes:
     * 
     * A JSON response of the form {"key":"value"} is considered a simple Java JSONObject.
     * To get a simple value from the JSONObject, use: <JSONObject identifier>.get<Type>("key");
     * 
     * A JSON response of the form {"key":{"key":"value"}} is considered a complex Java JSONObject.
     * To get a complex value like another JSONObject, use: <JSONObject identifier>.getJSONObject("key")
     * 
     * Values can also be JSONArray Objects. JSONArray objects are simple, consisting of multiple JSONObject Objects.
     * 
     * 
     */
     

    // sendLiveRequest() function is created to request and retrieve the data
    public static void sendLiveRequest(){

        // The following line initializes the HttpGet Object with the URL in order to send a request
        HttpGet get = new HttpGet(BASE_URL + ENDPOINT + "?access_key=" + ACCESS_KEY);

        try {
            CloseableHttpResponse response =  httpClient.execute(get);
            HttpEntity entity = response.getEntity();

            // the following line converts the JSON Response to an equivalent Java Object
            JSONObject exchangeRates = new JSONObject(EntityUtils.toString(entity));

            System.out.println("Live Currency Exchange Rates");

            // Parsed JSON Objects are accessed according to the JSON resonse's hierarchy, output strings are built
            Date timeStampDate = new Date((long)(exchangeRates.getLong("timestamp")*1000)); 
            DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss a");
            String formattedDate = dateFormat.format(timeStampDate);
            System.out.println("1 " + exchangeRates.getString("source") + " in GBP : " + exchangeRates.getJSONObject("quotes").getDouble("USDGBP") + " (Date: " + formattedDate + ")");   
            System.out.println("\n");
            response.close();
        } catch (ClientProtocolException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

        // sendLiveRequest() function is executed
    public static void main(String[] args) throws IOException{
        sendLiveRequest();
        httpClient.close();
        new BufferedReader(new InputStreamReader(System.in)).readLine();
    }
}
                

The Java Output will look like this:

Live Currency Exchange Rates
1 USD in GBP : 0.66046 (Date: 2015-05-02 21:26:15 PM)
                

The entire Java demo source code, along with all necessary components, is available for download at our GitHub Repository.


Downloads

HTML Select-Option Menu

Get a full list of all supported currencies wrapped in HTML <select> <option> tags:

<select name='currencies'>
   <option value='AED' title='United Arab Emirates Dirham'>AED</option>
   <option value='AFN' title='Afghan Afghani'>AFN</option>
   <option value='ALL' title='Albanian Lek'>ALL</option>
   <option value='AMD' title='Armenian Dram'>AMD</option>
   <option value='ANG' title='Netherlands Antillean Guilder'>ANG</option>
   [...]
</select>
                

HTML Currencies Table

Download a clean HTML <table> containing all supported currencies:

<table>
   <thead>
      <tr>
         <th>Code</th>
         <th>Name</th>
      </tr>
   </thead>
   <tbody>
      <tr>
         <td>AED</td>
         <td>United Arab Emirates Dirham</td>
      </tr>
      <tr>
         <td>AFN</td>
         <td>Afghan Afghani</td>
      </tr>
      <tr>
         <td>ALL</td>
         <td>Albanian Lek</td>
      </tr>
      <tr>
         <td>AMD</td>
         <td>Armenian Dram</td>
      </tr>
      [...]
   </tbody>
</table>