# VidsSave YouTube Download API

## Overview
3-step process to download YouTube videos/audio via vidssave.com API.

## Auth
```
auth: 20250901majwlqo
domain: api-ak.vidssave.com
```

## Step 1: Parse Video Metadata

**POST** `https://api.vidssave.com/api/contentsite_api/media/parse`

**Body (form-urlencoded):**
```
auth=20250901majwlqo
domain=api-ak.vidssave.com
origin=source
link=https://www.youtube.com/watch?v=VIDEO_ID
```

**Response:** Returns `data.resources[]` array with available formats:
- Each resource has: `resource_id`, `quality`, `format`, `type` (video/audio), `size`, `resource_content`
- Some have `download_url` directly (if `download_mode` = `check_download`)
- Others need Step 2 to generate download link

### Available Formats (example):
| Quality | Format | Type | Size |
|---------|--------|------|------|
| 144P | MP4 | video | ~60MB |
| 240P | MP4 | video | ~101MB |
| 360P | MP4 | video | ~491MB |
| 480P | MP4 | video | ~269MB |
| 720P | MP4 | video | ~484MB |
| 1080P | MP4 | video | ~1.6GB |
| LOW | WEBM | audio | ~28MB |
| 48KBPS | M4A | audio | ~44MB |
| 128KBPS | M4A | audio | ~117MB |
| 256KBPS | OPUS | audio | ~118MB |

## Step 2: Request Download

**POST** `https://api.vidssave.com/api/contentsite_api/media/download`

**Body (form-urlencoded):**
```
auth=20250901majwlqo
domain=api-ak.vidssave.com
request=<resource_content from Step 1>
no_encrypt=1
```

**Response:**
```json
{
    "data": {
        "task_id": "<task_id>"
    },
    "status": 1
}
```

## Step 3: Poll for Download Link (SSE)

**GET** `https://api.vidssave.com/sse/contentsite_api/media/download_query?auth=20250901majwlqo&domain=api-ak.vidssave.com&task_id=<task_id>&download_domain=vidssave.com&origin=content_site`

**SSE Events:**
```
event: running
data: {"status":"running","progress":0,...}

event: running
data: {"status":"running","progress":49,...}

event: success
data: {"status":"success","progress":100,"filesize":117792844,"download_link":"https://...","download_type":""}
```

Poll until `status` = `success`, then use `download_link` to download the file.

## Notes
- **ALWAYS download 256KBPS audio** — best quality available
- Some resources have `download_url` directly in Step 1 response (when `download_mode` = `check_download`) — can skip Step 2/3 for those
- SSE endpoint streams progress updates; final event contains the download URL
