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

# Media Extraction

> Extract audio and video from online platforms including YouTube, TikTok, Instagram, and more using AudioPod AI's media extraction service.

## Overview

AudioPod AI's Media Extraction API provides powerful tools for downloading and extracting audio/video content from various online platforms. Extract high-quality audio from videos, download content in multiple formats, and get detailed metadata for content analysis.

### Key Features

* **Multi-Platform Support**: YouTube, TikTok, Instagram, Vimeo, Spotify, and more
* **Multiple Formats**: MP4, MP3, WAV, WebM, AAC, and other audio/video formats
* **Quality Options**: From 144p to 4K video, various audio bitrates
* **Metadata Extraction**: Title, description, duration, uploader info, view counts
* **Thumbnail Download**: Automatic thumbnail extraction and download
* **Batch Processing**: Download multiple videos efficiently
* **Public Access**: Limited public access without authentication
* **No Duration Limits**: Full-length content extraction for authenticated users

## Authentication

* **Public Access**: Limited features, 10-minute duration limit, basic formats only
* **Authenticated Access**: Full features with API key or JWT token
  * **API Key (Recommended)**: `X-API-Key: your_api_key` header
  * **JWT Token**: `Authorization: Bearer your_jwt_token` (for session-based auth)

## Rate Limits

All endpoints are rate limited to prevent abuse:

* **Public Video Info**: 60 requests/minute
* **Public Download**: 10 requests/minute
* **Authenticated Video Info**: 30 requests/minute
* **Authenticated Download**: 10 requests/minute
* **Bulk Download**: 3 requests/minute
* **Job Status**: 60 requests/minute
* **Job Management**: 30 requests/minute

## Video Information

### Get Video Info (Public)

Extract basic video metadata without authentication.

<Tabs>
  <Tab title="POST">
    ```http theme={null}
    POST /api/v1/video/public/info
    Content-Type: application/json

    {
      "url": "https://youtube.com/watch?v=example123",
      "include_formats": false
    }
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    import requests

    # Get basic video info (no auth required)
    video_info_request = {
        "url": "https://youtube.com/watch?v=example123",
        "include_formats": False  # Limited format info for public access
    }

    response = requests.post(
        "https://api.audiopod.ai/api/v1/video/public/info",
        json=video_info_request
    )

    if response.status_code == 200:
        video_info = response.json()
        print(f"Title: {video_info['title']}")
        print(f"Duration: {video_info['duration']} seconds")
        print(f"Uploader: {video_info['uploader']}")
        print(f"View count: {video_info['view_count']}")
    ```
  </Tab>

  <Tab title="cURL">
    ```bash theme={null}
    curl -X POST "https://api.audiopod.ai/api/v1/video/public/info" \
      -H "Content-Type: application/json" \
      -d '{
        "url": "https://youtube.com/watch?v=example123",
        "include_formats": false
      }'
    ```
  </Tab>
</Tabs>

### Get Video Info (Authenticated)

Extract comprehensive video metadata with full format information.

<Tabs>
  <Tab title="POST">
    ```http theme={null}
    POST /api/v1/video/info
    X-API-Key: {api_key}
    Content-Type: application/json

    {
      "url": "https://youtube.com/watch?v=example123",
      "include_formats": true
    }
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    # Get comprehensive video info (authentication required)
    video_info_request = {
        "url": "https://youtube.com/watch?v=example123",
        "include_formats": True  # Get all available formats and qualities
    }

    response = requests.post(
        "https://api.audiopod.ai/api/v1/video/info",
        headers={"X-API-Key": api_key},
        json=video_info_request
    )

    if response.status_code == 200:
        video_info = response.json()
        print(f"Title: {video_info['title']}")
        print(f"Duration: {video_info['duration']} seconds")
        print(f"Estimated credits: {video_info['estimated_credits']}")
        
        # Available formats
        for format_info in video_info.get("formats", []):
            print(f"Format: {format_info['format']} - {format_info['quality']}")
    ```
  </Tab>
</Tabs>

**Response:**

