公式SDKライブラリ
Python、JavaScript、Go、Rust用の公式クライアントライブラリ。型付きクライアント、自動リトライロジック、WebSocketサポートによりAPI統合を簡素化します。
Python SDK
パッケージ: smartmoney-api
インストール: pip install smartmoney-api
リポジトリ: github.com/smartmoneyapi/python-client
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"Position update: {update}")
機能
- Async/awaitサポート (asyncio, aiohttp)
- 指数バックオフによる自動リトライ
- 自動再接続付きWebSocketストリーミング
- 型ヒントとIDEオートコンプリート
- リクエストロギングとデバッグ
JavaScript SDK
パッケージ: smartmoney-api
インストール: npm install smartmoney-api
リポジトリ: github.com/smartmoneyapi/js-client
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("Position update:", update);
});
stream.on("error", (err) => {
console.error("Stream error:", err);
});
Go SDK
モジュール: github.com/smartmoneyapi/go-client
インストール: go get github.com/smartmoneyapi/go-client
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
クレート: smartmoney-api
インストール: cargo add smartmoney-api
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ヘッダーを尊重します。