简体   繁体   English

雅虎金融网络服务消失了吗? API 变了吗? 暂时下线?

[英]Has Yahoo finance web service disappeared? API changed? Down temporarily?

For quite some time I've been using the following REST API to query Yahoo finance for current prices.很长一段时间以来,我一直在使用以下 REST API 来查询雅虎财经的当前价格。 It is documented in several Stack Overflow posts, eg Yahoo finance webservice and elsewhere in .它记录在多个 Stack Overflow 帖子中,例如Yahoo Finance webservice其他地方。

http://finance.yahoo.com/webservice/v1/symbols/$SYMBOLS/quote?format=json

where $SYMBOLS is a comma-delimited list of stock or index symbols.其中 $SYMBOLS 是以逗号分隔的股票或指数符号列表。

Yesterday the query stopped working, returning only a "Moved Temporarily. Redirecting to ..." message.昨天查询停止工作,只返回“临时移动。重定向到...”消息。

Is this web service now closed?这个网络服务现在关闭了吗? Has it been replaced by YQL or another API?是否已被 YQL 或其他 API 取代? Queries for a table of historic prices to "ichart" still work.查询“ichart”的历史价格表仍然有效。 Eg,例如,

http://ichart.finance.yahoo.com/table.csv?d=2&e=3&f=2016&g=d&a=0&b=1&c=2011&ignore=.csv&s=$SYMBOL

Thanks.谢谢。

I was facing a similar issue from last 2-3 days.在过去的 2-3 天里,我遇到了类似的问题。 The url works on the smartphone, where on the desktop it gives "Not a valid parameter" error and HTTP Code 406.该网址适用于智能手机,在桌面上它会给出“不是有效参数”错误和 HTTP 代码 406。

This can be resolved by adding user agent as "Mozilla/5.0 (Linux; Android 6.0.1; MotoG3 Build/MPI24.107-55) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.81 Mobile Safari/537.36" while invoking the get request.这可以通过将用户代理添加为“Mozilla/5.0 (Linux; Android 6.0.1; MotoG3 Build/MPI24.107-55) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.81 Mobile Safari/537.36”来解决,而调用获取请求。

For example, if you are downloading from curl in php use as follows:例如,如果您在 php 中从 curl 下载,请按如下方式使用:

curl_setopt($session,CURLOPT_USERAGENT,"Mozilla/5.0 (Linux; Android 6.0.1; MotoG3 Build/MPI24.107-55) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.81 Mobile Safari/537.36");

I hope this will resolve the issue.我希望这能解决这个问题。

Yes, it does seem like Yahoo!是的,它看起来确实像 Yahoo! has discontinued the (private, mostly-undocumented) Yahoo Finance API that many have been relying on for years for currency data.已经停止使用(私有的,大部分未记录的)Yahoo Finance API,许多人多年来一直依赖该 API 来获取货币数据。 We received some notifications about it over the past 24 hours.我们在过去 24 小时内收到了一些关于它的通知。 (edit: All responses seem to be returning "Not a valid parameter" . I suppose there's a chance they may switch it back on, but they don't officially support that API anywhere as far as I can tell.) (编辑:所有响应似乎都返回"Not a valid parameter" 。我想他们可能会重新打开它,但据我所知,他们在任何地方都没有正式支持该 API。)

I created Open Exchange Rates about five years ago, and our exchange rate API now supports a community of tens of thousands of developers - and their tens of millions of users - with accurate, up-to-date information.大约五年前,我创建了Open Exchange Rates ,我们的汇率 API 现在支持由数以万计的开发人员及其数以千万计的用户组成的社区,提供准确、最新的信息。

Please feel welcome to check out our Forever Free service at https://openexchangerates.org .欢迎访问https://openexchangerates.org查看我们的永久免费服务。

Our API is in a simple, original JSON format, which has actually caught on as a standard method for displaying rates because it's so simple to work with (unlike the Yahoo API, which required you to parse the obscure nested objects to pull out the basic info you needed...)我们的 API 采用简单的原始 JSON 格式,它实际上已成为显示费率的标准方法,因为它使用起来非常简单(不像 Yahoo API,它需要您解析晦涩的嵌套对象以提取基本的您需要的信息...)