```json theme={null}
{
  "title": "Amazing Video Content",
  "description": "This is an example video with great content...",
  "uploader": "Content Creator",
  "upload_date": "2024-01-15",
  "duration": 185.4,
  "view_count": 1250000,
  "like_count": 45000,
  "thumbnail_url": "https://img.youtube.com/vi/example123/maxresdefault.jpg",
  "platform": "youtube",
  "video_id": "example123",
  "estimated_credits": 102,
  "formats": [
    {
      "format_id": "22",
      "format": "mp4",
      "quality": "720p",
      "resolution": "1280x720",
      "fps": 30,
      "file_size": 85600000,
      "audio_codec": "aac",
      "video_codec": "h264"
    },
    {
      "format_id": "140",
      "format": "mp3",
      "quality": "128kbps",
      "audio_codec": "aac",
      "file_size": 3000000
    }
  ]
}
```

## Media Download

### Download Media (Public)

Download videos with public access limitations.

<Tabs>
  <Tab title="POST">
    ```http theme={null}
    POST /api/v1/video/public/download
    Content-Type: application/json

    {
      "url": "https://youtube.com/watch?v=example123",
      "format": "mp3",
      "quality": "128kbps"
    }
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    # Public download (10-minute limit, basic formats only)
    download_request = {
        "url": "https://youtube.com/watch?v=example123",
        "format": "mp3",        # mp4, mp3, wav only for public
        "quality": "128kbps",   # Limited quality options
        "audio_only": True      # For audio-only download
    }

    response = requests.post(
        "https://api.audiopod.ai/api/v1/video/public/download",
        json=download_request
    )

    if response.status_code == 200:
        download_job = response.json()
        job_id = download_job["job"]["id"]
        print(f"Public download job created: {job_id}")
        print(f"Status: {download_job['job']['status']}")
    ```
  </Tab>
</Tabs>

### Download Media (Authenticated)

Download videos with full features and no restrictions.

<Tabs>
  <Tab title="POST">
    ```http theme={null}
    POST /api/v1/video/download
    X-API-Key: {api_key}
    Content-Type: application/json

    {
      "url": "https://youtube.com/watch?v=example123",
      "format": "mp4",
      "quality": "1080p",
      "audio_only": false,
      "include_thumbnail": true
    }
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    # Authenticated download (full features)
    download_request = {
        "url": "https://youtube.com/watch?v=example123",
        "format": "mp4",           # Any supported format
        "quality": "1080p",        # Any available quality
        "audio_only": False,    # Keep video, set True for audio-only
        "include_thumbnail": True, # Download thumbnail
        "format_selector": "best", # "best", "worst", or specific format_id
        "output_filename": "my_video.mp4"  # Custom filename
    }

    response = requests.post(
        "https://api.audiopod.ai/api/v1/video/download",
        headers={"X-API-Key": api_key},
        json=download_request
    )

    if response.status_code == 200:
        download_job = response.json()
        job_id = download_job["job"]["id"]
        print(f"Download job created: {job_id}")
        print(f"Estimated credits: {download_job['estimated_credits']}")
    ```
  </Tab>
</Tabs>

**Request Parameters:**

* **`url`** (required): URL of the video to download
* **`format`** (optional): Output format (mp4, mp3, wav, webm, mkv, etc.)
* **`quality`** (optional): Quality setting (144p, 720p, 1080p, 4K for video; 128kbps, 320kbps for audio)
* **`audio_only`** (optional): Extract audio only (default: false)
* **`include_thumbnail`** (optional): Download thumbnail image (default: false)
* **`format_selector`** (optional): Format selection strategy ("best", "worst", or specific format\_id)
* **`output_filename`** (optional): Custom output filename

**Response:**

```json theme={null}
{
  "job": {
    "id": 123,
    "status": "PROCESSING",
    "progress": 0,
    "url": "https://youtube.com/watch?v=example123",
    "format": "mp4",
    "quality": "1080p",
    "audio_only": false,
    "include_thumbnail": true,
    "estimated_duration": 185.4,
    "created_at": "2024-01-15T10:30:00Z",
    "task_id": "celery_task_uuid_here"
  },
  "estimated_credits": 102,
  "message": "Download job created successfully"
}
```

