Package Exports
- @alpha-sdk/client
Readme
@alpha-sdk/client
TypeScript client for the Alpha Camera REST API — control Sony cameras via REST. Auto-generated from the OpenAPI spec via Fern.
Install
npm install @alpha-sdk/clientUsage
import { AlphaSDKClient } from "@alpha-sdk/client";
const client = new AlphaSDKClient({
environment: "http://localhost:8080",
});
// Discover cameras
const listing = await client.cameras.list();
console.log(listing.cameras);
// Connect, shoot, disconnect
const cameraId = listing.cameras[0].id;
await client.cameras.connect({ cameraId, mode: "remote" });
await new Promise((r) => setTimeout(r, 500)); // settle (see Recipe 5)
await client.properties.setPriorityKey({ cameraId, setting: "pc-remote" });
await client.actions.afShutter({ cameraId });
await client.cameras.disconnect({ cameraId });Resources exposed
| Accessor | What it covers |
|---|---|
client.server |
Server status, logs, shutdown |
client.cameras |
Discover, connect, disconnect |
client.properties |
Read/write properties (ISO, aperture, priority key, etc.) |
client.actions |
Shoot, focus near/far, zoom, movie recording |
client.liveView |
Enable/start/stop live view stream |
client.sdCard |
List + download SD card files |
client.settings |
Save-info, LUT import, settings-file up/download |
Every REST endpoint in the OpenAPI spec has a method here.
Recipes — SSE, live view, server lifecycle, discovery
Some patterns aren't REST and are deliberately not generated into this client — they ship as copy-paste recipes in docs/recipes/:
| Pattern | Recipe |
|---|---|
| Real-time events (SSE) | Recipe 1 — SSE event consumer |
| Live view frame polling | Recipe 2 — Live view polling |
| Server subprocess lifecycle | Recipe 3 — Server subprocess manager |
| Camera discovery / hot-plug | Recipe 4 — Discovery + auto-reconnect |
| Retry with backoff | Recipe 5 — Retry + backoff |
| React hook | Recipe 6 — React hook |
Why recipes instead of a wrapper library? These patterns are standard JS/TS idioms (fetch streaming, setInterval, child_process.spawn). Owning the code in your app is easier to debug, easier to modify, and easier for AI coding assistants to reason about than an opaque library abstraction.
Error handling
Every non-2xx response throws a typed subclass of AlphaSDKError:
import { AlphaCameraRestApi, AlphaSDKError } from "@alpha-sdk/client";
const { BadRequestError, NotFoundError } = AlphaCameraRestApi;
try {
await client.cameras.connect({ cameraId: "unknown", mode: "remote" });
} catch (err) {
if (err instanceof BadRequestError) {
console.error("400:", (err.body as any).message);
} else if (err instanceof NotFoundError) {
console.error("404:", err.body);
} else if (err instanceof AlphaSDKError) {
console.error(`${err.statusCode}: ${err.message}`);
}
}Regenerate
From the repo root:
cd fern && fern generate --group ts-sdk --localOnly generated source is rewritten; package.json, tsconfig.json, README.md, CHANGELOG.md stay put.
License
MIT — see LICENSE.