json 雅虎财经所有货币报价 API 文档

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5108399/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 17:46:22  来源:igfitidea点击:

Yahoo Finance All Currencies quote API Documentation

jsonapiyahoocurrencyfinance

提问by zanona

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.

我已经使用这个提要很长时间了,我相信 Apple 在其中一个 mac 小部件中也这样做了。但真正令人好奇的是,我根本找不到任何相关文档,我尝试了 google 和所有方法。

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

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

I can see people using different parameters like view=basicdate=Ymd;currency=truebut it's horrible there isn't anything official.

我可以看到人们使用不同的参数,view=basicdate=Ymd;currency=true但可怕的是没有任何官方的东西。

For now I am using these parameters:

现在我正在使用这些参数:

format=jsonand callback=listsometimes...

format=jsoncallback=list有时...

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 :)

但这对我来说仍然是个谜。有没有人知道它的真实情况,因为雅虎似乎试图将其隐藏在其他地方:)

采纳答案by NT3RP

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.

根据我所做的研究,您使用的 API 似乎没有任何可用的文档。根据您尝试获取的数据,我建议使用 Yahoo's YQL API 来访问 Yahoo Finance (可以在此处找到示例)。或者,您可以尝试使用这种有据可查的方式从 Yahoo Finance 获取 CSV 数据

EDIT:

编辑:

There has been some discussion on the Yahoo developer forumsand 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.

缺少文档的原因是我们没有 Finance API。似乎有些人对他们用来提取财务数据的 API 进行了逆向工程,但他们这样做违反了我们的服务条款(不重新分发财务数据),因此我建议您避免使用这些 Web 服务。

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.

同时,您列出的 URL 可以使用YQL 控制台访问,尽管我不够精明,不知道如何使用它提取 URL 参数。

回答by FedeKrum



| ATTENTION !!! |

| 注意力 !!!|

| SERVICE SUSPENDED BY YAHOO, solution no longer valid. |

| 雅虎暂停服务,解决方案不再有效。|

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

从 Yahoo 获取您可以从 REST 查询解析的 JSON 或 XML。

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

您可以将任何货币兑换成任何货币,甚至可以使用 YQL(雅虎查询语言)获取查询的日期和时间。

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.

我认为这不会破坏任何服务条款,因为它是 100% 雅虎解决方案。

回答by Sergey Dirin

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

这可能会有所帮助:http: //finance.yahoo.com/d/quotes.csv?e=.csv&f=c4l1&s=EURUSD=X,GBPUSD = X它将返回 csv 文件:

"EUR",1.2972
"GBP",1.6034

Or if you need json: Yahoo csv parser

或者如果你需要 json: Yahoo csv parser

回答by Einacio

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.

我正在开发一个需要货币转换的应用程序,并且一直在使用开放汇率,因为我不会因为该应用程序正在测试而付款。但截至 2012 年 9 月,开放汇率将支付给非个人,所以我检查了他们正在使用雅虎财经网络服务(“不存在”的服务)并在此处查找有关它的文档,并且选择使用 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.

将 YQL 与 NT3RP 链接的 Yahoo Finance 表 (yahoo.finance.quotes) 一起使用,货币显示为符号 =“ISOCODE=X”,例如:“ARS=X”代表阿根廷比索,“AUD=X”代表澳元。"USD=X" 不存在,但它会是 1,因为其余的是对美元的汇率。

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

OP API 上的“价格”值位于表的“LastTradePriceOnly”字段中。对于我的应用程序,我使用了“询问”字段。

回答by zeFree

As NT3RP told us that:

正如 NT3RP 告诉我们的那样:

... 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...

...我们(雅虎!)没有财务 API。似乎有些人对他们用来提取财务数据的 API 进行了逆向工程,但他们违反了我们的服务条款......

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]

所以我只是想和你分享这个网站:
http: //josscrowcroft.github.com/open-exchange-rates/
[更新:网站已经转移到 - 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.]

没有访问费、没有速率限制、没有丑陋的 XML - 只是免费的、每小时更新的 JSON 格式的汇率
[更新:免费供个人使用,对您的企业来说很划算。]

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

我希望我有所帮助,这对您(和其他人)也有帮助。:)

回答by Liam Hogan

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

我已使用此 URL 获取多个货币市场报价。

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

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:

它们可以像这样在 PHP 中解析:

$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];
}