EmofyEmofy Developers
TypeScript SDK

TypeScript SDK

@emofy/dev-sdk — the official type-safe client for the Emofy Developer API (v1): client construction, error handling, and the full API reference.

@emofy/dev-sdk is the official TypeScript client for the Emofy Developer API (v1). Its types are generated from the frozen OpenAPI contract, and the runtime is a thin fetch wrapper that unwraps the V1 envelope, surfaces a typed error, honours Retry-After backoff, and transmits idempotency keys.

For a guided, end-to-end walkthrough (API key → first request → webhook verification) start with the SDK Quickstart. This page covers the essentials; the full SDK Reference documents every public export.

Install

npm install @emofy/dev-sdk

Construct a client

import { createEmofyClient } from "@emofy/dev-sdk";

const emofy = createEmofyClient({
  apiKey: process.env.EMOFY_API_KEY!,
  baseUrl: process.env.EMOFY_API_URL!,
});

The returned EmofyClient is stateless and safe to share across requests. See createEmofyClient and EmofyClientConfig for every option.

Handle errors

Every failed call throws an EmofyApiError carrying the stable machine-readable code — branch on the code, never the human message:

import { EmofyApiError } from "@emofy/dev-sdk";

try {
  await emofy.tasks.create({ title: "Practice reading" });
} catch (err) {
  if (err instanceof EmofyApiError && err.code === "scope_insufficient") {
    // re-request the missing scope
  }
  throw err;
}

The full set of codes is the Error Catalog; the SDK's code type is the EmofyApiErrorCode open union.

Reference

The SDK Reference is generated directly from the SDK's TypeScript surface — every function, class, interface, and type with its signature.

On this page