If you need assistance porting from the deprecated Yahoo!如果您需要帮助从已弃用的 Yahoo! 移植API, we'll be happy to assist via email. API,我们很乐意通过电子邮件提供帮助。

(I am the founder of Open Exchange Rates.) (我是 Open Exchange Rates 的创始人。)

Since the service is down, I use the following URL to query Yahoo data (for ACA.PA):由于服务已关闭,我使用以下 URL 来查询 Yahoo 数据(针对 ACA.PA):

Link 关联

The JSON result is different but I found the informations that interests me. JSON 结果不同,但我找到了我感兴趣的信息。

For more information , visit the page https://developer.yahoo.com/yql/欲了解更多信息,请访问页面https://developer.yahoo.com/yql/

I had the same issue.我遇到过同样的问题。 Here is the API URL to pull stock from YAHOO.这是从 YAHOO 中提取库存的 API URL。 Hope this helps.希望这可以帮助。

https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.quotes%20where%20symbol%20in%20(%22YHOO%22)&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=

Check out this excellent API Wrapper, available on NuGet: https://github.com/salmonthinlion/YahooFinanceApi查看 NuGet 上提供的这个出色的 API 包装器: https ://github.com/salmonthinlion/YahooFinanceApi

Get stock quotes获取股票报价

var quotes = await Yahoo.Symbol("AAPL", "GOOG").Tag(Tag.LastTradePriceOnly, Tag,ChangeAndPercentChange, Tag.DaysLow, Tag.DaysHigh).GetAsync();
var aapl = quotes["AAPL"];
var price = aapl[Tag.LastTradePriceOnly];

Get historical data for a stock获取股票的历史数据

// You should be able to query data from various markets including US, HK, TW
var history = await Yahoo.GetHistoricalAsync("AAPL", new DateTime(2016, 1, 1), new DateTime(2016, 7, 1), Period.Daily);
foreach (var candle in history)
{
    Console.WriteLine($"DateTime: {candle.DateTime}, Open: {candle.Open}, High: {candle.High}, Low: {candle.Low}, Close: {candle.Close}, Volume: {candle.Volume}, AdjustedClose: {candle.AdjustedClose}");
}

Get dividend history for a stock获取股票的股息历史

// You should be able to query data from various markets including US, HK, TW
var dividendHistory = await Yahoo.GetHistoricalDividendsAsync("AAPL", new DateTime(2016, 1, 1), new DateTime(2016, 7, 1));
foreach (var candle in dividendHistory)
{
    Console.WriteLine($"DateTime: {candle.DateTime}, Dividend: {candle.Dividend}");
}

I am the author of ValueViz on github .我是github上 ValueViz 的作者。

Daily prices每日价格

You need to be familiar with RESTFUL services.您需要熟悉 RESTFUL 服务。

https://quantprice.herokuapp.com/api/v1.1/scoop/day?tickers=MSFT&date=2017-06-09 https://quantprice.herokuapp.com/api/v1.1/scoop/day?tickers=MSFT&date=2017-06-09

Historical prices历史价格

You have to provide a date range :您必须提供日期范围:

https://quantprice.herokuapp.com/api/v1.1/scoop/period?tickers=MSFT&begin=2012-02-19&end=2012-02-20 https://quantprice.herokuapp.com/api/v1.1/scoop/period?tickers=MSFT&begin=2012-02-19&end=2012-02-20

If you don't provide begin or end it will use the earliest or current date:如果您不提供开始或结束,它将使用最早或当前日期:

https://quantprice.herokuapp.com/api/v1.1/scoop/period?tickers=MSFT&begin=2012-02-19 https://quantprice.herokuapp.com/api/v1.1/scoop/period?tickers=MSFT&begin=2012-02-19

Multiple tickers多个代码

You can just comma separate tickers:您可以用逗号分隔代码:

https://quantprice.herokuapp.com/api/v1.1/scoop/period?tickers=IBM,MSFT&begin=2012-02-19 https://quantprice.herokuapp.com/api/v1.1/scoop/period?tickers=IBM,MSFT&begin=2012-02-19

Rate limit速率限制

