-
-
Save henrik/265014 to your computer and use it in GitHub Desktop.
Get exchange rate as JSONP via YQL. | |
YQL Console: http://developer.yahoo.com/yql/console | |
Query (USD to SEK): select rate,name from csv where url='http://download.finance.yahoo.com/d/quotes?s=USDSEK%3DX&f=l1n' and columns='rate,name' | |
Example code: | |
<script type="text/javascript"> | |
function getRate(from, to) { | |
var script = document.createElement('script'); | |
script.setAttribute('src', "http://query.yahooapis.com/v1/public/yql?q=select%20rate%2Cname%20from%20csv%20where%20url%3D'http%3A%2F%2Fdownload.finance.yahoo.com%2Fd%2Fquotes%3Fs%3D"+from+to+"%253DX%26f%3Dl1n'%20and%20columns%3D'rate%2Cname'&format=json&callback=parseExchangeRate"); | |
document.body.appendChild(script); | |
} | |
function parseExchangeRate(data) { | |
var name = data.query.results.row.name; | |
var rate = parseFloat(data.query.results.row.rate, 10); | |
alert("Exchange rate " + name + " is " + rate); | |
} | |
getRate("SEK", "USD"); | |
getRate("USD", "SEK"); | |
</script> |
@luissquall: Nice, thanks!
How can i filter it by date, for example, how to get the yesterday (or previous) rates?
Change http://
to //
to automatically adjust the script protocol to the page protocol (HTTP/HTTPS). YQL Console is available over HTTPS.
How can i filter it by date, for example, how to get the yesterday (or previous) rates?
please
Excelent! works :)
Excelent
Hi! Thanks a lot for the code, works perfectly. One question, how I can store each request as a variable to use it later? For example if i do getRate("SEK", "USD");, how I can store that rate so I can multiply it and get the currency conversion?
This always converts any currency with default amount.
1 is default where in code amount is given 10 to be converted.
I had use this. It works great for me.
Exchange Rates in Excel
Wonderful, thank you for your great work
Doesn't return results, it's fail.
{"query":{"count":0,"created":"2017-11-03T04:01:34Z","lang":"ru-RU","results":null}}
Thanks Yahoo.
http://download.finance.yahoo.com/
It has come to our attention that this service is being used in violation of the Yahoo Terms of Service. As such, the service is being discontinued. For all future markets and equities data research, please refer to finance.yahoo.com.
Administratin' 'Hoo Nixon Administratin' 'Hoo
Re: Is Yahoo! Finance API broken?
Hi All - I'm blocking new replies to this thread since it refers to an older outage.
The new download issue which began 11/01/17 and returning an error 999 for most users is currently being investigated and we hope to have it resolved soon.
@kasimvali786 Yahoo has discontinued this API I'm afraid. See the comment before yours.
Hi Henrik,
Yes, I noticed that before comment, do you have any idea is there any link API URL to get the daily exchange rates.
Thanks in advanced.
@kasimvali786
You can use this one
`https://finance.google.com/finance/converter?a=${amout}&from=${from}&to=${to}`
@Sheff3rd
This might be too much to ask but can you post an example to convert USD to INR using the above URL ?
Looks like both APIs are not working.
You should try this: http://developer.yahoo.com/yql/console/?q=show%20tables&env=store://datatables.org/alltableswithkeys#h=select%20*%20from%20yahoo.finance.xchange%20where%20pair%20in%20%28%22USDMXN%22%29