## Batch Downloads

### Bulk Download Multiple Videos

Download multiple videos in a single request.

<Tabs>
  <Tab title="POST">
    ```http theme={null}
    POST /api/v1/video/video-download/bulk-download
    X-API-Key: {api_key}
    Content-Type: application/json

    {
      "downloads": [
        {
          "url": "https://youtube.com/watch?v=video1",
          "format": "mp3",
          "quality": "320kbps"
        },
        {
          "url": "https://youtube.com/watch?v=video2", 
          "format": "mp4",
          "quality": "720p"
        }
      ],
      "audio_only": true,
      "include_thumbnails": false
    }
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    # Bulk download multiple videos
    bulk_request = {
        "downloads": [
            {
                "url": "https://youtube.com/watch?v=video1",
                "format": "mp3",
                "quality": "320kbps"
            },
            {
                "url": "https://youtube.com/watch?v=video2", 
                "format": "mp4",
                "quality": "720p"
            },
            {
                "url": "https://youtube.com/watch?v=video3",
                "format": "wav"  # High quality audio
            }
        ],
        "audio_only": True,         # Apply to all downloads  
        "include_thumbnail": False  # Apply to all downloads
    }

    response = requests.post(
        "https://api.audiopod.ai/api/v1/video/video-download/bulk-download",
        headers={"X-API-Key": api_key},
        json=bulk_request
    )

    if response.status_code == 200:
        bulk_job = response.json()
        print(f"Bulk download created with {len(bulk_job['jobs'])} jobs")
        for job in bulk_job["jobs"]:
            print(f"  Job {job['id']}: {job['url']}")
    ```
  </Tab>
</Tabs>

## Job Management

### Get Download Status

Monitor the progress of download jobs.

<Tabs>
  <Tab title="GET">
    ```http theme={null}
    GET /api/v1/video/video-download/jobs/{job_id}
    X-API-Key: {api_key}
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    job_id = 123
    response = requests.get(
        f"https://api.audiopod.ai/api/v1/video/video-download/jobs/{job_id}",
        headers={"X-API-Key": api_key}
    )

    if response.status_code == 200:
        job_status = response.json()
        print(f"Status: {job_status['status']}")
        print(f"Progress: {job_status['progress']}%")
        
        if job_status["status"] == "COMPLETED":
            print("Download complete!")
            print(f"Video URL: {job_status['download_url']}")
            if job_status.get("thumbnail_url"):
                print(f"Thumbnail URL: {job_status['thumbnail_url']}")
            
            # File information
            print(f"File size: {job_status['file_size']} bytes")
            print(f"Duration: {job_status['duration']} seconds")
    ```
  </Tab>
</Tabs>

**Response (Completed Job):**

```json theme={null}
{
  "id": 123,
  "status": "COMPLETED",
  "progress": 100,
  "url": "https://youtube.com/watch?v=example123",
  "format": "mp4",
  "quality": "1080p",
  "audio_only": false,
  "include_thumbnail": true,
  "created_at": "2024-01-15T10:30:00Z",
  "completed_at": "2024-01-15T10:33:15Z",
  "download_url": "https://api.audiopod.ai/download/video_123.mp4",
  "thumbnail_url": "https://api.audiopod.ai/download/thumbnail_123.jpg",
  "original_title": "Amazing Video Content",
  "file_size": 85600000,
  "duration": 185.4,
  "resolution": "1920x1080",
  "fps": 30,
  "audio_codec": "aac",
  "video_codec": "h264",
  "credits_used": 102,
  "processing_time": 195.2
}
```

### List Download Jobs

Get all download jobs for the authenticated user.

