Package Exports
- @alpha-sdk/client
Readme
@alpha-sdk/client
TypeScript client for the Alpha Camera REST API — control Sony cameras via REST.
Public example app:
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 on crsdk.app:
| Pattern | Recipe |
|---|---|
| Real-time events (SSE) | SSE events |
| Live view frame polling | Live view polling |
| Server subprocess lifecycle | Server subprocess |
| Camera discovery / hot-plug | Discovery + reconnect |
| Retry with backoff | Retry + backoff |
| React hook | 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 AlphaSDKError) {
console.error(`${err.statusCode}: ${err.message}`);
}
}404 is used only on a smaller subset of endpoints (for example missing live
view frames or camera-specific SD-card download targets). Connection-status and
disconnect remain 200 even when nothing is currently connected.
License
MIT — see LICENSE.