开发者

Yahoo Finance All Currencies quote API Documentation

I've being using this feed for a long time, I believe Apple does it as well in one of the mac widgets. but what is really curious is that I simply can't find any documentation for it, I've tried google and everything.

http://finance.yahoo.com/webservice/v1/symbols/allcurrencies/quote

I can see people using different parameters like view=basic date=Ymd; currency=true but it's horrible there isn't anything official.

For now I am using these parameters:

format=json and callback=list sometimes...

But it is still a 开发者_运维知识库mystery for me. Does anyone know the real truth about it because it seems Yahoo is trying to hide it somewhere else :)


From the research that I've done, there doesn't appear to be any documentation available for the API you're using. Depending on the data you're trying to get, I'd recommend using Yahoo's YQL API for accessing Yahoo Finance (An example can be found here). Alternatively, you could try using this well documented way to get CSV data from Yahoo Finance.

EDIT:

There has been some discussion on the Yahoo developer forums and it looks like there is no documentation (emphasis mine):

The reason for the lack of documentation is that we don't have a Finance API. It appears some have reverse engineered an API that they use to pull Finance data, but they are breaking our Terms of Service (no redistribution of Finance data) in doing this so I would encourage you to avoid using these webservices.

At the same time, the URL you've listed can be accessed using the YQL console, though I'm not savvy enough to know how to extract URL parameters with it.


ATTENTION !!!

SERVICE SUSPENDED BY YAHOO

I now use a free account at https://currencyscoop.com/ that lets me use the API commercially with up to 5000 free requests a month (that is around a request every 10 minutes).

Outdated solution (no longer valid)

Get from Yahoo a JSON or XML that you can parse from a REST query.

You can exchange from any to any currency and even get the date and time of the query using the YQL (Yahoo Query Language).

https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20csv%20where%20url%3D%22http%3A%2F%2Ffinance.yahoo.com%2Fd%2Fquotes.csv%3Fe%3D.csv%26f%3Dnl1d1t1%26s%3Dusdeur%3DX%22%3B&format=json&callback=

This will bring an example like below:

{
 "query": {
  "count": 1,
  "created": "2016-02-12T07:07:30Z",
  "lang": "en-US",
  "results": {
   "row": {
    "col0": "USD/EUR",
    "col1": "0.8835",
    "col2": "2/12/2016",
    "col3": "7:07am"
   }
  }
 }
}

You can try the console

I think this does not break any Term of Service as it is a 100% yahoo solution.


This could help: http://finance.yahoo.com/d/quotes.csv?e=.csv&f=c4l1&s=EURUSD=X,GBPUSD=X It will return csv file:

"EUR",1.2972
"GBP",1.6034

Or if you need json: Yahoo csv parser


I'm developing an application that needs currency conversion, and been using Open Exchange Rates because I wouldn't be paying since the app is in testing. But as of September 2012 Open Exchange Rates is gonna be paid for non-personal, so I checked out that they were using the Yahoo Finance Webservice (the one that "doesn't exist") and looking for documentation on it got here, and opted to use YQL.

Using YQL with the Yahoo Finance table (yahoo.finance.quotes) linked by NT3RP, currencies appear with symbol="ISOCODE=X", for example: "ARS=X" for Argentine Peso, "AUD=X" for Australian Dollar. "USD=X" doesn't exist, but it would be 1, since the rest are rates against USD.

The "price" value on the OP API is in the field "LastTradePriceOnly" of the table. For my application I used the "Ask" field.


As NT3RP told us that:

... we (Yahoo!) don't have a Finance API. It appears some have reverse engineered an API that they use to pull Finance data, but they are breaking our Terms of Service...

