官方SDK函式庫

提供Python、JavaScript、Go與Rust的官方客戶端函式庫。透過類型化客戶端、自動重試邏輯與WebSocket支援,簡化API整合流程。

Python SDK

套件名稱: smartmoney-api

安裝指令: pip install smartmoney-api

程式碼庫: github.com/smartmoneyapi/python-client

Python
from smartmoney import SmartMoneyAPI # 初始化客戶端 client = SmartMoneyAPI(api_key="sk_live_abc123xyz789") # 獲取巨鯨持倉 whales = client.whale_positions(symbol="BTCUSDT", limit=50) for position in whales: print(f"{position.wallet_address}: {position.position_size} BTC @ {position.entry_price}") # 獲取資金費率 funding = client.funding_rates(symbol="BTCUSDT", interval="4h", limit=24) # 串流即時更新 with client.stream_whale_positions(["BTCUSDT", "ETHUSDT"]) as stream: for update in stream: print(f"持倉更新: {update}")

功能特色

  • 非同步/等待支援 (asyncio, aiohttp)
  • 指數退避自動重試機制
  • 自動重連的WebSocket串流
  • 型別提示與IDE自動補全
  • 請求記錄與除錯功能

JavaScript SDK

套件名稱: smartmoney-api

安裝指令: npm install smartmoney-api

程式碼庫: github.com/smartmoneyapi/js-client

JavaScript
import { SmartMoneyAPI } from "smartmoney-api"; const client = new SmartMoneyAPI({ apiKey: "sk_live_abc123xyz789" }); // 獲取巨鯨持倉 const whales = await client.whalePositions({ symbol: "BTCUSDT", limit: 50 }); whales.positions.forEach(pos => { console.log(`${pos.wallet_address}: ${pos.position_size} BTC`); }); // 串流即時更新 const stream = client.streamWhalePositions(["BTCUSDT", "ETHUSDT"]); stream.on("data", (update) => { console.log("持倉更新:", update); }); stream.on("error", (err) => { console.error("串流錯誤:", err); });

Go SDK

模組: github.com/smartmoneyapi/go-client

安裝: go get github.com/smartmoneyapi/go-client

Go
package main import ( "fmt" "github.com/smartmoneyapi/go-client" ) func main() { // 創建客戶端 client := smartmoney.NewClient("sk_live_abc123xyz789") // 獲取巨鯨持倉 positions, err := client.WhalePositions(ctx, &smartmoney.WhalePositionsFilter{ Symbol: "BTCUSDT", Limit: 50, }) if err != nil { panic(err) } for _, pos := range positions { fmt.Printf("%s: %.2f BTC\n", pos.WalletAddress, pos.PositionSize) } }

Rust SDK

Crate: smartmoney-api

安裝: cargo add smartmoney-api

Rust
use smartmoney_api::Client; #[tokio::main] async fn main() -> Result<(), Box> { let client = Client::new("sk_live_abc123xyz789"); // 獲取巨鯨持倉 let positions = client .whale_positions() .symbol("BTCUSDT") .limit(50) .send() .await?; for position in positions.iter() { println!( "{}: {} BTC @ {}", position.wallet_address, position.position_size, position.entry_price ); } Ok(()) }

常見模式

錯誤處理

所有SDK均提供豐富的錯誤類型與自動重試邏輯。錯誤包含狀態碼、錯誤代碼及人類可讀訊息。

請求超時

可配置請求超時時間(預設30秒)。為長時間運行的操作設置自定義超時。

速率限制處理

觸發速率限制時自動指數退避。遵循Retry-After標頭。

選擇您的SDK

從您熟悉的語言開始。包含完整文檔與範例。

查看API參考文檔
免費開始 — 每日100次呼叫,無需綁卡

透過單一API獲取3大交易所的即時巨鯨資金流動、資金費率、未平倉合約及鏈上數據。免費層級無需信用卡,隨時可升級。

免費開始 →
試用即時API控制台 → (無需帳戶)
30秒內取得您的API金鑰

準備開始開發?立即獲取免費API金鑰(每日100次呼叫,無需綁卡),開始拉取即時巨鯨、資金費率及鏈上數據。

取得您的API金鑰 →