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

# YouTube Videos & Reels API

> YouTube videos and Reels by search, channel URL or video URL, with views, likes, comments, duration, publish date, description, keywords and thumbnails.

`POST /v1/data/youtube/videos/run`

**Pricing:** $0.0005 per video ($0.5 per 1,000).

## Ways to call it

* **Search**: set `query` (optional: `maxResults`, `onlyVideosNewerThan`)
* **Channel**: set `channelUrl` (optional: `contentType`, `maxResults`, `onlyVideosNewerThan`)
* **Video URL**: set `urls`

## Request

Send the inputs under `params`. Only the keys below are accepted; any other key returns `422 invalid_params`.

**query** `string`

Keyword or phrase to search YouTube (e.g. 'python tutorial'). Returns ranked video results matching the query.

**channelUrl** `string`

YouTube channel URL (e.g. [https://www.youtube.com/@MrBeast](https://www.youtube.com/@MrBeast) or [https://www.youtube.com/channel/UC](https://www.youtube.com/channel/UC)...) or @handle. Returns all videos from the channel.

Format e.g. `https://www.youtube.com/@mrbeast`.

**contentType** `string` (default: videos)

Which part of the channel to pull (By Channel mode only): regular Videos or Shorts. Overrides any tab in the channel URL you paste.

Allowed values: `videos` (Videos), `shorts` (Shorts).

**urls** `string[]`

Direct YouTube video URLs (e.g. [https://www.youtube.com/watch?v=](https://www.youtube.com/watch?v=)...). One per line. Returns full metadata for each video.

**maxResults** `integer`

Total number of videos to return. Applies to Search and Channel modes.

**onlyVideosNewerThan** `date`

Only return videos published on or after this date (YYYY-MM-DD, or a full ISO timestamp). In Channel mode the filter is applied before any video is fetched, so a window with no new uploads returns no rows and costs nothing.

## Example

```bash cURL theme={null}
curl -X POST "https://api.mindcase.co/v1/data/youtube/videos/run?wait=true" \
  -H "Authorization: Bearer $MINDCASE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "params": {
    "urls": [
      "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
      "https://www.youtube.com/watch?v=hT_nvWreIhg",
      "https://www.youtube.com/watch?v=9bZkp7q19f0"
    ]
  }
}'
```

```python Python theme={null}
import os, requests

r = requests.post(
    "https://api.mindcase.co/v1/data/youtube/videos/run",
    params={"wait": "true"},
    headers={"Authorization": f"Bearer {os.environ['MINDCASE_API_KEY']}"},
    json={"params": {
    "urls": [
        "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
        "https://www.youtube.com/watch?v=hT_nvWreIhg",
        "https://www.youtube.com/watch?v=9bZkp7q19f0"
    ]
}},
)
job = r.json()
rows = job.get("data", [])  # if job["status"] == "running", poll /v1/jobs/{job_id}/results
```

```javascript Node.js theme={null}
const r = await fetch("https://api.mindcase.co/v1/data/youtube/videos/run?wait=true", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.MINDCASE_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ params: {
  "urls": [
    "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
    "https://www.youtube.com/watch?v=hT_nvWreIhg",
    "https://www.youtube.com/watch?v=9bZkp7q19f0"
  ]
} }),
});
const job = await r.json();
const rows = job.data ?? []; // if job.status === "running", poll /v1/jobs/{job_id}/results
```

## Response fields

Each row in `data` is one video, keyed by these fields.

| Field | Name | Type |
| - | - | - |
| `type` | Type | text |
| `title` | Title | text |
| `videoUrl` | Video URL | url |
| `views` | Views | number |
| `likes` | Likes | number |
| `comments` | Comments | number |
| `durationS` | Duration (s) | number |
| `published` | Published | text |
| `description` | Description | text |
| `keywords` | Keywords | array |
| `category` | Category | text |
| `availableCaptions` | Available Captions | object\_array |
| `isLive` | Is Live | boolean |
| `thumbnail` | Thumbnail | url |
| `channel` | Channel | text |
| `channelId` | Channel ID | text |
| `channelHandle` | Channel Handle | text |
| `subscribers` | Subscribers | text |
| `channelUrl` | Channel URL | url |
| `channelBadges` | Channel Badges | text |
| `channelAvatar` | Channel Avatar | image |

## Example response

Abridged: long text and lists are shortened.

```json theme={null}
{
  "job_id": "7f3a1c2e-0b9d-4c55-9a51-3f2e8d1b6a40",
  "agent": "youtube/videos",
  "status": "completed",
  "row_count": 1,
  "truncated": false,
  "data": [
    {
      "channelUrl": "https://www.youtube.com/channel/UCuudpdbKmQWq2PPzYgVCWlA",
      "videoUrl": "https://www.youtube.com/watch?v=fWjsdhR3z3c",
      "published": "2021-05-26T05:32:40-07:00",
      "channelBadges": [
        "Verified"
      ],
      "description": "In this crash course I'll be teaching you the basics of Python in less than 10 minutes. Python is super easy to learn compared to the other languages!\n\nDownl...",
      "availableCaptions": [
        {
          "language": "en",
          "name": "English (auto-generated)"
        }
      ],
      "likes": 35771,
      "category": "Education",
      "subscribers": "362K subscribers",
      "views": 1574874,
      "channelHandle": "@Indently",
      "comments": 899,
      "channel": "Indently",
      "title": "Learn Python in Less than 10 Minutes for Beginners (Fast & Easy)",
      "thumbnail": "https://i.ytimg.com/vi/fWjsdhR3z3c/maxresdefault.jpg",
      "channelAvatar": null,
      "isLive": false,
      "durationS": 630,
      "channelId": "UCuudpdbKmQWq2PPzYgVCWlA",
      "keywords": [
        "code palace",
        "cde palace"
      ],
      "type": "video"
    }
  ]
}
```

## Related APIs

For channel-level stats use [`youtube/channels`](https://docs.mindcase.co/apis/youtube/channels); for comments on a video use [`youtube/comments`](https://docs.mindcase.co/apis/youtube/comments).


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