Forum OpenACS Q&A: API for Currency conversion

Posted by Iuri Sampaio on
Hi there,

Does anyone know an API or webservice for real time currency conversion?

Posted by Jeff Rogers on
A few sources for rate data, although I believe it's all delayed:

Yahoo finance via YQL:

For data directly from Yahoo finance, there is a "download" link on any quote page, something like

Get Exchange Rates api gives you a snapshot in json format-

Open Exchange Rates has a paid api that is free for small-scale use:

Posted by Benjamin Brink on
Depending on the currencies of your application, current market information might be "leaked" through a popularly used crypto coin exchange:


Posted by Iuri Sampaio on
Hi Benjamin,

I'll have a look at those references you posted.

I also found something on google APIs.

The one I really liked, and thought it was very good to emphasize here, came form European Central Bank.

I believe that one we could have more confidence!

It's a webservice where you can grab an xml file with daily quotations.
Pretty and neat! Check it out.

Posted by Gustaf Neumann on
Hear, Hear, there is someone with confidence in the ECB!
(just joking).
Posted by Antonio Pisano on
I have some working code into a proc we used some time ago which queried that same webservice. It uses tdom to extract exchange rates and load them in the db.

If interested I can send it to you.

Being a common feature request in web applications, we could think about writing a little wrapper, based on this and/or other official webservices and populate a standard table...

Posted by Antonio Pisano on
I have some spare time and could have some fun implementing the feature.

Should work like this: the proc queries for a rate into a table called currency_exchange_rates. This table has 4 columns - currency_from, currency_to, exchage_rate, exchange_date.

If an entry is found, the result is returned, otherwise it is retrieved in one of this ways:
- yahoo finance if date is current date
- ECB if date is previous. As the rates are available only from Euro, the rate from different currencies would have to be derived (with possible loss of precision, yet little)

I would use this two because are free of charge, official and stable enough, but could use others if someone finds them (my searches didn't).

The rate so obtained will be then stored in table and cached.

The table could be created in the ref-currency package. The procs should go elsewhere, because the package is meant to contain only data... what could be a proper place?

This is the plan. Of course I don't want to build a cathedral in the desert, even if it would be for fun, so I will start working when I receive some feedback! 😊