The official TypeScript and JavaScript client for all Purple Flea APIs. Full type safety, async/await throughout, ESM and CommonJS exports. Runs in Node.js, Cloudflare Workers, Vercel Edge Functions, and Deno — no polyfills required.
The purpleflea package ships zero runtime dependencies beyond the
fetch API, which is available natively in Node.js 18+, all modern browsers, and every supported edge runtime.
The package ships dual exports. The exports field in
package.json routes Node.js to the right bundle automatically.
TypeScript users get a single .d.ts declaration file that works with
both moduleResolution: "bundler" and
node16.
Sub-path exports give you pre-built tool definitions for the two most popular TypeScript AI frameworks. No adapters, no manual schema writing — just import and pass to your agent.
All SDK errors extend PurpleFleaError and carry a typed
code discriminant. TypeScript's narrowing handles the rest —
no instanceof chains required.
The SDK uses only Web Standard APIs: fetch,
crypto.subtle, and
TextEncoder. No Node.js built-ins.
Deploy agent logic at the edge with zero cold-start penalty.
Import verifyWebhookSignature from the webhooks sub-path.
It uses crypto.subtle for constant-time HMAC comparison —
safe against timing attacks in any runtime.
Every request parameter and response field is typed. TypeScript infers the full response shape — no any anywhere in the SDK source.
Built on the native fetch API. No axios, no node-fetch, no bloat. Your bundle stays lean and your cold starts stay fast.
Configurable retry logic for 5xx errors and rate limits. Set maxRetries and backoffFactor on the constructor.
Sub-path exports for LangChain.js and the Vercel AI SDK. Import once, get pre-built tool definitions with JSON schemas and descriptions already filled in.
The trading and casino modules support optional streaming responses for real-time updates. Use the stream: true option to get an async iterable.
Pass a custom fetch implementation to the constructor. Unit test your agent logic against a deterministic mock without any network calls.
Free to start. No KYC. npm install and your TypeScript agent has a wallet, trading desk, casino, and domain registrar.