views:

3228

answers:

9

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.

+1  A: 

coinnill.com has a sort-of web-service.

http://coinmill.com/rss/AUD_USD.xml

will give you the AUD --> USD rate for example. You'll just need to parse the XML that comes back.

cagcowboy
That data seems out of date. It says AUD is 0.77 but I know it is 0.69 today.
Adam Pierce
+1  A: 

XE.com provides feed for their exchange rates. Not free though.

jop
+5  A: 

Here is a Soap service that offers exchange rate

http://www.newyorkfed.org/markets/pilotfx.html

Ólafur Waage
Shame it's SOAP and not REST. Apart from that, it's a useful facility
David Arno
Is this free and stable? Will I be able to ship software that relies on this?
apparently they stopped doing this @ 31.12.2008
Sevki
+2  A: 

This site has a currency converter service for free:

http://www.webservicex.net/WS/WSDetails.aspx?WSID=10

Ch00k
+23  A: 

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

Greg
That is up to date and easy to parse. This is what I am after.
Adam Pierce
I am also interested in this, is there any information on what the parameters stand for?Specifically the "f" parameter. I can't find any info anywhere.
Fishcake
Is it legal to read this data if you have a commercial website?
Junior Mayhé
The "f" field seems to be a (non delimited) list of fields you wish to see in the resulting csv file. A little experimentation reveals the field code "n" may also be handy.
Myster
Myster
+5  A: 

Might be nice to add

  http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml

to the list.

The official reference rates provides by the European Central Bank based on the regular daily concertation procedure between central banks within and outside the European System of Central Banks.

The feed is in XML and some other formats.
Updating normally takes place at 2.15 p.m. (14:15) ECB time (= Frankfurt time).

Jacco
seems to be unavailable. I found http://www.ecb.int/euro.html
Junior Mayhé
Just checked (20 minutes after your comment) and it available for me.
Jacco
+1  A: 

Oanda.com exposes currency rates as an XML API, but not for free

Eugene Osovetsky
+5  A: 

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.

philoye
Also, forex rates change all the time, and banks may only take into account the rate at midnight, local time. With ~2% daily volatility, there *is* incertitude.
Alexandre C.
That's a great point. Definitely reinforces the need for a buffer of some kind if you are displaying one currency, but charging another. For what it is worth, with my 4% padding, I've never had anyone do a chargeback.
philoye
+1  A: 

I feel compelled to add:

http://www.exchangerate-api.com/

Dead simple to use with a clean RESTful API and signup takes 5 seconds. Includes coding examples for most major languages, most are 2-3 lines long.

Rates are updated hourly, so it's fine for most uses, and you get 1500 monthy queries for free. I've never needed more than that, but the rates are very reasonable for higher volumes.

Alex