<Tabs>
  <Tab title="GET">
    ```http theme={null}
    GET /api/v1/video/video-download/jobs?status=COMPLETED&platform=youtube&limit=50
    X-API-Key: {api_key}
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    response = requests.get(
        "https://api.audiopod.ai/api/v1/video/video-download/jobs",
        headers={"X-API-Key": api_key"},
        params={
            "status": "COMPLETED",     # Filter by status
            "platform": "youtube",     # Filter by platform
            "format": "mp3",          # Filter by format
            "limit": 50,
            "skip": 0
        }
    )

    if response.status_code == 200:
        jobs_data = response.json()
        for job in jobs_data["items"]:
            print(f"Job {job['id']}: {job['status']} - {job['original_title']}")
            print(f"  Platform: {job['platform']}, Format: {job['format']}")
            print(f"  Duration: {job['duration']}s, Size: {job['file_size']} bytes")
    ```
  </Tab>
</Tabs>

### Download Files

Download the extracted media files.

<Tabs>
  <Tab title="Python">
    ```python theme={null}
    def download_extracted_media(job_id, api_key, download_thumbnail=True):
        """Download extracted media and thumbnail from completed job"""
        
        # Get job details
        response = requests.get(
            f"https://api.audiopod.ai/api/v1/video/video-download/jobs/{job_id}",
            headers={"X-API-Key": api_key}
        )
        
        if response.status_code != 200:
            return {"error": "Job not found"}
        
        job = response.json()
        
        if job["status"] != "COMPLETED":
            return {"error": f"Job not completed. Status: {job['status']}"}
        
        downloaded_files = []
        
        # Download main media file
        if job.get("download_url"):
            media_response = requests.get(job["download_url"])
            if media_response.status_code == 200:
                # Use original title for filename, cleaned up
                title = job["original_title"].replace("/", "_").replace("\\", "_")
                extension = job["format"]
                filename = f"{title}_{job_id}.{extension}"
                
                with open(filename, "wb") as f:
                    f.write(media_response.content)
                
                downloaded_files.append({
                    "type": "media",
                    "filename": filename,
                    "size": len(media_response.content)
                })
        
        # Download thumbnail if available and requested
        if download_thumbnail and job.get("thumbnail_url"):
            thumb_response = requests.get(job["thumbnail_url"])
            if thumb_response.status_code == 200:
                thumb_filename = f"{title}_thumbnail_{job_id}.jpg"
                
                with open(thumb_filename, "wb") as f:
                    f.write(thumb_response.content)
                
                downloaded_files.append({
                    "type": "thumbnail",
                    "filename": thumb_filename,
                    "size": len(thumb_response.content)
                })
        
        return {
            "success": True,
            "job_id": job_id,
            "title": job["original_title"],
            "duration": job["duration"],
            "format": job["format"],
            "quality": job["quality"],
            "files": downloaded_files,
            "credits_used": job["credits_used"]
        }

    # Usage
    result = download_extracted_media(123, "your_api_key", download_thumbnail=True)
    if result.get("success"):
        print(f"Downloaded: {result['title']}")
        for file_info in result["files"]:
            print(f"  {file_info['type']}: {file_info['filename']} ({file_info['size']} bytes)")
    ```
  </Tab>
</Tabs>

## Job Management

### Update Download Job

Update job metadata such as custom title.

<Tabs>
  <Tab title="PUT">
    ```http theme={null}
    PUT /api/v1/video/video-download/jobs/{job_id}
    X-API-Key: {api_key}
    Content-Type: application/json

    {
      "title": "My Custom Video Title"
    }
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    job_id = 123
    update_data = {
        "title": "My Custom Video Title"
    }

    response = requests.put(
        f"https://api.audiopod.ai/api/v1/video/video-download/jobs/{job_id}",
        headers={"X-API-Key": api_key},
        json=update_data
    )

    if response.status_code == 200:
        updated_job = response.json()
        print(f"Updated job title: {updated_job['title']}")
    ```
  </Tab>
</Tabs>

### Delete Download Job

Remove a download job and its associated files.

<Tabs>
  <Tab title="DELETE">
    ```http theme={null}
    DELETE /api/v1/video/video-download/jobs/{job_id}
    X-API-Key: {api_key}
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    job_id = 123
    response = requests.delete(
        f"https://api.audiopod.ai/api/v1/video/video-download/jobs/{job_id}",
        headers={"X-API-Key": api_key}
    )

    if response.status_code == 200:
        result = response.json()
        print(result["message"])  # "Job deleted successfully"
    ```
  </Tab>
