YouTube Comments API Documentation

The YouTube Comments API provides developers with access to comments data from YouTube videos. It enables the retrieval of comments, including their text, likes, author details, and more, using the /api/v1/comments?engine=youtube_comments endpoint.

API Parameters

Search Query

  • Name
    video_id
    Required
    Required
    Description

    The unique identifier for a YouTube video. Find it in the video's URL, e.g., https://www.youtube.com/watch?v=video_id, or through our YouTube Search API.

Localization

  • Name
    gl
    Required
    Optional
    Description

    The default parameter us defines the country of the search. Check the full list of supported YouTube gl countries.

  • Name
    hl
    Required
    Optional
    Description

    The default parameter en defines the interface language of the search. Check the full list of supported YouTube hl languages.

Pagination

  • Name
    next_page_token
    Required
    Optional
    Description

    This token is used to retrieve the next page of comments or replies. When using the YouTube Comments API, use the next_page_token or replies_next_page_token provided in the previous response to load subsequent pages.

    For users of the YouTube Video API, comments_sorting_token can also facilitate pagination by fetching additional comment pages. Ensure the appropriate token is used based on the data context and API being accessed.

Engine

  • Name
    engine
    Required
    Required
    Description

    Specifies the engine to use for fetching data. For accessing YouTube comment data, set this to youtube_comments.

