Use the generated client instead of hand-writing fetch calls.
The Asteri public SDK is generated from the same OpenAPI contract that powers the preview docs and reference index. It gives developers typed requests, typed responses, and the same auth headers every time.
Package name:@asteri/public-api-sdk
Generated from/api/public/v1/openapi.jsonand currently lives as a workspace package.
Use the normal package name externally. Inside this monorepo, prefer the workspace install form.
pnpm add @asteri/public-api-sdkpnpm --filter web add @asteri/public-api-sdk@workspace:*The generated client takes care ofx-organization-idand eitherx-api-keyor bearer auth for every request.
import { AsteriPublicApiClient } from '@asteri/public-api-sdk';
const client = new AsteriPublicApiClient({
baseUrl: 'http://localhost:3000',
organizationId: process.env.ASTERI_ORG_ID!,
apiKey: process.env.ASTERI_API_KEY!,
});
const customers = await client.customers.list({
query: { limit: 25 },
});
const estimate = await client.estimates.create({
customer_id: '8af2ca8e-8f31-4e6e-a46c-0703b61f7ca3',
currency: 'USD',
line_items: [
{ name: 'Quarterly hood cleaning', quantity: 1, unit_price: 1825 },
],
});Non-2xx responses throwAsteriApiErrorso integrations can read the HTTP status, parsed error payload, retry guidance, and returned contract version without string-parsing generic exceptions.
import { AsteriApiError, AsteriPublicApiClient } from '@asteri/public-api-sdk';
const client = new AsteriPublicApiClient({
baseUrl: 'http://localhost:3000',
organizationId: process.env.ASTERI_ORG_ID!,
apiKey: process.env.ASTERI_API_KEY!,
});
try {
await client.customers.list();
} catch (error) {
if (error instanceof AsteriApiError) {
console.error(error.status);
console.error(error.payload);
console.error(error.retryAfter);
}
throw error;
}The package exports hand-written helpers layered on top of the generated client for common workflows like walking paginated list endpoints across every page.
import { AsteriPublicApiClient, listAllCustomers } from '@asteri/public-api-sdk';
const client = new AsteriPublicApiClient({
baseUrl: 'http://localhost:3000',
organizationId: process.env.ASTERI_ORG_ID!,
apiKey: process.env.ASTERI_API_KEY!,
});
const customers = await listAllCustomers(client, {
pageSize: 100,
});The SDK includes concrete example files you can run directly. Use them as your fastest path to a working integration.
Example:packages/public-api-sdk/examples/list-all-customers.ts
ASTERI_BASE_URL=http://localhost:3000 \
ASTERI_ORG_ID=your-org-id \
ASTERI_API_KEY=ast_live_your_key \
pnpm -C packages/public-api-sdk example:list-all-customersExample:packages/public-api-sdk/examples/create-estimate.ts
ASTERI_BASE_URL=http://localhost:3000 \
ASTERI_ORG_ID=your-org-id \
ASTERI_API_KEY=ast_live_your_key \
ASTERI_CUSTOMER_ID=customer-uuid \
pnpm -C packages/public-api-sdk example:create-estimateCI publishes preview artifacts to the stable GitHub prerelease tagpublic-api-preview-latestso consumers outside this monorepo can install the SDK tarball or download the OpenAPI file directly.
Current:asteri-public-api-sdk-0.1.0.tgz
npm install https://github.com/Asteri-Labs/asteri/releases/download/public-api-preview-latest/asteri-public-api-sdk-0.1.0.tgzCurrent:asteri-public-api-openapi.json
curl -L https://github.com/Asteri-Labs/asteri/releases/download/public-api-preview-latest/asteri-public-api-openapi.json -o asteri-public-api-openapi.jsonThe monorepo includes a tiny end-to-end starter app that uses the SDK against the live preview API, supports customer, appointment, and estimate creation, and exposes a local webhook inbox panel at/webhooks/asteri.
App path:apps/public-api-starter
ASTERI_BASE_URL=http://localhost:3000 \
ASTERI_ORG_ID=your-org-id \
ASTERI_API_KEY=ast_live_your_key \
ASTERI_WEBHOOK_SECRET=your_webhook_secret \
PORT=4010 \
pnpm dev:public-api-starterWhenever the public contract changes, regenerate the client from the current OpenAPI document rather than editing generated code by hand.
pnpm sdk:public-api:generate