# Search YouTube

> Search YouTube by keyword for videos, Shorts, channels and playlists, with date, length and type filters.

- **Request:** `GET https://api.lurkapi.com/v1/youtube/search`
- **Auth:** `x-api-key` header ([get a free key](https://lurkapi.com/login?next=/dashboard))
- **Cost:** 1 credit per call. Validation errors, `401`/`402`/`429` rejections and `5xx` failures are free; `not_found` is charged ([how charging works](https://lurkapi.com/docs.md#credits)).
- **MCP tool:** `youtube_search` on `https://api.lurkapi.com/mcp`
- **Freshness:** responses are cached for up to 15 minutes
- **Try it live:** https://lurkapi.com/docs/youtube/search#try (no signup)
- **Platform:** [YouTube](https://lurkapi.com/docs/youtube.md) (youtube.com)
- **Web page:** https://lurkapi.com/docs/youtube/search

## When to use this

Use it for trend, topic and competitor research: what YouTube's search page shows for a keyword, split into `videos`, `shorts`, `channels`, `playlists` and `lives` (streaming now). About 20 results per page. Narrow it with `type`, `uploadDate`, `duration` (videos only) and `sortBy=popular`.

Video results carry views as YouTube shows them, a description snippet and the channel. Counts may be rounded; video details returns exact views. Shorts carry title and views only; pass a Short's `url` to the video endpoint for the rest.

**Pagination.** Pass the response's `continuationToken` back as `continuationToken` (with the same query) for the next page; it's null on the last page.

## Parameters

All parameters go in the query string.

| Name | Type | Required | Default | Allowed values | Description | Example |
| --- | --- | --- | --- | --- | --- | --- |
| `query` | string | yes |  |  | Keywords, e.g. `running shoes`. YouTube's operators work, e.g. `intitle:"air max"`. | `running shoes` |
| `type` | string | no | `all` | `all`, `videos`, `shorts`, `channels`, `playlists` | What to search for. `all` mixes them like youtube.com. |  |
| `uploadDate` | string | no | `any` | `any`, `today`, `this_week`, `this_month`, `this_year` | Only results uploaded in this window. |  |
| `duration` | string | no | `any` | `any`, `under_3_min`, `between_3_and_20_min`, `over_20_min` | Video length. Doesn't apply to Shorts. |  |
| `sortBy` | string | no | `relevance` | `relevance`, `popular` | `relevance` (YouTube's default) or `popular` (most viewed first). |  |
| `continuationToken` | string | no |  |  | The `continuationToken` from the previous response, for the next page. |  |

## Example request

Replace `YOUR_API_KEY` with your key, or set `LURKAPI_KEY` for the code. [Get a free key](https://lurkapi.com/login?next=/dashboard).

curl:

```bash
curl "https://api.lurkapi.com/v1/youtube/search?query=running+shoes" \
  -H "x-api-key: YOUR_API_KEY"
```

JavaScript:

```js
const params = new URLSearchParams({
  query: "running shoes",
});
const res = await fetch(`https://api.lurkapi.com/v1/youtube/search?${params}`, {
  headers: { "x-api-key": process.env.LURKAPI_KEY },
});
const data = await res.json();
if (!data.success) throw new Error(`${data.code}: ${data.error}`);
console.log(data.videos);
```

Python:

```python
import os
import requests

res = requests.get(
    "https://api.lurkapi.com/v1/youtube/search",
    params={
        "query": "running shoes",
    },
    headers={"x-api-key": os.environ["LURKAPI_KEY"]},
    timeout=60,
)
data = res.json()
if not data["success"]:
    raise RuntimeError(f"{data['code']}: {data['error']}")
print(data["videos"])
```

## Example response

A real response from this endpoint, captured from the live API and trimmed to a couple of items. Strings over 96 characters (mostly signed media URLs) are cut short and end in `…`.

200 OK (application/json):

```json
{
  "success": true,
  "credits_remaining": 999992,
  "credits_charged": 1,
  "videos": [
    {
      "type": "video",
      "id": "z5mWgBMOFJk",
      "url": "https://www.youtube.com/watch?v=z5mWgBMOFJk",
      "title": "My Top 3 Running Shoes | Marathon Prep Training",
      "thumbnail": "https://i.ytimg.com/vi/z5mWgBMOFJk/hq720.jpg?sqp=-oaymwEcCNAFEJQDSFXyq4q…",
      "viewCountText": "682,786 views",
      "viewCountInt": 682786,
      "publishedTimeText": "6 years ago",
      "publishedTime": "2020-10-01T14:32:05.335Z",
      "lengthText": "17:18",
      "lengthSeconds": 1038,
      "badges": [],
      "description": "Subscribe: http://bit.ly/subNickBare Follow Nick Bare: Facebook: http://…",
      "channel": {
        "id": "UCbVEx9qG_hLrb6FrWQJz_Tg",
        "title": "Nick Bare",
        "handle": "nickbarefitness",
        "url": "https://www.youtube.com/@nickbarefitness",
        "thumbnail": "https://yt3.ggpht.com/ytc/AIdro_mVx6fQ8UNrMx2sjhQ5JwJyQTCfSXAoznqRdRSZLo…"
      }
    },
    {
      "type": "video",
      "id": "GDL5GVlpuko",
      "url": "https://www.youtube.com/watch?v=GDL5GVlpuko",
      "title": "My Complete Guide To Running Shoes! (Everything You Need To Know)",
      "thumbnail": "https://i.ytimg.com/vi/GDL5GVlpuko/hq720.jpg?sqp=-oaymwEcCNAFEJQDSFXyq4q…",
      "viewCountText": "282,242 views",
      "viewCountInt": 282242,
      "publishedTimeText": "10 months ago",
      "publishedTime": "2025-12-04T14:32:05.335Z",
      "lengthText": "20:25",
      "lengthSeconds": 1225,
      "badges": [
        "1 product",
        "4K"
      ],
      "description": "If you enjoyed the video, please like, comment and subscribe! Thank you …",
      "channel": {
        "id": "UCZPqG0yh_xPm2AyLjffbDvw",
        "title": "Ben Parkes",
        "handle": "BenParkes",
        "url": "https://www.youtube.com/@BenParkes",
        "thumbnail": "https://yt3.ggpht.com/ytc/AIdro_mDy4ZoQqcj7DiO_-1z6j2Y6Nu_PvFESGAsJagEM5…"
      }
    }
  ],
  "shorts": [
    {
      "type": "short",
      "id": "SVyIXZQABS8",
      "url": "https://www.youtube.com/shorts/SVyIXZQABS8",
      "title": "Which shoes to get for your Hyrox training? Boldfit Running Shoes",
      "thumbnail": "https://i.ytimg.com/vi/SVyIXZQABS8/oar2.jpg?sqp=-oaymwEgCJUDEOAESFWQAgHy…",
      "viewCountText": "44 views",
      "viewCountInt": 44
    },
    {
      "type": "short",
      "id": "rKuu1bK6qQY",
      "url": "https://www.youtube.com/shorts/rKuu1bK6qQY",
      "title": "Best Running Shoes for Long Runs 🏃",
      "thumbnail": "https://i.ytimg.com/vi/rKuu1bK6qQY/oar2.jpg?sqp=-oaymwEgCJUDEOAESFWQAgHy…",
      "viewCountText": "7M views",
      "viewCountInt": 7000000
    }
  ],
  "channels": [],
  "playlists": [],
  "lives": [],
  "continuationToken": "EugBEg1ydW5uaW5nIHNob2VzGtYBU0JTQ0FRdDZOVzFYWjBKTlQwWkthNElCQzBkRVREVkhW…"
}
```

## Response fields

Every field of a successful response. `[]` marks a list: `a[].b` is the `b` of each item in `a`. **nullable** fields can be `null`; **optional** fields can be missing.

| Field | Type | Description |
| --- | --- | --- |
| `success` | `true` | Always true here; errors have `success: false`. |
| `credits_remaining` | `number` | Your balance after this call. On anonymous playground calls: free tries left today. |
| `credits_charged` | `number` | Credits this call cost; 0 on free endpoints. On anonymous playground calls: tries used (1). |
| `videos` | `object[]` | Videos, in result order. |
| `videos[].type` | `"video"` | Always `video`. |
| `videos[].id` | `string` | Video id, e.g. `v9QtM6qnG50`. |
| `videos[].url` | `string` | Watch link. Pass it to the video endpoint for likes, comments, the full description and exact views. |
| `videos[].title` | `string` | Video title. |
| `videos[].thumbnail` | `string`, nullable | Largest thumbnail URL. |
| `videos[].viewCountText` | `string`, nullable | Views as YouTube shows them, e.g. "82M views", or "1,204 watching" while live. |
| `videos[].viewCountInt` | `number`, nullable | viewCountText as a number, rounded whenever YouTube abbreviates it (82M views → 82000000). Use video details for exact views. |
| `videos[].publishedTimeText` | `string`, nullable | When it went up, as YouTube shows it, e.g. "10 days ago". null for live and upcoming videos. |
| `videos[].publishedTime` | `string`, nullable | publishedTimeText as an estimated ISO 8601 time, counted back from when we fetched the page. Only as precise as the text: "1 year ago" means sometime that year. |
| `videos[].lengthText` | `string`, nullable | Length as shown, e.g. "19:03". null for live and upcoming videos. |
| `videos[].lengthSeconds` | `number`, nullable | Length in seconds. |
| `videos[].badges` | `string[]` | Labels YouTube shows on the result, e.g. "4K", "CC", "New" or "LIVE". Often empty. |
| `videos[].description` | `string`, nullable | The description snippet shown under the result, usually its first line or two. |
| `videos[].channel` | `object`, nullable | The channel behind it. |
| `videos[].channel.id` | `string`, nullable | Channel id, `UC…`. |
| `videos[].channel.title` | `string`, nullable | Channel name. |
| `videos[].channel.handle` | `string`, nullable | Handle without the @, e.g. `BenParkes`; null if YouTube shows none. |
| `videos[].channel.url` | `string`, nullable | Channel page, e.g. `https://www.youtube.com/@BenParkes`. |
| `videos[].channel.thumbnail` | `string`, nullable | Channel picture URL; null when the result doesn't show one. |
| `shorts` | `object[]` | Shorts, in result order. |
| `shorts[].type` | `"short"` | Always `short`. |
| `shorts[].id` | `string` | The Short's video id. |
| `shorts[].url` | `string` | `https://www.youtube.com/shorts/<id>`. Pass it to the video endpoint for likes, comments, date and length. |
| `shorts[].title` | `string` | The Short's title. |
| `shorts[].thumbnail` | `string`, nullable | Largest (vertical) thumbnail URL. |
| `shorts[].viewCountText` | `string`, nullable | Views as YouTube shows them, e.g. "22M views". |
| `shorts[].viewCountInt` | `number`, nullable | viewCountText as a number, rounded as shown (22M views → 22000000). |
| `channels` | `object[]` | Channels, in result order. |
| `channels[].type` | `"channel"` | Always `channel`. |
| `channels[].id` | `string` | Channel id, `UC…`. Pass it to channel details for the full stats. |
| `channels[].url` | `string` | Channel page. |
| `channels[].title` | `string` | Channel name. |
| `channels[].handle` | `string`, nullable | Handle without the @; null if YouTube shows none. |
| `channels[].thumbnail` | `string`, nullable | Channel picture URL. |
| `channels[].description` | `string`, nullable | The description snippet shown in the result. |
| `channels[].subscriberCountText` | `string`, nullable | Subscribers as YouTube shows them, e.g. "128K subscribers". |
| `channels[].subscriberCount` | `number`, nullable | subscriberCountText as a number, rounded as shown. |
| `channels[].isVerified` | `boolean` | Has YouTube's verified or official artist badge. |
| `playlists` | `object[]` | Playlists and mixes, in result order. |
| `playlists[].type` | `"playlist"` | Always `playlist`. |
| `playlists[].id` | `string` | Playlist id, e.g. `PLB50X6wE7gSWNQJElg3NX4AH42QoouHOk` (mixes start with `RD`). |
| `playlists[].url` | `string` | Playlist page, `https://www.youtube.com/playlist?list=<id>`. |
| `playlists[].title` | `string` | Playlist title. |
| `playlists[].thumbnail` | `string`, nullable | Cover thumbnail URL (its first video). |
| `playlists[].videoCountText` | `string`, nullable | Size as YouTube shows it, e.g. "30 videos". |
| `playlists[].videoCount` | `number`, nullable | videoCountText as a number. |
| `playlists[].channel` | `object`, nullable | The channel behind it. |
| `playlists[].channel.id` | `string`, nullable | Channel id, `UC…`. |
| `playlists[].channel.title` | `string`, nullable | Channel name. |
| `playlists[].channel.handle` | `string`, nullable | Handle without the @, e.g. `BenParkes`; null if YouTube shows none. |
| `playlists[].channel.url` | `string`, nullable | Channel page, e.g. `https://www.youtube.com/@BenParkes`. |
| `playlists[].channel.thumbnail` | `string`, nullable | Channel picture URL; null when the result doesn't show one. |
| `lives` | `object[]` | Streams that are live right now. |
| `lives[].type` | `"video"` | Always `video`. |
| `lives[].id` | `string` | Video id, e.g. `v9QtM6qnG50`. |
| `lives[].url` | `string` | Watch link. Pass it to the video endpoint for likes, comments, the full description and exact views. |
| `lives[].title` | `string` | Video title. |
| `lives[].thumbnail` | `string`, nullable | Largest thumbnail URL. |
| `lives[].viewCountText` | `string`, nullable | Views as YouTube shows them, e.g. "82M views", or "1,204 watching" while live. |
| `lives[].viewCountInt` | `number`, nullable | viewCountText as a number, rounded whenever YouTube abbreviates it (82M views → 82000000). Use video details for exact views. |
| `lives[].publishedTimeText` | `string`, nullable | When it went up, as YouTube shows it, e.g. "10 days ago". null for live and upcoming videos. |
| `lives[].publishedTime` | `string`, nullable | publishedTimeText as an estimated ISO 8601 time, counted back from when we fetched the page. Only as precise as the text: "1 year ago" means sometime that year. |
| `lives[].lengthText` | `string`, nullable | Length as shown, e.g. "19:03". null for live and upcoming videos. |
| `lives[].lengthSeconds` | `number`, nullable | Length in seconds. |
| `lives[].badges` | `string[]` | Labels YouTube shows on the result, e.g. "4K", "CC", "New" or "LIVE". Often empty. |
| `lives[].description` | `string`, nullable | The description snippet shown under the result, usually its first line or two. |
| `lives[].channel` | `object`, nullable | The channel behind it. |
| `lives[].channel.id` | `string`, nullable | Channel id, `UC…`. |
| `lives[].channel.title` | `string`, nullable | Channel name. |
| `lives[].channel.handle` | `string`, nullable | Handle without the @, e.g. `BenParkes`; null if YouTube shows none. |
| `lives[].channel.url` | `string`, nullable | Channel page, e.g. `https://www.youtube.com/@BenParkes`. |
| `lives[].channel.thumbnail` | `string`, nullable | Channel picture URL; null when the result doesn't show one. |
| `continuationToken` | `string`, nullable | Pass as `continuationToken` for the next page. null on the last page. |

## Caching and freshness

Responses are cached for up to 15 minutes, so a repeat call within that window can return the same data. It still costs 1 credit.

## Errors

Errors return `{ success: false, error, code, docs }` with the HTTP status below. Validation errors, `401`/`402`/`429` rejections and `5xx` failures are free; `not_found` is charged ([how charging works](https://lurkapi.com/docs.md#credits)). [All error codes](https://lurkapi.com/docs.md#errors).

| Status | Code | Meaning |
| --- | --- | --- |
| 401 | `missing_api_key` | No API key. Send it in the `x-api-key` header. |
| 401 | `invalid_api_key` | The key is unknown or was revoked. |
| 402 | `insufficient_credits` | Not enough credits for this call. Buy a pack or wait for tomorrow's top-up. |
| 405 | `method_not_allowed` | Endpoints take GET with query params. |
| 429 | `rate_limited` | Too many calls at once. Wait for the `retry-after` seconds, then retry. |
| 500 | `internal_error` | Something broke on our side. Retry; 5xx errors are free. |
| 502 | `upstream_error` | The platform didn't give a usable answer. Retry; 5xx errors are free. |
| 503 | `upstream_busy` | All our connections to the platform are busy. Retry in a few seconds; 5xx errors are free. |
| 504 | `upstream_timeout` | The platform took over 30 seconds to answer. Retry; timeouts are free. |

## Use it in Claude

Once LurkAPI is [connected to Claude](https://lurkapi.com/docs.md#claude), this endpoint is the `youtube_search` tool. Ask in plain English, for example:

Ask Claude:

```text
Use LurkAPI's youtube_search with query "running shoes" and summarize what you find.
```

Claude calls `youtube_search` with arguments like these, and each call costs 1 credit:

Tool arguments:

```json
{
  "query": "running shoes"
}
```

Tool results skip nulls and empty lists to save tokens.

---

Previous: [Channel Shorts](https://lurkapi.com/docs/youtube/channel-shorts.md) · Next: [Profile](https://lurkapi.com/docs/tiktok/profile.md)
