@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
fetch). Works in browsers, Edge runtimes, and Bun. Zero runtime dependencies.
Quickstart
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:.status, .requestId, and .body — pull them straight into your support tickets and observability stack.
| Error class | HTTP | Retried? |
|---|---|---|
ValidationError | 400 | No |
AuthenticationError | 401 | No |
InsufficientCreditsError | 402 | No |
ForbiddenError | 403 | No |
NotFoundError | 404 | No |
RateLimitError | 429 | Yes (honors Retry-After) |
ServerError | 5xx | Yes (exponential backoff with jitter) |
ScannerError (base) | any | depends on subclass |
Auto-tracked balance
Every billed response includes anX-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:
Server-side batches — createBatch + waitForBatch
For large lists (500+) or when you want the server to manage the queue:
scanner.cancelBatch(id)) to refund the unprocessed credits.
CSV upload
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
owner/admin roles when authenticated via JWT. API-key callers have no role gate.
Trace propagation
Pass arequestId per call so your distributed-trace IDs flow into our request logs:
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 customfetch — easy to mock without spinning up a network:
Source + issues
- npm:
@sly_ai/scanner - Source: github.com/Sly-devs/sly/tree/main/packages/scanner-sdk
- Issues / requests: github.com/Sly-devs/sly/issues (label
scanner-sdk) - Support: partners@getsly.ai
What’s next
- Quickstart — the same flow without the SDK
- Endpoint reference
- Credits & billing