ไลบรารี SDK อย่างเป็นทางการ
ไลบรารีไคลเอนต์อย่างเป็นทางการสำหรับ Python, JavaScript, Go และ Rust ทำให้การเชื่อมต่อ API ง่ายขึ้นด้วยไคลเอนต์แบบมีประเภท, ตรรกะการลองใหม่อัตโนมัติ และการสนับสนุน WebSocket
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"อัพเดทตำแหน่ง: {update}")
คุณสมบัติ
- รองรับ Async/await (asyncio, aiohttp)
- ลองใหม่อัตโนมัติด้วย exponential backoff
- สตรีมผ่าน WebSocket พร้อมเชื่อมต่อใหม่อัตโนมัติ
- type hints และ autocomplete ใน 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("อัพเดทตำแหน่ง:", update);
});
stream.on("error", (err) => {
console.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 วินาที) ตั้งเวลารอสำหรับการดำเนินการที่ใช้เวลานาน
การจัดการจำกัดอัตรา
ใช้ exponential backoff อัตโนมัติเมื่อถึงจำกัดอัตรา เคารพหัวข้อ Retry-After
เลือก SDK ของคุณ
เริ่มต้นด้วยภาษาที่คุณเลือก มีเอกสารประกอบและตัวอย่างครบถ้วน
ดูเอกสารอ้างอิง API