📦

SDK Downloads

Official SDKs for JavaScript, Python, Rust, and Go. Built with type safety, automatic retries, and comprehensive documentation.


🟨

JavaScript / TypeScript

v0.2.0

Full-featured SDK for Node.js and browser environments with TypeScript support

Installation
$ npm install @defiguardian/sdk# or: yarn add @defiguardian/sdk# or: pnpm add @defiguardian/sdk
Full TypeScript support with auto-complete34 methods covering all v1 API endpointsAutomatic retry with exponential backoffWebhook signature verification helpersWorks in Node.js and edge runtimes
Quick Start
import { DeFiGuardian } from '@defiguardian/sdk';

const client = new DeFiGuardian({
  apiKey: process.env.DEFI_GUARDIAN_API_KEY!,
});

// Check API status
const status = await client.getStatus();
console.log('API version:', status.version);

// Get all positions for your wallets
const positions = await client.listPositions();
console.log(`Found ${positions.length} positions`);

// Run a Monte Carlo simulation
const mc = await client.runMonteCarlo({
  positionId: 'pos_abc123',
  iterations: 1000,
  horizonDays: 30,
});
console.log('Liquidation probability:', mc.liquidationProbability);

// Get whale cluster intelligence
const whales = await client.getWhaleClusters();
console.log('Active clusters:', whales.length);
🐍

Python

v0.3.0

Async-first Python SDK with aiohttp, Pydantic models, and automatic retries

Installation
$ pip install defiguardian# or: poetry add defiguardian
Python 3.8+ with full type hintsAsync/await with aiohttpPydantic response modelsAutomatic retry with backoffWebhook signature verification
Quick Start
import asyncio
from defiguardian import DeFiGuardian

async def main():
    async with DeFiGuardian(api_key="dg_your_key") as client:
        # Get all positions
        positions = await client.list_positions()
        print(f"Found {len(positions)} positions")

        # Scan a wallet across all protocols
        scan = await client.scan_positions("0xYourWallet")
        for pos in scan:
            if pos.health_factor and pos.health_factor < 1.5:
                print(f"Warning: {pos.protocol} position at risk!")

        # Get whale intelligence
        whales = await client.get_whale_clusters()
        print(f"Tracking {len(whales)} whale clusters")

        # Run Monte Carlo simulation
        mc = await client.run_monte_carlo("pos_abc123", iterations=1000)
        print(f"Liquidation probability: {mc.liquidation_probability}")

asyncio.run(main())
🦀

Rust

v0.2.0

High-performance async SDK with reqwest, serde models, and constant-time webhook verification

Installation
$ cargo add defiguardian
Async with tokio + reqwestSerde deserialization with typed modelsConstant-time webhook signature verificationConnection poolingCompile-time type safety
Quick Start
use defiguardian::Client;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Client::new(
        std::env::var("DEFI_GUARDIAN_API_KEY")?
    );

    // Check API status
    let status = client.get_status().await?;
    println!("API version: {}", status.version);

    // Get all positions
    let positions = client.list_positions().await?;
    println!("Found {} positions", positions.len());

    // Get market health (free tier)
    let health = client.get_market_health().await?;
    println!("DeFi risk index: {}", health.risk_index);

    // Whale intelligence
    let whales = client.get_whale_clusters().await?;
    for cluster in &whales {
        println!("Cluster: {} wallets", cluster.wallet_count);
    }

    Ok(())
}
🐹

Go

v1.0.0

Idiomatic Go SDK with context support, functional options, and automatic retries with jitter

Installation
$ go get github.com/defiguardian/sdk-go
Context-aware API callsFunctional options patternAutomatic retry with jitterConcurrent-safe clientMinimal dependencies (stdlib only)
Quick Start
package main

import (
    "context"
    "fmt"
    "log"
    "os"

    defiguardian "github.com/defiguardian/sdk-go"
)

func main() {
    client := defiguardian.NewClient(os.Getenv("DEFI_GUARDIAN_API_KEY"))
    ctx := context.Background()

    // Check API status
    status, err := client.GetStatus(ctx)
    if err != nil {
        log.Fatal(err)
    }
    fmt.Println("API version:", status.Version)

    // Get all positions
    positions, err := client.ListPositions(ctx)
    if err != nil {
        log.Fatal(err)
    }
    fmt.Printf("Found %d positions\n", len(positions))

    // Get whale clusters
    whales, err := client.GetWhaleClusters(ctx)
    if err != nil {
        log.Fatal(err)
    }
    fmt.Printf("Tracking %d whale clusters\n", len(whales))
}

Direct REST API

Don't see your language? Use our REST API directly. All SDKs are just wrappers around the same API.

cURL Example
curl -X GET "https://app.defiguardian.fi/api/v1/positions" \
  -H "x-api-key: dg_YOUR_API_KEY_HERE" \
  -H "Content-Type: application/json"
📖 View Full API Documentation

Need Help?

Having trouble with our SDKs? We're here to help!