錯誤代碼
| 錯誤代碼 | 錯誤內容 | 說明 |
|---|---|---|
| 401 | Unauthorized | 您使用的 API key 無法成功驗證,請至 金鑰申請頁 的行情 API 區重新新增 API Key 試試。 |
| 403 | Forbidden | 您目前使用的權限方案並不支援此功能,欲升級權限方案可參考 行情方案及價格頁。 |
| 404 | Resource Not Found | 查無資料:商品代碼無效或不存在,或查詢的日期為非交易日、早於資料起始日。請確認商品代碼與查詢區間。 |
| 429 | Rate limit exceeded | 您目前的呼叫次數已達上限,請稍後再試,欲升級權限方案可參考 行情方案及價格頁。 |
使用 SDK 時
Python SDK 遇到上述錯誤會拋出 FugleAPIError,可由 status_code 取得錯誤代碼;Node.js SDK 不會以 reject 回報,而是回傳含 statusCode 與 message 的物件。
- Python
- Node.js
from fugle_marketdata import RestClient, FugleAPIError
client = RestClient(api_key = 'YOUR_API_KEY')
stock = client.stock
try:
print(stock.intraday.quote(symbol='0000'))
except FugleAPIError as e:
print(e.status_code, e.message) # 404 Resource Not Found
const { RestClient } = require('@fugle/marketdata');
const client = new RestClient({ apiKey: 'YOUR_API_KEY' });
client.stock.intraday.quote({ symbol: '0000' })
.then((data) => {
if (data.statusCode) {
console.log(data.statusCode, data.message); // 404 Resource Not Found
return;
}
console.log(data);
});