Skip to main content
The @kashdao/sdk package is a hand-written TypeScript client for the REST API. It’s the recommended way to integrate from any TS/JS runtime — Node 22+, modern browsers, Deno, Bun, or Cloudflare Workers.

Construct the client

The client is a thin façade over typed sub-clients: kash.markets, kash.trades, kash.portfolio, kash.webhooks, kash.account, kash.traces.

Place a trade

Pagination — async iteration

Every list method returns a Page<T> that’s both the first page and an AsyncIterable<T>:

Get a quote

Verify a webhook

Typed errors

Every error is a typed subclass of KashError:

Lifecycle hooks

Tap into every request, response, retry, and error for logging or observability:
A throwing hook never breaks the request — exceptions are swallowed and the call proceeds. Hooks are safe to add for telemetry without thinking about resilience.

Cloning a client

withConfig returns a new client with overridden fields. Useful for tenant switching or per-request key swaps:
withConfig re-validates — passing an invalid override throws KashConfigurationError.

Mock client for tests

@kashdao/sdk/testing exports a fake client with realistic default fixtures:
The defaults pass the wire-shape contract tests, so they’re indistinguishable from real production responses for downstream consumers.

Versioning

The SDK follows SemVer. The KashError shape, public method signatures, and exported types are SemVer-stable. Internals (private fields, pagination tokens, transport details) are not — pin to a major version range in package.json. The SDK auto-includes a User-Agent header identifying its version, so we can correlate API logs with SDK versions when investigating issues.

Pin against a specific API contract version

Send the X-Kash-Api-Version request header to lock your integration against a specific contract date. The SDK can be configured to send it on every request:
Server response carries X-API-Version (the canonical version) plus Sunset / Deprecation headers when your pinned version is winding down (12-month deprecation window per RFC 8594). The SDK’s onResponse hook surfaces both — wire it into your monitoring to flag deprecations early. Pinning to an unknown date returns 410 API_VERSION_UNSUPPORTED with the supported list in metadata.supported.

Quality gates

The SDK ships with strict quality gates that are part of the public contract:
  • Bundle size budgets — main entry ≤ 24 KB gzipped, /testing subpath ≤ 8 KB. Enforced at publish time via size-limit.
  • Static type testspnpm test:types runs vitest’s typecheck mode against tests/types/public-types.test-d.ts. The public TypeScript surface is locked: any change to a public type’s shape fails compilation, forcing a deliberate CHANGELOG + version bump.
  • Public-barrel snapshottests/unit/barrel-snapshot.test.ts pins the exact set of exported names. Accidental removals fail the build.
  • Wire-shape contracttests/contract/wire-shape.test.ts asserts every resource schema matches canonical fixtures. Ships to the public mirror.

Source & changelog

Next

CLI

kash — the command-line interface. Same primitives, scripting-friendly.

Endpoint Reference

The full live spec at /v1/docs.