INTEGRATION

SDK Reference

The @sentinelguard/sdk npm package gives any TypeScript or JavaScript application instant access to SentinelGuard's real-time threat feed — no infrastructure required.

Installation

Install via your preferred package manager.

npmbash
npm install @sentinelguard/sdk
yarnbash
yarn add @sentinelguard/sdk
bunbash
bun add @sentinelguard/sdk

Quick Start

Create a client and start listening for live exploit alerts in seconds.

index.tstypescript
import SentinelClient from '@sentinelguard/sdk';

const client = new SentinelClient();

// Subscribe to real-time alerts for your protocol
const unsubscribe = client.subscribe(
  'YOUR_PROTOCOL_ADDRESS',
  (alert) => {
    console.log(`Alert fired: ${alert.rule_triggered} — severity ${alert.severity}`);
    console.log(`At risk: $${alert.estimated_at_risk_usd.toLocaleString()}`);
  }
);

// Later, clean up the WebSocket connection
unsubscribe();

SentinelClient

The main entry point. By default it connects to the hosted SentinelGuard API — pass a custom SentinelConfig to point at a self-hosted instance.

client.tstypescript
import SentinelClient, { SentinelConfig } from '@sentinelguard/sdk';

const config: SentinelConfig = {
  apiUrl: 'https://sentinel-guard-three.vercel.app', // optional, this is the default
  wsUrl:  'wss://sentinel-guard-three.vercel.app',   // optional
};

const client = new SentinelClient(config);
Config FieldTypeDescription
apiUrlstring?Base URL for REST endpoints. Defaults to the hosted API.
wsUrlstring?WebSocket base URL. Defaults to the hosted WebSocket server.

Methods

subscribe(protocolAddress, onAlert) → () => void

Opens a WebSocket connection to the live feed and calls onAlert each time an alert arrives for the given protocol address. Returns an unsubscribe function that closes the socket.

subscribe.tstypescript
const unsubscribe = client.subscribe(
  '9W95BjbZuXdwf6p7X3bHu3wnMb2R5y7A4K',
  (alert) => {
    if (alert.severity >= 80) {
      triggerEmergencyAlert(alert);
    }
  }
);

getAlerts(protocolAddress) → Promise<Alert[]>

Fetches historical alerts for a specific protocol address via the REST API.

getAlerts.tstypescript
const alerts = await client.getAlerts('9W95BjbZuXdwf6p7X3bHu3wnMb2R5y7A4K');
alerts.forEach((a) => console.log(a.rule_triggered, a.created_at));

getThreats() → Promise<Alert[]>

Returns the full public threat feed — all alerts across all protocols. No API key required.

getThreats.tstypescript
const threats = await client.getThreats();
console.log(`${threats.length} total threats detected`);

isPaused(protocolAddress) → Promise<boolean>

Checks whether a protocol is currently in a paused state.

isPaused.tstypescript
const paused = await client.isPaused('9W95BjbZuXdwf6p7X3bHu3wnMb2R5y7A4K');
if (paused) {
  console.log('Protocol is currently paused — withdrawals locked.');
}

Alert Type

All methods that return alerts use the Alert interface exported from the package.

types.tstypescript
import { Alert } from '@sentinelguard/sdk';

interface Alert {
  id: string;                      // Unique alert identifier
  protocol: string;                // Protocol public key
  rule_triggered: string;          // e.g. "FLASH_LOAN_DRAIN"
  severity: number;                // Score 0–99
  estimated_at_risk_usd: number;   // USD value at risk
  on_chain_tx: string | null;      // Transaction signature, if available
  slot: number;                    // Solana slot number
  created_at: string;              // ISO 8601 timestamp
}

The SDK ships full TypeScript typings. Both ESM (import) and CommonJS (require) are supported out of the box.

Was this page helpful?