Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically access currency exchange rates [closed]

I'm setting up an online ordering system but I'm in Australia and for international customers I'd like to show prices in US dollars or Euros so they don't have to make the mental effort to convert from Australian dollars.

Does anyone know if I can pull up to date exchange rates off the net somewhere in an easy-to-parse format I can access from my PHP script ?


UPDATE: I have now written a PHP class which implements this. You can get the code from my website.

like image 655
Adam Pierce Avatar asked Oct 08 '08 09:10

Adam Pierce


People also ask

Is there a free exchange rate API?

Exchange rates API is a free service for current and historical foreign exchange rates & crypto exchange rates.

Does Google have a currency converter API?

Google is providing a finance API to convert one currency to another currency in real-time. You will get real-time information on the currency conversion rate of any country. It's very easy and helpful to get currency conversion rate information.

What is fixer API?

Fixer is a simple and lightweight API for. current and historical foreign exchange (forex) rates.


2 Answers

You can get currency conversions in a simple format from yahoo:

For example, to convert from GBP to EUR: http://download.finance.yahoo.com/d/quotes.csv?s=GBPEUR=X&f=sl1d1t1ba&e=.csv

like image 116
Greg Avatar answered Sep 25 '22 17:09

Greg


This answer is VERY late, but there is a key bit of info missing from the above answers.

If you want to show accurate prices to your customers it is important to understand how foreign exchange rates work.

Most FX services only quote the spot rate (midway between the Bid and Ask). The spot is a kind of shorthand for the exchange rate, but no one gets the spot because you can only sell at the bid or buy at the ask. You're usually looking at least a 1% spread between them, so the spot rate is 0.5% off for your customers.

But it doesn't stop there, your customers almost certainly are using a credit card and Visa/Mastercard/Amex all charge foreign exchange fees. These are non-trivial in my experience, at LEAST 2.5%. For example, Citibank Australia charges 3.3%. These vary from card to card so there's no way for you to predict the final price that your customers will be billed.

If you want to quote an "accurate" price to your customers based on an exchange rate, you need to factor in the above and provide a buffer so that you don't end up charging more than what you quoted.

FWIW, I've been adding 4% to what the F/X conversion would otherwise indicate.

like image 21
philoye Avatar answered Sep 23 '22 17:09

philoye