The typed Node.js API client — zero browser dependencies, native fetch (Node 18+).
@edpire/sdk/client exports EdpireClient, a typed wrapper over the Edpire REST API. It runs server-side only (your API key must never reach the browser), has zero browser dependencies, and uses native fetch.It is not a rendering pattern — it’s the backend utility used alongside the Embedded Player and Custom Flow.
Create the client once at module level and reuse it — don’t instantiate it per request.
import { EdpireClient } from "@edpire/sdk/client"// module level — one instance, reused across all requestsconst client = new EdpireClient({ apiKey: process.env.EDPIRE_API_KEY!, // starts with edp_live_ baseUrl: "https://edpire.com", // optional, this is the default})
Every method throws EdpireError on a non-2xx response:
import { EdpireError } from "@edpire/sdk/client"try { await client.getAssessment("bad-id")} catch (err) { if (err instanceof EdpireError) { console.log(err.status) // e.g. 404 console.log(err.message) // e.g. "Assessment not found" }}
Common status codes: 400 bad request · 401 invalid API key · 403 forbidden / origin not allowed · 404 not found · 409 max attempts reached · 422 grading failed · 429 rate limit exceeded.