</Tabs>

### Get User Statistics

Get comprehensive download statistics for the authenticated user.

<Tabs>
  <Tab title="GET">
    ```http theme={null}
    GET /api/v1/video/video-download/stats
    X-API-Key: {api_key}
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    response = requests.get(
        "https://api.audiopod.ai/api/v1/video/video-download/stats",
        headers={"X-API-Key": api_key}
    )

    if response.status_code == 200:
        stats = response.json()
        print(f"Total downloads: {stats['total_downloads']}")
        print(f"Total duration: {stats['total_duration']} seconds")
        print(f"Credits used: {stats['total_credits_used']}")
        print(f"By platform: {stats['downloads_by_platform']}")
        print(f"By format: {stats['downloads_by_format']}")
    ```
  </Tab>
</Tabs>

**Response:**

```json theme={null}
{
  "total_downloads": 45,
  "total_duration": 12450.5,
  "total_credits_used": 1245,
  "downloads_by_platform": {
    "youtube": 25,
    "tiktok": 15,
    "instagram": 5
  },
  "downloads_by_format": {
    "mp3": 30,
    "mp4": 15
  },
  "recent_downloads": [
    {
      "id": 123,
      "title": "Recent Video",
      "platform": "youtube",
      "status": "COMPLETED",
      "created_at": "2024-01-15T10:30:00Z"
    }
  ]
}
```

## Platform Support

### Supported Platforms

| Platform   | Audio | Video | Playlists | Live Streams |
| ---------- | ----- | ----- | --------- | ------------ |
| YouTube    | ✅     | ✅     | ✅         | ✅            |
| TikTok     | ✅     | ✅     | ❌         | ❌            |
| Instagram  | ✅     | ✅     | ❌         | ❌            |
| Vimeo      | ✅     | ✅     | ✅         | ❌            |
| Twitter/X  | ✅     | ✅     | ❌         | ❌            |
| Facebook   | ✅     | ✅     | ❌         | ❌            |
| Spotify    | ✅     | ❌     | ✅         | ❌            |
| SoundCloud | ✅     | ❌     | ✅         | ❌            |

### Format Support

**Video Formats:**

* MP4 (H.264, H.265)
* WebM (VP8, VP9)
* MKV
* AVI
* MOV

**Audio Formats:**

* MP3 (various bitrates)
* WAV (uncompressed)
* AAC
* OGG
* FLAC (lossless)

**Quality Options:**

* **Video**: 144p, 240p, 360p, 480p, 720p, 1080p, 1440p, 2160p (4K)
* **Audio**: 64kbps, 128kbps, 192kbps, 256kbps, 320kbps

## Use Cases & Examples

### Podcast Content Creation

```python theme={null}
def extract_podcast_audio_from_videos(video_urls, api_key):
    """Extract high-quality audio from video content for podcast creation"""
    
    podcast_audios = []
    
    for url in video_urls:
        print(f"Extracting audio from: {url}")
        
        # Request high-quality audio extraction
        download_request = {
            "url": url,
            "audio_only": True,
            "format": "wav",        # High quality for editing
            "quality": "best",      # Best available audio quality
            "include_thumbnail": True  # For podcast artwork
        }
        
        response = requests.post(
            "https://api.audiopod.ai/api/v1/video/download",
            headers={"X-API-Key": api_key},
            json=download_request
        )
        
        if response.status_code == 200:
            job_data = response.json()
            podcast_audios.append({
                "url": url,
                "job_id": job_data["job"]["id"],
                "status": "processing"
            })
    
    # Monitor all extractions
    completed_audios = []
    
    while len(completed_audios) < len(podcast_audios):
        for audio_job in podcast_audios:
            if any(c["job_id"] == audio_job["job_id"] for c in completed_audios):
                continue
            
            status_response = requests.get(
                f"https://api.audiopod.ai/api/v1/video/video-download/jobs/{audio_job['job_id']}",
                headers={"X-API-Key": api_key}
            )
            
            job_status = status_response.json()
            
            if job_status["status"] == "COMPLETED":
                # Download the audio file
                audio_response = requests.get(job_status["download_url"])
                filename = f"podcast_audio_{audio_job['job_id']}.wav"
                
                with open(filename, "wb") as f:
                    f.write(audio_response.content)
                
                completed_audios.append({
                    "original_url": audio_job["url"],
                    "job_id": audio_job["job_id"],
                    "filename": filename,
                    "title": job_status["original_title"],
                    "duration": job_status["duration"],
                    "thumbnail_url": job_status.get("thumbnail_url")
                })
                
                print(f"Extracted: {filename}")
        
        time.sleep(5)
    
    return completed_audios

# Usage
video_urls = [
    "https://youtube.com/watch?v=interview1",
    "https://youtube.com/watch?v=interview2", 
    "https://youtube.com/watch?v=interview3"
]

podcast_content = extract_podcast_audio_from_videos(video_urls, "your_api_key")
print(f"Extracted {len(podcast_content)} audio files for podcast:")
for content in podcast_content:
    print(f"  {content['title']} - {content['filename']} ({content['duration']:.1f}s)")
```

