yahoo-finance

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


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?


Solution

  • 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