So I just thought of sharing this site with you:
http://josscrowcroft.github.com/open-exchange-rates/
[update: site has moved to - http://openexchangerates.org]

This site says:

No access fees, no rate limits, no ugly XML - just free, hourly updated exchange rates in JSON format
[update: Free for personal use, a bargain for your business.]

I hope I've helped and this is of some use to you (and others too). : )


Updated query for Yahoo! Finance,

https://query1.finance.yahoo.com/v7/finance/quote?&symbols=USD,CAD,EUR,XMR&fields=regularMarketPrice

returns

{
"quoteResponse": {
    "result": [
        {
            "language": "en-US",
            "region": "US",
            "quoteType": "ETF",
            "quoteSourceName": "Delayed Quote",
            "triggerable": true,
            "exchange": "PCX",
            "exchangeTimezoneName": "America/New_York",
            "exchangeTimezoneShortName": "EDT",
            "gmtOffSetMilliseconds": -14400000,
            "market": "us_market",
            "esgPopulated": false,
            "firstTradeDateMilliseconds": 1170340200000,
            "priceHint": 2,
            "regularMarketTime": 1628712000,
            "regularMarketPrice": 35.56,
            "fullExchangeName": "NYSEArca",
            "tradeable": false,
            "sourceInterval": 15,
            "exchangeDataDelayedBy": 0,
            "marketState": "PRE",
            "symbol": "USD"
        },
        {
            "language": "en-US",
            "region": "US",
            "quoteType": "ETF",
            "quoteSourceName": "Delayed Quote",
            "triggerable": true,
            "exchange": "PCX",
            "exchangeTimezoneName": "America/New_York",
            "exchangeTimezoneShortName": "EDT",
            "gmtOffSetMilliseconds": -14400000,
            "market": "us_market",
            "esgPopulated": false,
            "firstTradeDateMilliseconds": 1320935400000,
            "priceHint": 2,
            "regularMarketTime": 1411675200,
            "regularMarketPrice": 95.879,
            "fullExchangeName": "NYSEArca",
            "tradeable": false,
            "sourceInterval": 15,
            "exchangeDataDelayedBy": 0,
            "marketState": "PRE",
            "symbol": "CAD"
        },
        {
            "language": "en-US",
            "region": "US",
            "quoteType": "INDEX",
            "triggerable": false,
            "exchange": "NYS",
            "exchangeTimezoneName": "America/New_York",
            "exchangeTimezoneShortName": "EDT",
            "gmtOffSetMilliseconds": -14400000,
            "market": "us_market",
            "esgPopulated": false,
            "firstTradeDateMilliseconds": 1543501800000,
            "priceHint": 4,
            "regularMarketTime": 0,
            "regularMarketPrice": 0.0,
            "fullExchangeName": "NYSE",
            "tradeable": false,
            "sourceInterval": 15,
            "exchangeDataDelayedBy": 0,
            "marketState": "PRE",
            "symbol": "EUR"
        },
        {
            "language": "en-US",
            "region": "US",
            "quoteType": "ECNQUOTE",
            "quoteSourceName": "Delayed Quote",
            "triggerable": true,
            "exchange": "NMS",
            "exchangeTimezoneName": "America/New_York",
            "exchangeTimezoneShortName": "EDT",
            "gmtOffSetMilliseconds": -14400000,
            "market": "us_market",
            "esgPopulated": false,
            "firstTradeDateMilliseconds": 1493213400000,
            "fullExchangeName": "NasdaqGS",
            "tradeable": false,
            "sourceInterval": 15,
            "exchangeDataDelayedBy": 0,
            "marketState": "PRE",
            "symbol": "XMR"
        }
    ],
    "error": null
}

}


I have used this URL to obtain multiple currency market quotes.

http://finance.yahoo.com/d/quotes.csv?e=.csv&f=c4l1&s=USD=X,CAD=X,EUR=X

"USD",1.0000
"CAD",1.2458
"EUR",0.8396

They can be parsed in PHP like this:

$symbols = ['USD=X', 'CAD=X', 'EUR=X'];
$url = "http://finance.yahoo.com/d/quotes.csv?e=.csv&f=c4l1&s=".join($symbols, ',');

$quote = array_map( 'str_getcsv', file($url) );

foreach ($quote as $key => $symb) {
    $symbol = $quote[$key][0];
    $value = $quote[$key][1];
}


As of 2022, I was successful using:

  • https://query1.finance.yahoo.com/v7/finance/spark?symbols=EURGBP%3DX
  • https://query1.finance.yahoo.com/v7/finance/spark?symbols=EURUSD%3DX

You can also request multiples pairs in a single call:

  • https://query1.finance.yahoo.com/v7/finance/spark?symbols=USDEUR=X,EURGBP=X

Notes:

  • Delayed. Not to be used for realtime quotes or trading information;
  • Check ['spark']['result'][0]['meta']['regularMarketTime'] to get the quote timestamp;
  • If yahoo is not a requirement, you can use https://assets.ino.com/data/quote/?format=json&s=FOREX_EURGBP;
  • Links found sniffing XHR network requests while browsing Forex websites;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