### Educational Content Archive

```python theme={null}
def archive_educational_content(playlist_urls, api_key):
    """Download educational videos for offline access"""
    
    archived_content = {}
    
    for playlist_name, url in playlist_urls.items():
        print(f"Archiving {playlist_name}...")
        
        # Get video info first
        info_response = requests.post(
            "https://api.audiopod.ai/api/v1/video/info",
            headers={"X-API-Key": api_key},
            json={"url": url, "include_formats": True}
        )
        
        if info_response.status_code == 200:
            video_info = info_response.json()
            
            # Download in appropriate quality for education
            download_request = {
                "url": url,
                "format": "mp4",
                "quality": "720p",      # Good balance of quality/size
                "include_thumbnail": True,
                "output_filename": f"{playlist_name}_{video_info['video_id']}.mp4"
            }
            
            download_response = requests.post(
                "https://api.audiopod.ai/api/v1/video/download",
                headers={"X-API-Key": api_key},
                json=download_request
            )
            
            if download_response.status_code == 200:
                job_data = download_response.json()
                archived_content[playlist_name] = {
                    "job_id": job_data["job"]["id"],
                    "title": video_info["title"],
                    "duration": video_info["duration"],
                    "estimated_credits": job_data["estimated_credits"],
                    "status": "downloading"
                }
    
    return archived_content

# Usage for educational content
educational_playlists = {
    "math_basics": "https://youtube.com/watch?v=math_lesson_1",
    "science_intro": "https://youtube.com/watch?v=science_intro",
    "history_overview": "https://youtube.com/watch?v=history_basics"
}

archive = archive_educational_content(educational_playlists, "your_api_key")
print("Educational content archiving started:")
for subject, info in archive.items():
    print(f"  {subject}: {info['title']} ({info['duration']}s)")
```

### Social Media Content Analysis

```python theme={null}
def extract_social_media_content(social_urls, api_key):
    """Extract content from various social media platforms for analysis"""
    
    extracted_content = []
    
    for url in social_urls:
        # Detect platform
        platform = "unknown"
        if "tiktok.com" in url:
            platform = "tiktok"
        elif "instagram.com" in url:
            platform = "instagram" 
        elif "youtube.com" in url or "youtu.be" in url:
            platform = "youtube"
        elif "vimeo.com" in url:
            platform = "vimeo"
        
        print(f"Extracting from {platform}: {url}")
        
        # Platform-specific extraction settings
        if platform == "tiktok":
            # TikTok: usually short videos, extract both video and audio
            download_config = {
                "format": "mp4",
                "quality": "best",
                "audio_only": False,  # Keep video for visual analysis
                "include_thumbnail": True
            }
        elif platform == "instagram":
            # Instagram: stories, reels, posts
            download_config = {
                "format": "mp4", 
                "quality": "720p",
                "audio_only": True,   # Often interested in audio
                "include_thumbnail": True
            }
        else:
            # YouTube, Vimeo: longer content
            download_config = {
                "format": "mp3",         # Audio for analysis
                "quality": "320kbps",
                "audio_only": True,
                "include_thumbnail": True
            }
        
        download_config["url"] = url
        
        response = requests.post(
            "https://api.audiopod.ai/api/v1/video/download",
            headers={"X-API-Key": api_key},
            json=download_config
        )
        
        if response.status_code == 200:
            job_data = response.json()
            extracted_content.append({
                "platform": platform,
                "url": url,
                "job_id": job_data["job"]["id"],
                "config": download_config,
                "status": "processing"
            })
    
    return extracted_content

# Usage for social media analysis
social_urls = [
    "https://tiktok.com/@user/video/123",
    "https://instagram.com/p/ABC123/",
    "https://youtube.com/watch?v=analysis_video",
    "https://vimeo.com/123456789"
]

social_content = extract_social_media_content(social_urls, "your_api_key")
print(f"Extracting content from {len(social_content)} social media sources")
```

