# YouTube Search

Extract YouTube search results for a query, returning the ranked SERP a buyer sees: rank, result type, title, link, channel, views, duration, published date, and thumbnail across videos, channels, and playlists.

**Pricing:** $0.25 / 1k results

**Endpoint:** `POST /api/v1/agents/youtube/search/run`

**Auth:** `Authorization: Bearer mk_live_...`

## Parameters

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `query` | string | Yes | The YouTube keywords to search for. Use specific, multi-word queries — generic single-word queries can return no results. |
| `type` | string | No | Filter by content type (videos, channels, playlists). |
| `maxResults` | integer | No | Total results to fetch. Use 0 for all (minimum: 20). |
| `sortBy` | string | No | Sort order for the results. Relevance by default; Popularity sorts by view count. Note: sorting is not available for Shorts. |
| `duration` | string | No | Filter by video length. |
| `uploadDate` | string | No | Restrict results to a recent time range. |
| `country` | string | No | Country to search YouTube from. |
| `language` | string | No | Language for results. |

## Example

```bash
curl -X POST https://api.mindcase.co/api/v1/agents/youtube/search/run \
  -H "Authorization: Bearer mk_live_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"params":{"query":"..."}}'
```

```python
import requests

resp = requests.post(
    "https://api.mindcase.co/api/v1/agents/youtube/search/run",
    headers={"Authorization": "Bearer mk_live_YOUR_API_KEY"},
    json={"params": {
    "query": "..."
}},
)
data = resp.json()
```

## Get the results

`run` is async and returns a `job_id`. Poll until `status` is `completed`, then read the rows:

```bash
# 1) check status
curl https://api.mindcase.co/api/v1/jobs/JOB_ID \
  -H "Authorization: Bearer mk_live_YOUR_API_KEY"

# 2) when status == completed, fetch the rows
curl https://api.mindcase.co/api/v1/jobs/JOB_ID/results \
  -H "Authorization: Bearer mk_live_YOUR_API_KEY"
```

Full API reference (auth, jobs, balance, endpoints): https://mindcase.co/skills.md

## Response columns

| Field | Display name | Type |
|-------|--------------|------|
| `rank` | Rank | number |
| `resultType` | Result Type | text |
| `title` | Title | text |
| `url` | URL | url |
| `channel` | Channel | text |
| `channelHandle` | Channel Handle | text |
| `channelUrl` | Channel URL | url |
| `views` | Views | number |
| `durationSeconds` | Duration Seconds | number |
| `publishedAt` | Published At | text |
| `description` | Description | text |
| `category` | Category | text |
| `keywords` | Keywords | array |
| `language` | Language | text |
| `videoCount` | Video Count | number |
| `subscribers` | Subscribers | number |
| `thumbnail` | Thumbnail | url |
