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

# YouTube

> Fetch YouTube channel profiles and recent video uploads.

# YouTube

**Base URL:** `https://drain.lat/api/v1/youtube`

<AccordionGroup>
  <Accordion title="GET /profile/:handle" icon="user">
    Fetch a YouTube channel profile. Handle can be with or without `@`.

    ```
    GET /api/v1/youtube/profile/:handle
    ```

    <ParamField path="handle" type="string" required>
      YouTube channel handle. Both `MrBeast` and `@MrBeast` are valid.
    </ParamField>

    <CodeGroup>
      ```bash cURL theme={null}
      curl "https://drain.lat/api/v1/youtube/profile/MrBeast" \
        -H "x-api-key: YOUR_API_KEY"
      ```

      ```javascript JavaScript theme={null}
      const res = await fetch("https://drain.lat/api/v1/youtube/profile/MrBeast", {
        headers: { "x-api-key": "YOUR_API_KEY" }
      });
      const data = await res.json();
      ```

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

      res = requests.get(
          "https://drain.lat/api/v1/youtube/profile/MrBeast",
          headers={"x-api-key": "YOUR_API_KEY"}
      )
      print(res.json())
      ```
    </CodeGroup>

    <ResponseField name="id" type="string">YouTube channel ID.</ResponseField>
    <ResponseField name="username" type="string">Channel handle (with @).</ResponseField>
    <ResponseField name="displayName" type="string">Channel display name.</ResponseField>
    <ResponseField name="description" type="string">Channel description.</ResponseField>
    <ResponseField name="avatarUrl" type="string">Channel avatar URL.</ResponseField>
    <ResponseField name="country" type="string">Country code.</ResponseField>
    <ResponseField name="created" type="string">Channel creation date (ISO 8601).</ResponseField>
    <ResponseField name="subscribers" type="number">Subscriber count.</ResponseField>
    <ResponseField name="totalViews" type="number">Total view count.</ResponseField>
    <ResponseField name="videoCount" type="number">Total number of videos.</ResponseField>
    <ResponseField name="profileUrl" type="string">Link to the YouTube channel.</ResponseField>

    ```json Response theme={null}
    {
      "id": "UCX6OQ3DkcsbYNE6H8uQQuVA",
      "username": "@MrBeast",
      "displayName": "MrBeast",
      "description": "SUBSCRIBE FOR A COOKIE",
      "avatarUrl": "https://yt3.googleusercontent.com/...",
      "country": "US",
      "created": "2012-02-19T21:23:10Z",
      "subscribers": 340000000,
      "totalViews": 65000000000,
      "videoCount": 812,
      "profileUrl": "https://www.youtube.com/@MrBeast",
      "scrapedAt": "2026-05-05T12:00:00.000Z"
    }
    ```
  </Accordion>

  <Accordion title="GET /profile/:handle/videos" icon="film">
    Get the last 10 uploaded videos from a YouTube channel.

    ```
    GET /api/v1/youtube/profile/:handle/videos
    ```

    <ParamField path="handle" type="string" required>
      YouTube channel handle.
    </ParamField>

    <CodeGroup>
      ```bash cURL theme={null}
      curl "https://drain.lat/api/v1/youtube/profile/MrBeast/videos" \
        -H "x-api-key: YOUR_API_KEY"
      ```

      ```javascript JavaScript theme={null}
      const res = await fetch("https://drain.lat/api/v1/youtube/profile/MrBeast/videos", {
        headers: { "x-api-key": "YOUR_API_KEY" }
      });
      const data = await res.json();
      ```

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

      res = requests.get(
          "https://drain.lat/api/v1/youtube/profile/MrBeast/videos",
          headers={"x-api-key": "YOUR_API_KEY"}
      )
      print(res.json())
      ```
    </CodeGroup>

    <ResponseField name="handle" type="string">Channel handle.</ResponseField>

    <ResponseField name="videos" type="array">
      <Expandable title="video object">
        <ResponseField name="id" type="string">Video ID.</ResponseField>
        <ResponseField name="title" type="string">Video title.</ResponseField>
        <ResponseField name="description" type="string">Video description.</ResponseField>
        <ResponseField name="thumbnailUrl" type="string">Thumbnail image URL.</ResponseField>
        <ResponseField name="publishedAt" type="string">Publish date (ISO 8601).</ResponseField>
        <ResponseField name="url" type="string">Link to the video.</ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="total" type="number">Number of videos returned.</ResponseField>

    ```json Response theme={null}
    {
      "handle": "MrBeast",
      "videos": [
        {
          "id": "dQw4w9WgXcQ",
          "title": "I Spent 7 Days Buried Alive",
          "description": "This was insane...",
          "thumbnailUrl": "https://i.ytimg.com/vi/dQw4w9WgXcQ/hqdefault.jpg",
          "publishedAt": "2026-04-15T18:00:00Z",
          "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
        }
      ],
      "total": 10,
      "scrapedAt": "2026-05-05T12:00:00.000Z"
    }
    ```
  </Accordion>

  <Accordion title="GET /channel/:channelId" icon="id-card">
    Fetch a YouTube channel by raw channel ID.

    ```
    GET /api/v1/youtube/channel/:channelId
    ```

    <ParamField path="channelId" type="string" required>
      The YouTube channel ID (starts with `UC`).
    </ParamField>

    <CodeGroup>
      ```bash cURL theme={null}
      curl "https://drain.lat/api/v1/youtube/channel/UCBcRF18a7Qf58cCRy5xuWwQ" \
        -H "x-api-key: YOUR_API_KEY"
      ```

      ```javascript JavaScript theme={null}
      const res = await fetch("https://drain.lat/api/v1/youtube/channel/UCBcRF18a7Qf58cCRy5xuWwQ", {
        headers: { "x-api-key": "YOUR_API_KEY" }
      });
      const data = await res.json();
      ```

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

      res = requests.get(
          "https://drain.lat/api/v1/youtube/channel/UCBcRF18a7Qf58cCRy5xuWwQ",
          headers={"x-api-key": "YOUR_API_KEY"}
      )
      print(res.json())
      ```
    </CodeGroup>

    <ResponseField name="id" type="string">Channel ID.</ResponseField>
    <ResponseField name="username" type="string">Channel handle (with @).</ResponseField>
    <ResponseField name="displayName" type="string">Channel display name.</ResponseField>
    <ResponseField name="description" type="string">Channel description.</ResponseField>
    <ResponseField name="avatarUrl" type="string">Channel avatar URL.</ResponseField>
    <ResponseField name="bannerUrl" type="string">Channel banner image URL.</ResponseField>
    <ResponseField name="country" type="string">Country code.</ResponseField>
    <ResponseField name="created" type="string">Channel creation date (ISO 8601).</ResponseField>
    <ResponseField name="subscribers" type="number">Subscriber count.</ResponseField>
    <ResponseField name="totalViews" type="number">Total view count.</ResponseField>
    <ResponseField name="videoCount" type="number">Total number of videos.</ResponseField>
    <ResponseField name="profileUrl" type="string">Link to the YouTube channel.</ResponseField>

    ```json Response theme={null}
    {
      "id": "UCxxxxxx",
      "username": "@mkbhd",
      "displayName": "Marques Brownlee",
      "description": "Quality Tech Videos.",
      "avatarUrl": "https://...",
      "bannerUrl": "https://yt3.googleusercontent.com/banner/...",
      "country": "US",
      "created": "2009-03-21T00:00:00.000Z",
      "subscribers": 18500000,
      "totalViews": 4200000000,
      "videoCount": 1600,
      "profileUrl": "https://www.youtube.com/@mkbhd",
      "scrapedAt": "2026-05-08T10:00:00.000Z"
    }
    ```
  </Accordion>

  <Accordion title="GET /video/:videoId" icon="circle-play">
    Get stats and metadata for a single YouTube video.

    ```
    GET /api/v1/youtube/video/:videoId
    ```

    <ParamField path="videoId" type="string" required>
      The YouTube video ID (e.g. `dQw4w9WgXcQ`).
    </ParamField>

    <CodeGroup>
      ```bash cURL theme={null}
      curl "https://drain.lat/api/v1/youtube/video/dQw4w9WgXcQ" \
        -H "x-api-key: YOUR_API_KEY"
      ```

      ```javascript JavaScript theme={null}
      const res = await fetch("https://drain.lat/api/v1/youtube/video/dQw4w9WgXcQ", {
        headers: { "x-api-key": "YOUR_API_KEY" }
      });
      const data = await res.json();
      ```

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

      res = requests.get(
          "https://drain.lat/api/v1/youtube/video/dQw4w9WgXcQ",
          headers={"x-api-key": "YOUR_API_KEY"}
      )
      print(res.json())
      ```
    </CodeGroup>

    <ResponseField name="id" type="string">Video ID.</ResponseField>
    <ResponseField name="title" type="string">Video title.</ResponseField>
    <ResponseField name="description" type="string">Video description.</ResponseField>
    <ResponseField name="channelId" type="string">Channel ID.</ResponseField>
    <ResponseField name="channelTitle" type="string">Channel name.</ResponseField>
    <ResponseField name="publishedAt" type="string">Publish date (ISO 8601).</ResponseField>
    <ResponseField name="thumbnailUrl" type="string">Thumbnail image URL.</ResponseField>
    <ResponseField name="tags" type="string[]">List of tags.</ResponseField>
    <ResponseField name="duration" type="string">Duration in ISO 8601 format (e.g. `PT3M33S`).</ResponseField>
    <ResponseField name="views" type="number">View count.</ResponseField>
    <ResponseField name="likes" type="number">Like count.</ResponseField>
    <ResponseField name="comments" type="number">Comment count.</ResponseField>
    <ResponseField name="url" type="string">Link to the video.</ResponseField>

    ```json Response theme={null}
    {
      "id": "dQw4w9WgXcQ",
      "title": "Rick Astley - Never Gonna Give You Up",
      "description": "The official video...",
      "channelId": "UCxxxxxx",
      "channelTitle": "Rick Astley",
      "publishedAt": "2009-10-25T06:57:33.000Z",
      "thumbnailUrl": "https://...",
      "tags": ["rick astley", "pop"],
      "duration": "PT3M33S",
      "views": 1400000000,
      "likes": 16000000,
      "comments": 2400000,
      "url": "https://www.youtube.com/watch?v=dQw4w9WgXcQ",
      "scrapedAt": "2026-05-08T10:00:00.000Z"
    }
    ```
  </Accordion>

  <Accordion title="GET /search" icon="magnifying-glass">
    Search YouTube videos.

    ```
    GET /api/v1/youtube/search
    ```

    <ParamField query="q" type="string" required>
      Search query.
    </ParamField>

    <ParamField query="limit" type="number">
      Number of results. Max `25`. Default `10`.
    </ParamField>

    <CodeGroup>
      ```bash cURL theme={null}
      curl "https://drain.lat/api/v1/youtube/search?q=linux+tutorial&limit=10" \
        -H "x-api-key: YOUR_API_KEY"
      ```

      ```javascript JavaScript theme={null}
      const res = await fetch("https://drain.lat/api/v1/youtube/search?q=linux+tutorial&limit=10", {
        headers: { "x-api-key": "YOUR_API_KEY" }
      });
      const data = await res.json();
      ```

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

      res = requests.get(
          "https://drain.lat/api/v1/youtube/search",
          params={"q": "linux tutorial", "limit": 10},
          headers={"x-api-key": "YOUR_API_KEY"}
      )
      print(res.json())
      ```
    </CodeGroup>

    <ResponseField name="query" type="string">The search query used.</ResponseField>

    <ResponseField name="videos" type="array">
      <Expandable title="video object">
        <ResponseField name="id" type="string">Video ID.</ResponseField>
        <ResponseField name="title" type="string">Video title.</ResponseField>
        <ResponseField name="description" type="string">Video description snippet.</ResponseField>
        <ResponseField name="channelId" type="string">Channel ID.</ResponseField>
        <ResponseField name="channelTitle" type="string">Channel name.</ResponseField>
        <ResponseField name="publishedAt" type="string">Publish date (ISO 8601).</ResponseField>
        <ResponseField name="thumbnailUrl" type="string">Thumbnail image URL.</ResponseField>
        <ResponseField name="url" type="string">Link to the video.</ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="total" type="number">Number of results returned.</ResponseField>

    ```json Response theme={null}
    {
      "query": "linux tutorial",
      "videos": [
        {
          "id": "abc123",
          "title": "Linux for Beginners",
          "description": "Learn Linux...",
          "channelId": "UCxxxxxx",
          "channelTitle": "TechChannel",
          "publishedAt": "2026-01-01T00:00:00.000Z",
          "thumbnailUrl": "https://...",
          "url": "https://www.youtube.com/watch?v=abc123"
        }
      ],
      "total": 10,
      "scrapedAt": "2026-05-08T10:00:00.000Z"
    }
    ```
  </Accordion>
</AccordionGroup>
