공식 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"포지션 업데이트: {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("포지션 업데이트:", 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초). 장기 실행 작업에 대한 사용자 지정 시간 초과 설정 가능.
속도 제한 처리
속도 제한에 도달할 경우 지수 백오프 자동 적용. Retry-After 헤더를 존중합니다.
원하는 SDK 선택
선호하는 언어로 시작하세요. 전체 문서와 예제가 포함되어 있습니다.
API 참조 보기