## Error Handling

<AccordionGroup>
  <Accordion title="400 Bad Request - Invalid URL">
    **Causes:** - URL format not supported - Private/restricted content - Invalid video ID
    **Solutions:** - Verify URL is publicly accessible - Check platform support - Ensure URL format is correct
  </Accordion>

  <Accordion title="403 Forbidden - Access Denied">
    **Causes:** - Content is private or restricted - Geographic restrictions - Platform blocking
    **Solutions:** - Use publicly accessible content - Check content availability in your region - Try different platform
  </Accordion>

  <Accordion title="404 Not Found - Content Not Available">
    **Causes:** - Video deleted or removed - Invalid video ID - Platform content policy violation
    **Solutions:** - Verify content still exists - Check for updated URL - Use alternative source
  </Accordion>

  <Accordion title="413 Payload Too Large - File Size Limit">
    **Causes:** - Video file too large for processing - Very long duration content
    **Solutions:** - Use lower quality settings - Extract audio only - Split long content
  </Accordion>

  <Accordion title="402 Payment Required - Insufficient Credits">
    **Causes:** - Not enough credits for download duration/quality
    **Solutions:** - Purchase additional credits - Use lower quality settings - Check credit requirements
  </Accordion>
</AccordionGroup>

## Supported Formats

### Get Public Supported Formats

Get formats available for public downloads (no authentication required).

<Tabs>
  <Tab title="GET">
    ```http theme={null}
    GET /api/v1/video/video-download/public/formats
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    response = requests.get(
        "https://api.audiopod.ai/api/v1/video/video-download/public/formats"
    )

    if response.status_code == 200:
        formats = response.json()
        print("Public formats available:")
        print(f"Video: {formats['video_formats']}")
        print(f"Audio: {formats['audio_formats']}")
        print(f"Limitations: {formats['limitations']}")
    ```
  </Tab>
</Tabs>

**Response:**

```json theme={null}
{
  "video_formats": ["mp4"],
  "audio_formats": ["mp3", "wav"],
  "quality_options": ["144p", "240p", "360p", "480p", "720p", "1080p", "1440p", "2160p", "best", "worst"],
  "supported_platforms": ["youtube", "tiktok", "instagram", "vimeo", "spotify", "twitter", "facebook", "twitch", "dailymotion", "other"],
  "limitations": {
    "max_duration_minutes": 10,
    "requires_authentication": false,
    "credit_cost": 0
  }
}
```

### Get Full Supported Formats

Get complete list of formats available for authenticated users.

<Tabs>
  <Tab title="GET">
    ```http theme={null}
    GET /api/v1/video/video-download/formats
    X-API-Key: {api_key}
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    response = requests.get(
        "https://api.audiopod.ai/api/v1/video/video-download/formats",
        headers={"X-API-Key": api_key}
    )

    if response.status_code == 200:
        formats = response.json()
        print("All formats available:")
        print(f"Video: {formats['video_formats']}")
        print(f"Audio: {formats['audio_formats']}")
        print(f"Quality: {formats['quality_options']}")
    ```
  </Tab>
</Tabs>

**Response:**

