@retainrabbit/api-client
v0.1.0
Published
Server-side typed REST client for the RetainRabbit API.
Readme
@retainrabbit/api-client
Typed server-side REST client over a RetainRabbit /api/v1.
Server-side only — never expose your
rk_live_key in a browser bundle. This package holds your API key and must run only on a server (API route, backend service, edge function with a secret). For the browser, use@retainrabbit/jsor@retainrabbit/react, which are keyless.
Install
pnpm add @retainrabbit/api-clientUsage
import { createClient } from "@retainrabbit/api-client";
const rr = createClient({
baseUrl: "https://app.example.com/api/v1",
apiKey: process.env.RETAINRABBIT_API_KEY!, // server secret
});
const flows = await rr.flows.list();
const flow = await rr.flows.get(flows[0].id);
const session = await rr.sessions.start({ customerId: "cus_123", reason: "too_expensive" });
const stats = await rr.stats();Methods return the API's data payload and throw RetainRabbitApiError { status, message } on a non-2xx response.
