Node.js SDK

@chainscreen/sdk is the official TypeScript/Node.js client for the ChainScreen API. It ships full type definitions, camelCase response objects, and built-in retry logic.

Installation

npm install @chainscreen/sdk

Quick start

import { Client } from '@chainscreen/sdk'

const client = new Client({ apiKey: 'sk_live_...' })

const result = await client.screen('0x4f47bc496083c727c5fbe3ce9cdf2b0f6496270c', 'ethereum')
console.log(result.level)   // "CRITICAL"
console.log(result.score)   // 100

if (result.isHighRisk) {
  throw new Error(`High-risk address: ${result.level}`)
}

Batch screening

const { results, summary } = await client.screenBatch([
  { address: '0x4f47bc496083c727c5fbe3ce9cdf2b0f6496270c', chain: 'ethereum' },
  { address: '0x0000000000000000000000000000000000000000', chain: 'ethereum' },
])

console.log(summary.critical)  // 1
for (const r of results) {
  console.log(r.address, r.level)
}

Error handling

import {
  AuthError, InvalidAddressError,
  QuotaExceededError, RateLimitError, ScreeningError,
} from '@chainscreen/sdk'

try {
  const result = await client.screen(address, chain)
} catch (err) {
  if (err instanceof InvalidAddressError) {
    console.error('Bad address:', err.message)
  } else if (err instanceof QuotaExceededError) {
    console.error('Monthly quota exhausted')
  } else if (err instanceof RateLimitError) {
    console.error(`Rate limited — retry after ${err.retryAfter}s`)
  } else if (err instanceof AuthError) {
    console.error('Invalid API key')
  } else if (err instanceof ScreeningError) {
    console.error(`API error (${err.statusCode}):`, err.message)
  }
}

Configuration

OptionDefaultDescription
apiKeyrequiredYour sk_live_ or sk_test_ key
baseUrlhttps://anchorapi.dev/api/v1Override for self-hosted deployments
timeout10000Request timeout in milliseconds

TypeScript types

import type { ScreeningResult, RiskLevel, BatchScreeningResult } from '@chainscreen/sdk'

function checkRisk(result: ScreeningResult): void {
  const level: RiskLevel = result.level  // fully typed
  if (level === 'CRITICAL' || level === 'HIGH') {
    // block the transaction
  }
}

Retry behaviour

The SDK retries on 429 (rate limit), 500, 502,503, and 504 with exponential backoff (up to 3 attempts). Quota-exceeded errors are not retried.

Disclaimer: ChainScreen provides sanctions data for informational purposes only. It does not constitute legal advice. Consult qualified legal counsel for compliance decisions.