```json theme={null}
{
  "video_formats": ["mp4", "webm", "mkv", "flv", "avi", "mov"],
  "audio_formats": ["mp3", "wav", "aac", "m4a", "ogg", "opus"],
  "quality_options": ["144p", "240p", "360p", "480p", "720p", "1080p", "1440p", "2160p", "best", "worst"],
  "supported_platforms": ["youtube", "tiktok", "instagram", "vimeo", "spotify", "twitter", "facebook", "twitch", "dailymotion", "other"],
  "limitations": {
    "max_duration_minutes": null,
    "requires_authentication": true,
    "credit_cost": "Variable based on duration"
  }
}
```

## Best Practices

### Quality vs. File Size Optimization

```python theme={null}
# Quality recommendations by use case
quality_recommendations = {
    "podcast_audio": {
        "format": "wav",
        "quality": "320kbps",
        "audio_only": True,
        "reason": "High quality for editing and processing"
    },
    "social_media_analysis": {
        "format": "mp3", 
        "quality": "128kbps",
        "audio_only": True,
        "reason": "Sufficient quality, smaller file size"
    },
    "educational_archive": {
        "format": "mp4",
        "quality": "720p",
        "audio_only": False,
        "reason": "Good balance of quality and storage"
    },
    "professional_video": {
        "format": "mp4",
        "quality": "1080p",
        "audio_only": False,
        "reason": "High quality for professional use"
    }
}
```

### Batch Processing Strategy

```python theme={null}
def optimize_batch_downloads(urls, api_key, max_concurrent=5):
    """Optimize batch downloads with concurrency control"""
    
    import asyncio
    from concurrent.futures import ThreadPoolExecutor
    
    def process_single_download(url):
        download_request = {
            "url": url,
            "format": "mp3",
            "quality": "192kbps",
            "audio_only": True
        }
        
        response = requests.post(
            "https://api.audiopod.ai/api/v1/video/download",
            headers={"X-API-Key": api_key},
            json=download_request
        )
        
        return response.json() if response.status_code == 200 else None
    
    # Process in batches to avoid overwhelming the API
    batch_size = max_concurrent
    all_jobs = []
    
    for i in range(0, len(urls), batch_size):
        batch_urls = urls[i:i + batch_size]
        
        with ThreadPoolExecutor(max_workers=max_concurrent) as executor:
            batch_jobs = list(executor.map(process_single_download, batch_urls))
        
        all_jobs.extend([job for job in batch_jobs if job])
        
        # Brief pause between batches
        time.sleep(2)
    
    return all_jobs
```

## Pricing

Media extraction is billed by input duration. Two billing paths apply
depending on whether you authenticate with a JWT (subscription credits) or an
API key (API wallet, USD-denominated):

| Service                      | Account credits   | API wallet (USD) | Description                         |
| ---------------------------- | ----------------- | ---------------- | ----------------------------------- |
| Video Info                   | Free              | Free             | Get metadata without downloading    |
| Video Download (All Formats) | 33 credits/minute | \$0.01/minute    | Download audio/video in any quality |
| Thumbnail Extraction         | 1 credit          | n/a              | Download video thumbnail            |

### Cost Examples

| Duration   | Service    | Quality | Credits | API wallet (USD) |
| ---------- | ---------- | ------- | ------- | ---------------- |
| 5 minutes  | Audio Only | 320kbps | 165     | \$0.05           |
| 10 minutes | Video      | 720p    | 330     | \$0.10           |
| 30 minutes | Video      | 1080p   | 990     | \$0.30           |
| 2 hours    | Audio Only | 192kbps | 3,960   | \$1.20           |

### Cost Optimization Tips

1. **Extract audio only** when video is not needed
2. **Use appropriate quality** - don't download 4K for analysis
3. **Batch process** similar content for efficiency
4. **Get info first** to estimate costs before downloading

## Next Steps

<Columns cols={2}>
  <Card title="Speech-to-Text" icon="waveform" href="/api-reference/speech-to-text">
    Transcribe extracted audio content.
  </Card>

  <Card title="Speaker Separation" icon="users" href="/api-reference/speaker-separation">
    Separate speakers in extracted audio.
  </Card>
</Columns>
