> ## Documentation Index
> Fetch the complete documentation index at: https://docs.videodb.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Node.js SDK

> Install and configure the VideoDB Node.js SDK

## Installation

```bash theme={null}
npm install videodb
# or
yarn add videodb
```

<CardGroup cols={2}>
  <Card icon="package" title="npm" href="https://www.npmjs.com/package/videodb">
    View package on npm
  </Card>

  <Card icon="github" title="GitHub" href="https://github.com/video-db/videodb-node">
    Source code and issues
  </Card>
</CardGroup>

## Quick Start

```javascript theme={null}
import { connect } from 'videodb';

// Connect using environment variable
const conn = connect();

// Or pass API key directly
const conn = connect({ apiKey: "your-api-key" });
```

## Environment Variables

| Variable          | Description                                                        |
| :---------------- | :----------------------------------------------------------------- |
| `VIDEODB_API_KEY` | Your API key from [console.videodb.io](https://console.videodb.io) |

```bash theme={null}
export VIDEODB_API_KEY="your-api-key"
```

## TypeScript Support

Full TypeScript definitions are included. No additional packages needed.

```typescript theme={null}
import { connect, Video, SearchResult } from 'videodb';

const conn = connect();
const video: Video = await conn.uploadURL("default", { url: "..." });
const results: SearchResult = await video.search("query");
```

## Module Formats

Both ESM and CommonJS are supported:

```javascript theme={null}
// ESM
import { connect } from 'videodb';

// CommonJS
const { connect } = require('videodb');
```

## Basic Usage

```javascript theme={null}
import { connect } from 'videodb';

const conn = connect();

// Upload a video
const video = await conn.uploadURL("default", {
    url: "https://www.youtube.com/watch?v=example"
});

// Index for search
await video.indexSpokenWords();

// Search with natural language
const results = await video.search("key moments");
for (const shot of results.shots) {
    console.log(`${shot.start}s: ${shot.text}`);
}
```

## Server Side

Use the full SDK on your backend to manage sessions, run AI pipelines, and handle webhooks. Your API key should never be exposed to the browser.

```javascript theme={null}
// Create a capture session and generate a client token
const cap = await conn.createCaptureSession({ endUserId: "user_123" });
const token = await conn.generateClientToken(600);
```

## Client Side

For real-time desktop capture, install the Capture SDK on your client application. It uses short-lived tokens instead of your API key.

<Note>
  Desktop capture currently supports **macOS** and **Windows**.
</Note>

```bash theme={null}
npm install videodb
```

<Card icon="monitor" title="Capture SDK Overview" href="/pages/ingest/capture-sdks/overview">
  Learn how to integrate real-time screen, audio, and camera capture into your application
</Card>

## Next Steps

<CardGroup cols={2}>
  <Card icon="rocket" title="Quickstart" href="/pages/getting-started/quickstart">
    Build your first perception-enabled agent
  </Card>

  <Card icon="code" title="API Reference" href="/api-reference/introduction">
    Complete REST API documentation
  </Card>
</CardGroup>
