檢視 Yahoo股市API 的原始碼
←
Yahoo股市API
跳至導覽
跳至搜尋
由於下列原因,您沒有權限進行編輯此頁面的動作:
您請求的操作只有這個群組的使用者能使用:
使用者
您可以檢視並複製此頁面的原始碼。
{{Nav|程式語言、邏輯學}} ==API 地址== <pre>https://query1.finance.yahoo.com/v8/finance/chart/<股票名>?metrics=<價格形式>[,<價格形式>]*&interval=<單位區間>&range=<索取期間></pre> ''註:[...]*表可重複0次以上'' ==參數== *股票名,格式如: ** 美國股票代號 ** 「臺灣股票代號」.TW,例0050.TW *價格形式,以下為舉例: ** Date 日期 ** High 最高價 ** Low 最低價 ** Open 開盤價 ** Close 收盤價 ** Volume 成交量 *單位區間:一筆資料的單位,格式為「數字+時間單位」,時間單位如: ** m:分 ** h:小時 ** d:日 ** wk:週 ** mo:月 *索取範圍: **資料蒐羅的時間範圍(比如近3月等等),格式如上。 **ytd:年初迄今 **max:最大值 ==案例== 用 curl 索取臺股臺積電(2330)的近3日資料,存到a.txt: <pre>curl "https://query1.finance.yahoo.com/v8/finance/chart/2330.TW?metrics=Date,High,Low,Open,Close,Volume&interval=1d&range=3d" > a.txt</pre> 輸出結果: <pre> {"chart":{"result":[{"meta":{"currency":"TWD","symbol":"2330.TW","exchangeName":"TAI","instrumentType":"EQUITY","firstTradeDate":946947600,"regularMarketTime":1688707805,"gmtoffset":28800,"timezone":"CST","exchangeTimezoneName":"Asia/Taipei","regularMarketPrice":565.0,"chartPreviousClose":582.0,"priceHint":2,"currentTradingPeriod":{"pre":{"timezone":"CST","start":1688691600,"end":1688691600,"gmtoffset":28800},"regular":{"timezone":"CST","start":1688691600,"end":1688707800,"gmtoffset":28800},"post":{"timezone":"CST","start":1688707800,"end":1688707800,"gmtoffset":28800}},"dataGranularity":"1d","range":"3d","validRanges":["1d","5d","1mo","3mo","6mo","1y","2y","5y","10y","ytd","max"]},"timestamp":[1688518800,1688605200,1688691600],"indicators":{"quote":[{"low":[579.0,565.0,563.0],"close":[582.0,565.0,565.0],"open":[589.0,573.0,565.0],"high":[589.0,574.0,572.0],"volume":[14913592,28564891,18796190]}],"adjclose":[{"adjclose":[582.0,565.0,565.0]}]}}],"error":null}} </pre> 我們需要排整齊,以利閱讀,使用 js-beautify排齊,輸出到a_tidy.txt: <pre>js-beautify a.txt > a_tidy.txt</pre> 結果: <pre> { "chart": { "result": [{ "meta": { "currency": "TWD", "symbol": "2330.TW", "exchangeName": "TAI", "instrumentType": "EQUITY", "firstTradeDate": 946947600, "regularMarketTime": 1688707805, "gmtoffset": 28800, "timezone": "CST", "exchangeTimezoneName": "Asia/Taipei", "regularMarketPrice": 565.0, "chartPreviousClose": 582.0, "priceHint": 2, "currentTradingPeriod": { "pre": { "timezone": "CST", "start": 1688691600, "end": 1688691600, "gmtoffset": 28800 }, "regular": { "timezone": "CST", "start": 1688691600, "end": 1688707800, "gmtoffset": 28800 }, "post": { "timezone": "CST", "start": 1688707800, "end": 1688707800, "gmtoffset": 28800 } }, "dataGranularity": "1d", "range": "3d", "validRanges": ["1d", "5d", "1mo", "3mo", "6mo", "1y", "2y", "5y", "10y", "ytd", "max"] }, "timestamp": [1688518800, 1688605200, 1688691600], "indicators": { "quote": [{ "low": [579.0, 565.0, 563.0], "close": [582.0, 565.0, 565.0], "open": [589.0, 573.0, 565.0], "high": [589.0, 574.0, 572.0], "volume": [14913592, 28564891, 18796190] }], "adjclose": [{ "adjclose": [582.0, 565.0, 565.0] }] } }], "error": null } }</pre> ==參考== * [https://cryptocointracker.com/yahoo-finance/yahoo-finance-api Yahoo Finance API Guide & Examples] * [https://stackoverflow.com/questions/18985/how-can-i-beautify-javascript-code-using-command-line StackOverflow - How can I beautify JavaScript code using Command Line?] * [https://ithelp.ithome.com.tw/articles/10236119 ITHome - 【Day5】取得資訊-Python #2:抓股票資料 ] [[分類:資訊]]
此頁面使用了以下模板:
模板:Nav
(
檢視原始碼
)
返回到「
Yahoo股市API
」。
導覽選單
個人工具
登入
命名空間
頁面
討論
變體
視圖
閱讀
檢視原始碼
檢視歷史
更多
搜尋
導覽
首頁
愛爾蘭語辭典
近期變更
隨機頁面
有關 MediaWiki 的說明
相關網站
總首頁
Blog
舊 blog
現用 blog 備份
工具
連結至此的頁面
相關變更
特殊頁面
頁面資訊