@sybilion/sdk
v0.1.1
Published
Official TypeScript SDK for the Sybilion API.
Readme
@sybilion/sdk
Official TypeScript/JavaScript SDK for the Sybilion API. Ships as both ESM and CommonJS (import or require).
Install
npm install @sybilion/sdkConfiguration
- Credential:
Client({ token: "..." })(alias:apiKey). - Base URL:
baseUrl(alias:apiUrl), thenprocess.env.SYBILION_API_BASE_URLon Node, thenhttps://api.sybilion.dev.
The package exports SYBILION_API_BASE_URL_ENV and resolveApiUrl() for the same resolution rules as the Go/Python clients.
Quick use (me)
CommonJS:
const { Client } = require("@sybilion/sdk");
const client = new Client({ token: process.env.SYBILION_API_TOKEN });
const me = await client.raw.apiV1MeGet();import { Client } from "@sybilion/sdk";
const client = new Client({
token: process.env.SYBILION_API_TOKEN!,
});Use client.raw for the OpenAPI DefaultApi. Async helpers: waitForecast, iterUsagePages, iterJobsPages.
Forecasting (end-to-end)
const fs = require("node:fs");
const { Client } = require("@sybilion/sdk");
const client = new Client({ token: process.env.SYBILION_API_TOKEN });
await client.raw.apiV1MeGet();
const payload = JSON.parse(fs.readFileSync("forecast_post_example.json", "utf8"));
const started = await client.raw.apiV1ForecastsPost({ forecastRequestV1: payload });
const job = await client.waitForecast(started.jobId, { pollMs: 2000, timeoutMs: 30 * 60_000 });
if (job.status !== "completed") throw new Error(`forecast status=${job.status}`);Download an artifact
const path = require("node:path");
const fs = require("node:fs");
const a = job.artifacts?.[0];
if (!a?.name) throw new Error("no artifacts");
const blob = await client.raw.apiV1ForecastsIdArtifactsNameGet({ id: started.jobId, name: a.name });
const bytes = Buffer.from(await blob.arrayBuffer());
fs.mkdirSync("out", { recursive: true });
fs.writeFileSync(path.join("out", a.name), bytes);Build
npm ci
npm run buildMaintainer commands
bash scripts/sync-from-api-repo.sh
bash scripts/sdk-generate-typescript.sh
bash scripts/sdk-verify-typescript.sh
make verify
make smokeDocumentation
Full guides, feature walkthroughs, API reference, and SDK patterns: https://sybilion.dev/docs/.
Support
- Email — [email protected]
- Slack — Sybilion Community
- Discord — Sybilion Developers Community
License
Apache-2.0 — see LICENSE if present in your distribution.
