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

# Create Collection

> Collections group your media for organization and scoped search. Think of them as folders that also enable searching across all videos within.

## Quick Example

<CodeGroup>
  ```python Python theme={null}
  import videodb

  conn = videodb.connect()

  # Create a collection
  coll = conn.create_collection(
      name="Q4 Meetings",
      description="All Q4 2024 team meetings"
  )
  print(coll.id)  # c-xxx
  ```

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

  const conn = await connect();

  // Create a collection
  const coll = await conn.createCollection(
      "Q4 Meetings",
      "All Q4 2024 team meetings"
  );
  console.log(coll.id);  // c-xxx
  ```
</CodeGroup>

***

## Collection Operations

### Create

<CodeGroup>
  ```python Python theme={null}
  coll = conn.create_collection(
      name="Security Footage",
      description="Warehouse camera feeds"
  )
  ```

  ```javascript Node.js theme={null}
  const coll = await conn.createCollection(
      "Security Footage",
      "Warehouse camera feeds"
  );
  ```
</CodeGroup>

### List All

<CodeGroup>
  ```python Python theme={null}
  collections = conn.get_collections()
  for c in collections:
      print(f"{c.id}: {c.name}")
  ```

  ```javascript Node.js theme={null}
  const collections = await conn.getCollections();
  for (const c of collections) {
      console.log(`${c.id}: ${c.name}`);
  }
  ```
</CodeGroup>

### Get by ID

<CodeGroup>
  ```python Python theme={null}
  coll = conn.get_collection("c-xxx-xxx")
  ```

  ```javascript Node.js theme={null}
  const coll = await conn.getCollection("c-xxx-xxx");
  ```
</CodeGroup>

### Update

<CodeGroup>
  ```python Python theme={null}
  coll = conn.update_collection(
      "c-xxx-xxx",
      "New Name",
      "Updated description"
  )
  ```

  ```javascript Node.js theme={null}
  const coll = await conn.updateCollection(
      "c-xxx-xxx",
      "New Name",
      "Updated description"
  );
  ```
</CodeGroup>

### Delete

<CodeGroup>
  ```python Python theme={null}
  coll.delete()
  ```

  ```javascript Node.js theme={null}
  await coll.delete();
  ```
</CodeGroup>

***

## List Media in Collection

<CodeGroup>
  ```python Python theme={null}
  # List videos
  videos = coll.get_videos()
  for v in videos:
      print(f"{v.id}: {v.name}")

  # List audios
  audios = coll.get_audios()

  # List images
  images = coll.get_images()
  ```

  ```javascript Node.js theme={null}
  // List videos
  const videos = await coll.getVideos();
  for (const v of videos) {
      console.log(`${v.id}: ${v.name}`);
  }

  // List audios
  const audios = await coll.getAudios();

  // List images
  const images = await coll.getImages();
  ```
</CodeGroup>

***

## Collection Search

Search restricts results to videos in that collection - essential for RAG applications:

<CodeGroup>
  ```python Python theme={null}
  understanding = video.understand(
      analyzers=[{"type": "spoken_words", "name": "transcript"}],
  )
  understanding.wait_until_complete()
  transcript_analyzer = understanding.get_analyzer("transcript")
  transcript_index = video.index(
      name="transcript",
      source=transcript_analyzer,
      use_for=["semantic"],
      fields={"semantic": ["text"]},
  )
  transcript_index.wait_until_complete()

  results = coll.semantic_search(
      "quarterly results",
      index_ids=[transcript_index.index_id],
      top_k=5,
  )
  for shot in results.get_shots():
      print(f"{shot.start}s: {shot.text}")
  ```

  ```javascript Node.js theme={null}
  const understanding = await video.understand([
    { type: "spoken_words", name: "transcript" },
  ]);
  await understanding.waitUntilComplete();
  const transcriptAnalyzer = await understanding.getAnalyzer("transcript");
  const transcriptIndex = await video.index(transcriptAnalyzer, {
    name: "transcript",
    useFor: ["semantic"],
    fields: { semantic: ["text"] },
  });
  await transcriptIndex.waitUntilComplete();

  const results = await coll.semanticSearch("quarterly results", {
    indexIds: [transcriptIndex.indexId],
    topK: 5,
  });
  for (const shot of results.getShots()) {
      console.log(`${shot.start}s: ${shot.text}`);
  }
  ```
</CodeGroup>

***

## Public Collections

Share collections publicly for read-only access. Anyone with the collection ID can access media and indexes.

### Create Public Collection

<CodeGroup>
  ```python Python theme={null}
  public_coll = conn.create_collection(
      name="Demo Videos",
      description="Public demo collection",
      is_public=True
  )
  ```

  ```javascript Node.js theme={null}
  const publicColl = await conn.createCollection(
      "Demo Videos",
      "Public demo collection",
      true  // isPublic
  );
  ```
</CodeGroup>

### Toggle Visibility

<CodeGroup>
  ```python Python theme={null}
  # Make private
  coll.make_private()
  print(coll.is_public)  # False

  # Make public
  coll.make_public()
  print(coll.is_public)  # True
  ```

  ```javascript Node.js theme={null}
  // Make private
  await coll.makePrivate();
  console.log(coll.isPublic);  // false

  // Make public
  await coll.makePublic();
  console.log(coll.isPublic);  // true
  ```
</CodeGroup>

### Access Public Collection

Anyone can access with the collection ID:

<CodeGroup>
  ```python Python theme={null}
  # Access VideoDB's OCR Benchmark Collection
  public_coll = conn.get_collection("c-c0a2c223-e377-4625-94bf-910501c2a31c")
  videos = public_coll.get_videos()
  ```

  ```javascript Node.js theme={null}
  // Access VideoDB's OCR Benchmark Collection
  const publicColl = await conn.getCollection("c-c0a2c223-e377-4625-94bf-910501c2a31c");
  const videos = await publicColl.getVideos();
  ```
</CodeGroup>

***

## What You Can Build

<CardGroup cols={2}>
  <Card title="Keyword Search Compilation" icon="search" href="/examples-and-tutorials/video-rag/keyword-search">
    Organize videos in collections and search across all of them
  </Card>

  <Card title="Multimodal Search" icon="brain" href="/examples-and-tutorials/video-rag/multimodal-search">
    Build searchable video libraries with text and visual queries
  </Card>

  <Card title="Character Clips" icon="user" href="/examples-and-tutorials/video-rag/character-clips">
    Search collections to extract clips featuring specific people
  </Card>
</CardGroup>

***

## Next Steps

<CardGroup cols={2}>
  <Card icon="upload" title="Upload Video" href="/pages/ingest/files-and-collections/upload-video">
    Add media to your collections
  </Card>

  <Card icon="folder" title="Collection Patterns" href="/pages/ingest/files-and-collections/collection-patterns">
    Batching, retries, and production patterns
  </Card>
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.