> ## Documentation Index
> Fetch the complete documentation index at: https://api-tools.memories.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Create a collection, upload a video, wait for indexing, and read the results — in five minutes.

<Info>
  **Host**: `https://api.memories.ai/datalake/v1`
  **Auth**: `Authorization: sk-mai-...`
</Info>

This walks the full happy path: **create a collection → upload a video → poll the operation → read results**.

You need an API key first — create one in the **[Developer Console](https://console.memories.ai/)**, then set it here along with the base path:

```bash theme={null}
BASE=https://api.memories.ai/datalake/v1
AUTH="Authorization: sk-mai-xxxx"
```

<Steps>
  <Step title="Create a collection">
    Pick a vector model; optionally enable safety detection or face recognition.

    ```bash theme={null}
    COL=$(curl -s -X POST "$BASE/collections" -H "$AUTH" -H "Content-Type: application/json" \
      -d '{"name":"demo","enabled_detectors":["safety_detector"]}' \
      | jq -r .id)
    ```
  </Step>

  <Step title="Upload a video by URL">
    Returns `202` with a `video_id` and an `operation`.

    ```bash theme={null}
    R=$(curl -s -X POST "$BASE/videos" -H "$AUTH" -H "Content-Type: application/json" \
      -d '{"collection_id":"'$COL'","source_url":"https://example.com/demo.mp4","fps":1.0}')
    VID=$(echo $R | jq -r .video_id); OP=$(echo $R | jq -r .operation)
    ```
  </Step>

  <Step title="Poll the operation until done">
    Indexing runs `preprocess → index → derive`.

    ```bash theme={null}
    watch -n 5 "curl -s $BASE/operations/$OP -H '$AUTH' | jq '{done, progress}'"
    ```
  </Step>

  <Step title="Read the results">
    Once `ready`, pull details, summary, captions, safety events, or any time-slice.

    ```bash theme={null}
    curl -s "$BASE/videos/$VID" -H "$AUTH" | jq            # details (duration / AI title / tags)
    curl -s "$BASE/videos/$VID/summary" -H "$AUTH"          # AI summary
    curl -s "$BASE/videos/$VID/caption" -H "$AUTH"          # full captions
    curl -s "$BASE/videos/$VID/events" -H "$AUTH"           # safety events (if a detector is on)
    curl -s "$BASE/moments/$VID@10.0-20.0?expand=caption,frame,clip" -H "$AUTH"   # any time-slice
    ```
  </Step>
</Steps>

## The same flow in Python

```python theme={null}
import time, requests

BASE = "https://api.memories.ai/datalake/v1"
HEADERS = {"Authorization": "sk-mai-..."}

col = requests.post(f"{BASE}/collections", headers=HEADERS,
    json={"name": "demo", "enabled_detectors": ["safety_detector"]}).json()

r = requests.post(f"{BASE}/videos", headers=HEADERS,
    json={"collection_id": col["id"], "source_url": "https://example.com/demo.mp4", "fps": 1.0}).json()
vid, op = r["video_id"], r["operation"]

while True:                                        # poll to done
    o = requests.get(f"{BASE}/operations/{op}", headers=HEADERS).json()
    if o["done"]:
        break
    time.sleep(5)

print(requests.get(f"{BASE}/videos/{vid}/summary", headers=HEADERS).json())
print(requests.get(f"{BASE}/moments/{vid}@10.0-20.0?expand=caption,frame", headers=HEADERS).json())
```

## Next steps

<CardGroup cols={2}>
  <Card title="Search" icon="magnifying-glass" href="/datalake/search/search">
    Query the collection and get moments back.
  </Card>

  <Card title="Live Stream" icon="signal-stream" href="/datalake/streams/open-stream">
    Attach an rtsp/rtmp source and search it live.
  </Card>

  <Card title="Webhooks" icon="webhook" href="/datalake/reference/webhooks">
    Get notified instead of polling.
  </Card>

  <Card title="Errors & Rate Limits" icon="triangle-exclamation" href="/reference/errors-and-rate-limits">
    The full error envelope and retry guidance.
  </Card>
</CardGroup>