API key

  • Name
    api_key
    Required
    Required
    Description

    The api_key authenticates your requests. Use it as a query parameter (https://www.searchapi.io/api/v1/search?api_key=YOUR_API_KEY) or in the Authorization header (Bearer YOUR_API_KEY).

API Examples

Full Response

Full Response

Use the next_page_token provided in the response to fetch additional comments beyond the initial page.

GET
https://www.searchapi.io/api/v1/search?engine=youtube_comments&video_id=jvqFAi7vkBc
Request
import requests

url = "https://www.searchapi.io/api/v1/search"
params = {
  "engine": "youtube_comments",
  "video_id": "jvqFAi7vkBc"
}

response = requests.get(url, params = params)
print(response.text)
Response
{
  "search_metadata": {
    "id": "search_xPRye85MgqZ7cYYxoKadz2Q7",
    "status": "Success",
    "created_at": "2024-04-03T15:22:44Z",
    "request_time_taken": 2.65,
    "parsing_time_taken": 0.01,
    "total_time_taken": 2.66,
    "request_url": "https://www.youtube.com/watch?v=jvqFAi7vkBc",
    "html_url": "https://www.searchapi.io/api/v1/searches/search_xPRye85MgqZ7cYYxoKadz2Q7.html",
    "json_url": "https://www.searchapi.io/api/v1/searches/search_xPRye85MgqZ7cYYxoKadz2Q7"
  },
  "search_parameters": {
    "engine": "youtube_comments",
    "video_id": "jvqFAi7vkBc",
    "gl": "US",
    "hl": "en"
  },
  "comments": [
    {
      "id": "UgxyqfPGujI6Y5C0aRd4AaABAg",
      "link": "https://www.youtube.com/watch?v=jvqFAi7vkBc&lc=UgxyqfPGujI6Y5C0aRd4AaABAg",
      "channel": {
        "handle": "@lexfridman",
        "id": "UCSHZKyawb77ixDdsGog4iWA",
        "link": "https://www.youtube.com/@lexfridman",
        "thumbnail": "https://yt3.ggpht.com/ytc/AIdro_ltRkxKUsVCeSSe9xtBLOP5M2QpX4wTpa5Guy2sgW0=s176-c-k-c0x00ffffff-no-rj"
      },
      "text": "Here are the timestamps. Please check out our sponsors to support this podcast.\r \n Transcript:  https://lexfridman.com/sam-altman-2-transcript\r \n 0:00  - Introduction & sponsor mentions:\r \n - Cloaked:  https://cloaked.com/lex  and use code LexPod to get 25% off\r \n - Shopify:  https://shopify.com/lex  to get $1 per month trial\r \n - BetterHelp:  https://betterhelp.com/lex  to get 10% off\r \n - ExpressVPN:  https://expressvpn.com/lexpod  to get 3 months free\r \n 1:05  - OpenAI board saga\r \n 18:31  - Ilya Sutskever\r \n 24:40  - Elon Musk lawsuit\r \n 34:32  - Sora\r \n 44:23  - GPT-4\r \n 55:32  - Memory & privacy\r \n 1:02:36  - Q*\r \n 1:06:12  - GPT-5\r \n 1:09:27  - $7 trillion of compute\r \n 1:17:35  - Google and Gemini\r \n 1:28:40  - Leap to GPT-5\r \n 1:32:24  - AGI\r \n 1:50:57  - Aliens",
      "likes": 399,
      "replies": 69,
      "replies_next_page_token": "Eg0SC2p2cUZBaTd2a0JjGAYygwEaUBIaVWd4eXFmUEd1akk2WTVDMGFSZDRBYUFCQWciAggAKhhVQ1NIWkt5YXdiNzdpeERkc0dvZzRpV0EyC2p2cUZBaTd2a0JjQAFICoIBAggBQi9jb21tZW50LXJlcGxpZXMtaXRlbS1VZ3h5cWZQR3VqSTZZNUMwYVJkNEFhQUJBZw%3D%3D"
    },
    ...
  ],
  "pagination": {
    "next_page_token": "Eg0SC2p2cUZBaTd2a0JjGAYy5AIKugJnZXRfcmFua2VkX3N0cmVhbXMtLUNxY0JDSUFFRlJlMzBUZ2FuQUVLbHdFSTJGOFFnQVFZQnlLTUFYdVNGSXFZS2lnZFFfUnladFgwQU1NVFprU191NTBUa2RIRXRCSnFEWk5kZFYyM0lWQ1pKQVdDVU9kQi1PZm1RVFAxYi15S3R6R09hYUdwR0xWM25qa1BFakRzUkVRZGhQRXUtRDZRZ2pWOFI2WEx6MHFZNDhzQ0t5S01UeVUxMzhEQjE1Qm9Zd2xmWGNkRFdXRHpaTENNTi01dC1Ub0d6NUZ4WjFvY2I4UVpHTkVGdGNmY0V3YktXLWdCRUJRU0JRaUlJQmdBRWdjSWhDQVFFaGdCRWdjSWh5QVFBUmdBRWdVSWlTQVlBQklIQ0lVZ0VBa1lBUklGQ0tnZ0dBQVlBQSIRIgtqdnFGQWk3dmtCYzAAeAEoFEIQY29tbWVudHMtc2VjdGlvbg%3D%3D"
  }
}

Replies

Replies

Pass the replies_next_page_token as the value for the next_page_token parameter to retrieve additional replies to a comment.

GET
https://www.searchapi.io/api/v1/search?engine=youtube_comments&next_page_token=Eg0SC2p2cUZBaTd2a0JjGAYygwEaUBIaVWd4eXFmUEd1akk2WTVDMGFSZDRBYUFCQWciAggAKhhVQ1NIWkt5YXdiNzdpeERkc0dvZzRpV0EyC2p2cUZBaTd2a0JjQAFICoIBAggBQi9jb21tZW50LXJlcGxpZXMtaXRlbS1VZ3h5cWZQR3VqSTZZNUMwYVJkNEFhQUJBZw%3D%3D&video_id=jvqFAi7vkBc
Request
import requests

url = "https://www.searchapi.io/api/v1/search"
params = {
  "engine": "youtube_comments",
  "video_id": "jvqFAi7vkBc",
  "next_page_token": "Eg0SC2p2cUZBaTd2a0JjGAYygwEaUBIaVWd4eXFmUEd1akk2WTVDMGFSZDRBYUFCQWciAggAKhhVQ1NIWkt5YXdiNzdpeERkc0dvZzRpV0EyC2p2cUZBaTd2a0JjQAFICoIBAggBQi9jb21tZW50LXJlcGxpZXMtaXRlbS1VZ3h5cWZQR3VqSTZZNUMwYVJkNEFhQUJBZw=="
}

response = requests.get(url, params = params)
print(response.text)
Response
{
  "comments": [
    {
      "id": "UgxyqfPGujI6Y5C0aRd4AaABAg.A17iJ4JAk2FA17kRoZfCgz",
      "link": "https://www.youtube.com/watch?v=jvqFAi7vkBc&lc=UgxyqfPGujI6Y5C0aRd4AaABAg.A17iJ4JAk2FA17kRoZfCgz",
      "channel": {
        "id": "UC3oeuBp3eeNo5bOUxF7H5uA",
        "handle": "@TheImprovNinjas",
        "link": "https://www.youtube.com/@TheImprovNinjas",
        "thumbnail": "https://yt3.ggpht.com/PV8QEc2M_-q1MfExysbcbL3uBNJhSDic7wugj_V_FihetpBiycLz5APke1vsNwhGJEgksgtNmm4=s88-c-k-c0x00ffffff-no-rj"
      },
      "published_date": "2 weeks ago",
      "text": "💗",
      "likes": 3
    },
    ...
  ],
  "pagination": {
    "replies_next_page_token": "Eg0SC2p2cUZBaTd2a0JjGAYy1gEKT2dldF9jb21tZW50X3dpdGhfcmVwbGllc19zdHJlYW0tLUNnZ0lnQVFWRjdmUk9CSUZDS0FnR0FFWUFDSU5DZ3NJM3RMaHJ3WVFxTnJVUXcaUBIaVWd4eXFmUEd1akk2WTVDMGFSZDRBYUFCQWciAggAKhhVQ1NIWkt5YXdiNzdpeERkc0dvZzRpV0EyC2p2cUZBaTd2a0JjQAFIMoIBAggBKAhCL2NvbW1lbnQtcmVwbGllcy1pdGVtLVVneHlxZlBHdWpJNlk1QzBhUmQ0QWFBQkFn"
  }
}