Exchange Rate API

How it Works

Our service is the easy to use and reliable currency API that's perfect for both personal and professional use.

Using ExchangeRate-API.com is as simple as making HTTP requests:

Call:

http://www.exchangerate-api.com/FROM_CURRENCY/TO_CURRENCY/AMOUNT?k=YOUR_API_KEY
FROM_CURRENCY:A three letter currency code (see supported currency codes)
TO_CURRENCY:A three letter currency code (see supported currency codes)
AMOUNT:The value in your base currency (optional)


Returns:

CONVERTED_AMOUNT
CONVERTED_AMOUNT:The converted value (or the exchange-rate if AMOUNT is ommitted)



Example: To convert 9.99 US Dollars to Euros:
Call:

http://www.exchangerate-api.com/usd/eur/9.99?k=API_KEY

Returns:

7.61


Useful for: This a API query can be used whenever you already know what currency you want to convert from and to. For example, you may have a website where the user manually selects the currency they wish to use. You can then call this query to convert all the prices on your page to the correct amounts.

How do I implement this in code? We have compiled a large selection of code examples to illustrate how to implement our API in a variety of programming languages. Look to the top left of this page for links to each language example.

Error Codes:

The API returns the following error codes:
  -1 if an invalid amount is used (Must be numeric floating point or integer numbers)
  -2 if either of the 3 letter currency codes are invalid (Check our supported currencies)
  -3 if an invalid key is used (Get an API key)
  -4 if your API query limit is reached (Click here for extended usage)



We also offer two additional types of query:




1. Automatic currency conversion based on user's country:

Call:
http://www.exchangerate-api.com/auto/FROM_CURRENCY/IP_ADDRESS/AMOUNT?k=YOUR_API_KEY
FROM_CURRENCY:A three letter currency code (see supported currency codes)
IP_ADDRESS:A dot-decimal IP address (see how to obtain a user's IP address)
AMOUNT:The value in your base currency (optional)


Returns:

CONVERTED_AMOUNT|CURRENCY_SYMBOL_UNICODE|CURRENCY_CODE
CONVERTED_AMOUNT:The converted value (or the exchange-rate if AMOUNT is ommitted)
CURRENCY_SYMBOL_UNICODE:The unicode value of the new currency's symbol, eg: $. (NB: Please read)
CURRENCY_CODE:The new currency's three letter currency code, eg: USD

Example: To convert $10.95 for a user with an IP address of 178.79.140.74

Call:
http://www.exchangerate-api.com/auto/USD/178.79.140.74/10.95?k=YOUR_API_KEY
Returns:
85.43|82|ZAR


Useful for: This query is extremely useful if you would like your website or app to automatically display the correct prices depending on the user's country. For example, an American user will see all prices on your website in US Dollars, while someone landing on your site from England will see all prices in British Pounds. This will happen automatically, and they will not need to manually choose their currencies.


How do I implement this in code? We have compiled a large selection of code examples to illustrate how to implement our API in a variety of programming languages. You can find these examples here


What if you don't have the exchange rate information for that country? If your user is in a country we don't have information for, or if their IP Address is somehow invalid, this query will return the original amount, currency-symbol and currency code of the FROM_CURRENCY submitted. So if your base currency is USD, your website will simply display USD amounts for these users. See our supported currencies here

Free 14-Day Trial

Sign Up Now!

Get started right away!


2. Get country info and flag based on user's country:


Call:
http://www.exchangerate-api.com/country_info/IP_ADDRESS?k=YOUR_API_KEY
IP_ADDRESS:A dot-decimal IP address (see how to obtain a user's IP address)


Returns:

COUNTRY_NAME|2_DIGIT_COUNTRY_CODE|3_DIGIT_COUNTRY_CODE|CURRENCY_CODE|CURRENCY_SYMB
OL_UNICODE|FLAG
COUNTRY_NAME:The user's country's name
2_DIGIT_COUNTRY_CODE:ISO 3166-1 alpha-2 country code (eg: US)
3_DIGIT_COUNTRY_CODE:ISO 3166-1 alpha-3 country code (eg: USA)
CURRENCY_CODE:ISO 4217 currency code (eg: USD)
CURRENCY_SYMBOL_UNICODE:The unicode value of the currency's symbol, eg: $. (NB: Please read)
FLAG:A URL for a 16x11 country flag gif image (eg: )

Example: To get country information for a user with an IP address of 178.79.140.74:

Call:
http://www.exchangerate-api.com/country_info/178.79.140.74?k=YOUR_API_KEY
Returns:
South Africa|ZA|ZAF|ZAR|82|http://www.exchangerate-api.com/small/za.gif


Useful for: This query is extremely useful if you would like to internationalize your website or app. For example, you can automatically display the user's country flag on the site, or display inviting text such as "We welcome all [country_name] users!". Of course, it's great to call this query in conjunction with the automatic currency conversion query if you are displaying any prices on your site.


How do I implement this in code? We have compiled a large selection of code examples to illustrate how to implement our API in a variety of programming languages. You can find these examples here


What if the IP address is invalid? In 99.5% of cases we can match a given IP to a country. However, if your user's IP Address is somehow invalid, or we cannot match it to a country, this query will return "-5". It is important that your code can handle this gracefully.

Free 14-Day Trial

Sign Up Now!

Get started right away!