Librerie SDK ufficiali
Librerie client ufficiali per Python, JavaScript, Go e Rust. Semplifica l'integrazione API con client tipizzati, logica di riprova automatica e supporto WebSocket.
SDK Python
Pacchetto: smartmoney-api
Installazione: pip install smartmoney-api
Repository: github.com/smartmoneyapi/python-client
from smartmoney import SmartMoneyAPI
# Inizializza il client
client = SmartMoneyAPI(api_key="sk_live_abc123xyz789")
# Ottieni le posizioni delle balene
whales = client.whale_positions(symbol="BTCUSDT", limit=50)
for position in whales:
print(f"{position.wallet_address}: {position.position_size} BTC @ {position.entry_price}")
# Ottieni i tassi di funding
funding = client.funding_rates(symbol="BTCUSDT", interval="4h", limit=24)
# Stream di aggiornamenti in tempo reale
with client.stream_whale_positions(["BTCUSDT", "ETHUSDT"]) as stream:
for update in stream:
print(f"Aggiornamento posizione: {update}")
Funzionalità
- Supporto async/await (asyncio, aiohttp)
- Riprova automatica con backoff esponenziale
- Streaming WebSocket con riconnessione automatica
- Type hints e autocompletamento IDE
- Logging e debug delle richieste
SDK JavaScript
Pacchetto: smartmoney-api
Installazione: npm install smartmoney-api
Repository: github.com/smartmoneyapi/js-client
import { SmartMoneyAPI } from "smartmoney-api";
const client = new SmartMoneyAPI({
apiKey: "sk_live_abc123xyz789"
});
// Ottieni le posizioni delle balene
const whales = await client.whalePositions({
symbol: "BTCUSDT",
limit: 50
});
whales.positions.forEach(pos => {
console.log(`${pos.wallet_address}: ${pos.position_size} BTC`);
});
// Stream di aggiornamenti in tempo reale
const stream = client.streamWhalePositions(["BTCUSDT", "ETHUSDT"]);
stream.on("data", (update) => {
console.log("Aggiornamento posizione:", update);
});
stream.on("error", (err) => {
console.error("Errore stream:", err);
});
SDK Go
Modulo: github.com/smartmoneyapi/go-client
Installazione: go get github.com/smartmoneyapi/go-client
package main
import (
"fmt"
"github.com/smartmoneyapi/go-client"
)
func main() {
// Crea il client
client := smartmoney.NewClient("sk_live_abc123xyz789")
// Ottieni le posizioni delle balene
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)
}
}
SDK Rust
Crate: smartmoney-api
Installazione: cargo add smartmoney-api
use smartmoney_api::Client;
#[tokio::main]
async fn main() -> Result<(), Box> {
let client = Client::new("sk_live_abc123xyz789");
// Ottieni le posizioni delle balene
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(())
}
Modelli comuni
Gestione degli errori
Tutti gli SDK forniscono tipi di errore dettagliati con logica di riprova automatica. Gli errori includono codice di stato, codice di errore e messaggio leggibile.
Timeout delle richieste
Timeout delle richieste configurabili (predefinito 30s). Imposta timeout personalizzati per operazioni lunghe.
Gestione dei limiti di frequenza
Backoff esponenziale automatico in caso di limiti di frequenza. Rispetta l'header Retry-After.
Scegli il tuo SDK
Inizia con il linguaggio che preferisci. Documentazione completa ed esempi inclusi.
Vedi riferimento API