How to get historical data for currency exchange rates via Yahoo Finance?

Sergey V. picture Sergey V. · Mar 7, 2015 · Viewed 30.7k times · Source

I need to obtain JSON or XML response with the chronology of currency exchange rates, for example, from 2015-01-07 to 2015-03-07.

With this answer we can get just the latest info on currency exchange rates for chosen currencies.

Here we can get the currency exchange rates for certain date using the URL: http://finance.yahoo.com/connection/currency-converter-cache?date=20150307 and parsing the obtained JSON for certain currency.

But I need to get currency exchange rates for the range of dates as it is here but at the JSON or XML format.

Is there a way to do that?

Answer

dym picture dym · Jul 30, 2015

Use YQL (https://developer.yahoo.com/yql/)

Then you can retrieve the data you need with a query like this:

SELECT * 
FROM 
    yahoo.finance.historicaldata 
WHERE 
    symbol = "EUR=X" 
AND 
    startDate = "2009-09-11" 
AND 
    endDate = "2010-03-10"

Check here