Skip to content

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

bash
pnpm add @youvico/api
bash
npm install @youvico/api

Create a client

ts
import { Client } from "@youvico/api";

const client = new Client({
  apiKey: process.env.YOUVICO_API_KEY!,
});

Call endpoints

The SDK groups endpoints by resource.

ts
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.

ts
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.

ts
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

ts
const client = new Client({
  apiKey: process.env.YOUVICO_API_KEY!,
  timeoutMs: 30_000,
});
OptionRequiredDescription
apiKeyYesYouViCo API key used to authenticate requests.
baseUrlNoOverride the API base URL.
fetchNoCustom fetch implementation.
timeoutMsNoRequest timeout in milliseconds.
headersNoAdditional headers sent with every request.