You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{Nika}from'@supernovae-st/nika-client';// Stripe-style HMAC-SHA256 verification (async — uses Web Crypto API)// Works in Node.js 18+, Deno, Cloudflare Workers, and Bun.constisValid=awaitNika.verifyWebhook(rawBody,signatureHeader,// 't=1234567890,v1=abc123...'webhookSecret,);
Configuration
new Nika(config)
Option
Type
Default
Description
url
string
(required)
nika serve URL (http/https)
token
string
(required)
Bearer token (NIKA_SERVE_TOKEN)
timeout
number
30000
HTTP request timeout in ms
retries
number
2
Retries on 429/5xx
concurrency
number
24
Max concurrent HTTP requests
pollInterval
number
2000
Initial poll interval in ms
pollTimeout
number
300000
Max poll duration in ms
pollBackoff
number
1.5
Poll backoff multiplier
fetch
typeof fetch
globalThis.fetch
Custom fetch function
logger
NikaLogger
(none)
Logger interface (debug, info, warn, error)
API reference
Jobs — nika.jobs.*
Method
Returns
Description
submit(workflow, inputs?, opts?)
RunResponse
Submit workflow, return { job_id, status }
status(jobId)
NikaJob
Get job status
cancel(jobId)
CancelResponse
Cancel a running job
run(workflow, inputs?, opts?)
NikaJob
Submit + poll until terminal state
stream(jobId, opts?)
AsyncIterable<NikaEvent>
SSE event stream
artifacts(jobId)
NikaArtifact[]
List job artifacts
artifact(jobId, name)
string
Download artifact as text
artifactJson<T>(jobId, name)
T
Download artifact as parsed JSON
artifactBinary(jobId, name)
Uint8Array
Download artifact as raw bytes
artifactStream(jobId, name)
ReadableStream<Uint8Array>
Stream artifact (for large files)
runAndCollect(workflow, inputs?, opts?)
Record<string, unknown>
Run + collect all non-binary artifacts
Workflows — nika.workflows.*
Method
Returns
Description
list()
WorkflowInfo[]
List all workflows (auto-paginates)
listPage(opts?)
ListWorkflowsResponse
List single page (manual pagination)
reload()
WorkflowInfo[]
Rescan workflows directory
source(name)
string
Get raw YAML source
System
Method
Returns
Description
nika.health()
HealthResponse
Health check (no auth required)
Nika.verifyWebhook(body, sig, secret)
boolean
Static: verify webhook HMAC-SHA256
Error classes
All SDK errors extend NikaError. Catch it to handle any SDK error:
Terminal events close the SSE stream automatically.
The SDK auto-reconnects on stream drops (up to 3 attempts), using the Last-Event-Id header to resume without losing events. Configure via StreamOptions:
forawait(consteventofnika.jobs.stream(jobId,{maxReconnects: 5,reconnectDelay: 2000,idleTimeout: 120_000,})){// events are guaranteed in order, even across reconnects}