SDK
The JavaScript SDK is the easiest way to call the YouViCo API from server-side JavaScript or TypeScript. It adds API key authentication, typed request parameters, response types, timeouts, error handling, and multipart file upload helpers on top of the HTTP API.
WARNING
API keys are secret. Use the SDK in trusted server-side code only, and never expose your API key in browser code or public repositories.
Install
pnpm add @youvico/apinpm install @youvico/apiCreate a client
import { Client } from "@youvico/api";
const client = new Client({
apiKey: process.env.YOUVICO_API_KEY!,
});Call endpoints
The SDK groups endpoints by resource.
const projects = await client.projects.search({
query: "launch",
});
const folders = await client.folders.list("bdbff5de-96d7-468f-9db0-85fe28bd6b62");
const comments = await client.comments.list("FX1234567890ABCD");Every API reference page includes CLI, SDK, and cURL examples so you can switch between the command-line workflow, the SDK call, and the raw HTTP request.
Upload files
For most file uploads, use files.upload. It starts a multipart upload, uploads each part, and completes the upload for you.
const uploaded = await client.files.upload("bdbff5de-96d7-468f-9db0-85fe28bd6b62", {
name: "launch.mp4",
path: "/Users/me/videos/launch.mp4",
});You can also pass Blob, Buffer, ArrayBuffer, Uint8Array, or string through the data option.
Handle errors
Unsuccessful API responses throw YouvicoError.
import { YouvicoError } from "@youvico/api";
try {
await client.projects.get("bdbff5de-96d7-468f-9db0-85fe28bd6b62");
} catch (error) {
if (error instanceof YouvicoError) {
console.error(error.status, error.code, error.message);
}
throw error;
}Client options
const client = new Client({
apiKey: process.env.YOUVICO_API_KEY!,
timeoutMs: 30_000,
});| Option | Required | Description |
|---|---|---|
apiKey | Yes | YouViCo API key used to authenticate requests. |
baseUrl | No | Override the API base URL. |
fetch | No | Custom fetch implementation. |
timeoutMs | No | Request timeout in milliseconds. |
headers | No | Additional headers sent with every request. |