Yahoo 使用了 Reactjs 前端,这意味着如果您分析从客户端到后端的请求标头,您可以获得它们用于填充客户端存储的实际 JSON。
主机:
如果您打算使用代理或持久连接,请使用query2.finance.yahoo.com。但出于本文的目的,用于示例 URL 的主机并不意味着暗示它正在使用的路径。
基本数据
(将您的符号替换为:AAPL)
/v10/finance/quoteSummary/AAPL?modules=
?modules= 查询的输入:
[
'assetProfile',
'summaryProfile',
'summaryDetail',
'esgScores',
'price',
'incomeStatementHistory',
'incomeStatementHistoryQuarterly',
'balanceSheetHistory',
'balanceSheetHistoryQuarterly',
'cashflowStatementHistory',
'cashflowStatementHistoryQuarterly',
'defaultKeyStatistics',
'financialData',
'calendarEvents',
'secFilings',
'recommendationTrend',
'upgradeDowngradeHistory',
'institutionOwnership',
'fundOwnership',
'majorDirectHolders',
'majorHoldersBreakdown',
'insiderTransactions',
'insiderHolders',
'netSharePurchaseActivity',
'earnings',
'earningsHistory',
'earningsTrend',
'industryTrend',
'indexTrend',
'sectorTrend']
示例 URL: 查询所有上述模块
https://query2.finance.yahoo.com/v10/finance/quoteSummary/AAPL?modules=assetProfile%2CsummaryProfile%2CsummaryDetail%2CesgScores%2Cprice%2CincomeStatementHistory%2CincomeStatementHistoryQuarterly%2CbalanceSheetHistory%2CbalanceSheetHistoryQuarterly%2CcashflowStatementHistory%2CcashflowStatementHistoryQuarterly%2CdefaultKeyStatistics%2CfinancialData%2CcalendarEvents%2CsecFilings%2CrecommendationTrend%2CupgradeDowngradeHistory%2CinstitutionOwnership%2CfundOwnership%2CmajorDirectHolders%2CmajorHoldersBreakdown%2CinsiderTransactions%2CinsiderHolders%2CnetSharePurchaseActivity%2Cearnings%2CearningsHistory%2CearningsTrend%2CindustryTrend%2CindexTrend%2CsectorTrend
%2C 是, 的十六进制表示,需要插入到您请求的每个模块之间。 details about the hex encoding bit(如果你在乎的话)
期权合约
-
/v7/finance/options/AAPL(当前到期)
-
/v7/finance/options/AAPL?date=1679011200(2023年3月17日到期)
示例网址:
-
https://query2.finance.yahoo.com/v7/finance/options/AAPL(当前到期)
-
https://query2.finance.yahoo.com/v7/finance/options/AAPL?date=1679011200(2023年第17场比赛到期)
任何表示为 UNIX 时间戳的有效未来到期时间都可以在 ?date= 查询中使用。如果您查询当前过期时间,JSON 响应将包含可在 ?date= 查询中使用的所有有效过期时间的列表。 (here is a post explaining converting human-readable dates to UNIX timestamp in Python)
价格
/v8/finance/chart/AAPL?symbol=AAPL&period1=0&period2=9999999999&interval=3mo
&interval= 的可能输入: 1m, 5m, 15m, 30m, 90m, 1h, 1d, 5d, 1wk, 1mo, 3mo
m (分钟) 间隔限制为 30 天,period1 和 period2 每个请求最多跨越 7 天。超过这些限制中的任何一个都将导致错误并且不会舍入
h(小时) 间隔限制为 730 天,没有跨度限制。超过此值将导致错误并且不会舍入
period1=:您希望开始的日期的 UNIX 时间戳表示。
d(day)、wk(week)、mo(month) 间隔值小于初始交易日将向上取整至初始交易日。
period2=:您希望结束的日期的 UNIX 时间戳表示。
对于所有时间间隔:大于最后交易日期的值将向下舍入到可用的最新时间戳。
添加上市前和上市后数据
&includePrePost=true
添加股息和分割
&events=div%7Csplit
%7C 是 | 的十六进制数。 , 可以工作,但雅虎内部使用管道
示例网址:
https://query1.finance.yahoo.com/v8/finance/chart/AAPL?symbol=AAPL&period1=0&period2=9999999999&interval=1d&includePrePost=true&events=div%7Csplit
上述请求将返回股票代码 AAPL 每隔 1 天的所有价格数据,包括上市前和上市后数据以及股息和拆分。
注意: period1= 和 period2= 的价格示例 URL 中使用的值是为了演示每个输入的相应舍入行为。`