Skip to main content
The @sly_ai/scanner package is the recommended way to integrate the scanner from any TypeScript or JavaScript runtime. It mirrors every public API endpoint with typed methods, handles transient errors automatically, and tracks remaining credits without an extra round-trip.

Install

Requires Node.js 18+ (uses native fetch). Works in browsers, Edge runtimes, and Bun. Zero runtime dependencies.

Quickstart

That’s the whole integration for most use cases.

Configuration

environment is inferred from the key prefix: psk_live_*'live', psk_test_*'test'. Pass it explicitly when using JWT auth.

Typed errors

Catch the specific subclass for actionable handling:
Every error has .status, .requestId, and .body — pull them straight into your support tickets and observability stack. The retry policy is conservative on purpose — we never burn a partner’s quota on a deterministic 4xx.

Auto-tracked balance

Every billed response includes an X-Credits-Remaining header. The SDK reads it and updates scanner.balance so you don’t need a follow-up /credits/balance call:

Single scans

result is a fully-typed MerchantScan — IntelliSense gives you every score, protocol result, and metadata field. The response includes a request_id (UUID) that ties the scan to its credit-ledger row and is echoed in the X-Request-ID response header. Use it for audit + support correlation.

Bounded-concurrency stream — scanMany

For a moderate number of domains (~10–500) where you want results as they complete:
Per-domain errors are caught and yielded — one failure doesn’t abort the run. Default concurrency is 5; rate limits suggest staying under 10 unless you’ve negotiated a higher cap.

Server-side batches — createBatch + waitForBatch

For large lists (500+) or when you want the server to manage the queue:
Batch costs 0.5 credit per target, charged at enqueue time. Cancel before completion (scanner.cancelBatch(id)) to refund the unprocessed credits.

CSV upload

The CSV must include a domain column. Optional columns: merchant_name, merchant_category, country_code, region.

Credits, ledger, and activity

expandScan: true is the audit-trail unlock — every consume row comes back with the linked scan summary, so you can answer “what did I get for this charge?” without a second call.

Key management

Live keys can only be created by users with owner/admin roles when authenticated via JWT. API-key callers have no role gate.

Trace propagation

Pass a requestId per call so your distributed-trace IDs flow into our request logs:
The id rides as X-Request-ID and is echoed in error objects (err.requestId). Cross-references in support tickets cost zero engineering time.

Testing

The SDK accepts a custom fetch — easy to mock without spinning up a network:
The package itself ships with 13 vitest tests covering construction, environment inference, error mapping, retry, balance tracking, and ledger pagination — see the source for fixture patterns.

Source + issues

What’s next