All requests are rate limited to 10 requests per hour.所有请求的速率限制为每小时 10 个请求。 If you want to register for a full access API send me DM on twitter.如果您想注册一个完全访问 API,请在 Twitter 上给我发送 DM。 You will receive an API key to add to the URL.您将收到要添加到 URL 的 API 密钥。

We are setting up a paypal account for paid subscription without rates.我们正在为无费率的付费订阅设置一个贝宝帐户。

List of tickers available可用代码列表

https://github.com/robomotic/valueviz/blob/master/scoop_tickers.csv https://github.com/robomotic/valueviz/blob/master/scoop_tickers.csv

I am working also to provide fundamental data and company data from EDGAR.我也在努力提供来自 EDGAR 的基本数据和公司数据。 Cheers.干杯。

It is redirecting to the same page, but adding the parameter "bypass=true", which gives an error.它正在重定向到同一页面,但添加了参数“bypass=true”,这会产生错误。

EDIT: The answer given by https://stackoverflow.com/users/6593038/hemant-prasad is working for me.编辑: https ://stackoverflow.com/users/6593038/hemant-prasad 给出的答案对我有用。 When changing the user agent to a mobile device, the API works fine, and doesn't redirect so far.将用户代理更改为移动设备时,API 工作正常,到目前为止还没有重定向。

This is the code I'm using in Java (it's for the XML version, but it can be use for JSON as well):这是我在 Java 中使用的代码(它用于 XML 版本,但也可以用于 JSON):

URL url = new URL ("https://finance.yahoo.com/webservice/v1/symbols/" + stocks + "/quote");
HttpURLConnection urlc = (HttpURLConnection) url.openConnection ();
urlc.setRequestProperty ("User-Agent", "Mozilla/5.0 (Linux; Android 6.0; MotoE2(4G-LTE) Build/MPI24.65-39) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.81 Mobile Safari/537.36");
Document xml = DocumentBuilderFactory.newInstance ().newDocumentBuilder ().parse (urlc.getInputStream ());

I found a way to use the csv API.我找到了一种使用 csv API 的方法。

link 关联

where you need to write the symbol, the parameters and columns.您需要在其中编写符号、参数和列。

Use this website to find the parameters needed: http://www.jarloo.com/yahoo_finance/使用此网站查找所需的参数: http ://www.jarloo.com/yahoo_finance/

example:例子:

If you need to know the symbol's volume replace the string sl1d1t1c1ohgv with v如果您需要知道符号的体积,请将字符串sl1d1t1c1ohgv替换为v

and replace the columns symbol%2Cprice%2Cdate%2Ctime%2Cchange%2Ccol1%2Chigh%2Clow%2Cvolume with volume并将列symbol%2Cprice%2Cdate%2Ctime%2Cchange%2Ccol1%2Chigh%2Clow%2Cvolumevolume

The only issue is that data is kinda random and not real time like it was in webservice API唯一的问题是数据有点随机,不像 Web 服务 API 那样是实时的

The Python Yahoo Finance API seems to have a problem too. Python Yahoo Finance API似乎也有问题。 If you use it to look up, for example, Amazon stock prices it just shows the same two values over and over.例如,如果您使用它来查找亚马逊股票价格,它只会一遍又一遍地显示相同的两个值。

from yahoo_finance import Share import time f = open('/tmp/amazon/amzn.csv', 'w') while True:
    amzn=Share("AMZN")
    s = amzn.get_price() + "," + amzn.get_trade_datetime() + '\n'
    print (s)
    f.write (s)
    f.flush()
    time.sleep(5)
    del amzn

I think this could help, I have created a web service for all Nasdaq/Nyse tickers, you can test this REST API and check if it suits your need.我认为这会有所帮助,我已经为所有纳斯达克/纽约证券交易所代码创建了一个 Web 服务,您可以测试这个 REST API 并检查它是否适合您的需要。 Also you can visit this website below for the use cases example.您也可以访问下面的此网站以获取用例示例。

Rest API endpoint: https://rapidapi.com/moneygoddess888/api/nasdaq-stocks-dividend-history-live休息 API 端点: https ://rapidapi.com/moneygoddess888/api/nasdaq-stocks-dividend-history-live

Use Case Example: https://nasdaq-dividend-search-api.herokuapp.com用例示例: https ://nasdaq-dividend-search-api.herokuapp.com

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM