Skip to main content
POST
/
youtube
/
video
/
comment
YouTube Video Comment
curl --request POST \
  --url https://mavi-backend.memories.ai/serve/api/v2/youtube/video/comment \
  --header 'Authorization: <api-key>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "video_id": "Y2y4OpzKIK4",
  "page_size": 100,
  "next_page_token": null
}
'
{
  "items": [
    {
      "id": "comment_id_1",
      "text": "Comment content",
      "published_at": "2024-01-01T00:00:00Z",
      "like_count": 10,
      "author": {
        "id": "user_id",
        "name": "username",
        "channel_url": "https://..."
      },
      "reply_count": 5
    },
    {
      "id": "comment_id_2",
      "text": "Another comment",
      "published_at": "2024-01-02T00:00:00Z",
      "like_count": 20,
      "author": {
        "id": "user_id_2",
        "name": "username2",
        "channel_url": "https://..."
      },
      "reply_count": 0
    }
  ],
  "next_page_token": "CAoQAA",
  "page_info": {
    "total_results": 150,
    "results_per_page": 100
  }
}
This API is used to get the comment list for YouTube videos with pagination support.
Channel routing guide: see Social Media Scraping Overview. Endpoints with a channel request field let you choose apify, rapid, or memories.ai; endpoints without this field use managed routing.
Each API call costs $0.01 USD.

Channel Options

If your request supports a channel option, use it to control how scraper data is sourced:
ChannelWhat it meansTypical trade-off
apifyUses Apify, a dedicated web scraping platform with broad content coverage.Most stable and most complete results, but usually more expensive.
rapidUses RapidAPI, a lower-cost aggregation platform.Lower cost, but less stable and often narrower coverage.
memories.aiManaged routing by Memories.ai.Automatically selects the best price/performance path for your request.
Recommendation: Start with memories.ai unless you need to force a specific provider.
  • The maximum value for pagination parameter page_size is 100
  • next_page_token should be null for the first request, use the next_page_token returned from the previous response for subsequent requests
  • When next_page_token in the response is null, it indicates all comments have been retrieved

Code Example

import requests

BASE_URL = "https://mavi-backend.memories.ai/serve/api/v2"
API_KEY = "sk-mai-this_a_test_string_please_use_your_generated_key_during_testing"
HEADERS = {
    "Authorization": f"{API_KEY}",
    "Content-Type": "application/json"
}

def youtube_video_comment(video_id: str):
    url = f"{BASE_URL}/youtube/video/comment"
    page_size = 100
    next_page_token = None
    all_comments = []
    while True:
        data = {"video_id": video_id, "page_size": page_size, "next_page_token": next_page_token}
        resp = requests.post(url, json=data, headers=HEADERS).json()
        comments = resp.get("items", [])
        all_comments.extend(comments)
        next_page_token = resp.get("next_page_token")
        if not next_page_token:
            break
    return all_comments

# Usage example
comments = youtube_video_comment("your_youtube_video_id")
print(comments)

Request Body

FieldTypeRequiredDescription
video_idstringYesYouTube video ID (the v parameter from a YouTube URL, e.g., Y2y4OpzKIK4)
page_sizenumberNoNumber of comments returned per page, maximum value is 100, default is 100
next_page_tokenstring | nullNoNext page token, should be null for the first request, use the value returned from the previous response for subsequent requests

Response

Returns an object containing the comment list and pagination information.
{
  "items": [
    {
      "id": "comment_id_1",
      "text": "Comment content",
      "published_at": "2024-01-01T00:00:00Z",
      "like_count": 10,
      "author": {
        "id": "user_id",
        "name": "username",
        "channel_url": "https://..."
      },
      "reply_count": 5
    },
    {
      "id": "comment_id_2",
      "text": "Another comment",
      "published_at": "2024-01-02T00:00:00Z",
      "like_count": 20,
      "author": {
        "id": "user_id_2",
        "name": "username2",
        "channel_url": "https://..."
      },
      "reply_count": 0
    }
  ],
  "next_page_token": "CAoQAA",
  "page_info": {
    "total_results": 150,
    "results_per_page": 100
  }
}

Response Parameters

ParameterTypeDescription
itemsarray[object]Comment list array
items[].idstringComment ID
items[].textstringComment content
items[].published_atstringComment published time (ISO 8601 format)
items[].like_countnumberLike count
items[].authorobjectComment author information
items[].author.idstringAuthor ID
items[].author.namestringAuthor username
items[].author.channel_urlstringAuthor channel URL
items[].reply_countnumberReply count
next_page_tokenstring | nullNext page token, used to get the next page of data, null indicates all data has been retrieved
page_infoobjectPagination information
page_info.total_resultsnumberTotal number of comments
page_info.results_per_pagenumberNumber of results per page

Authorizations

Authorization
string
header
required

Body

application/json
video_id
string
required

YouTube video ID

Example:

"Y2y4OpzKIK4"

page_size
integer
default:100

Number of comments returned per page, maximum value is 100, default is 100

Required range: x <= 100
Example:

100

next_page_token
string | null

Next page token, should be null for the first request, use the value returned from the previous response for subsequent requests

Example:

null

Response

200 - application/json

Successfully returned comment list

items
object[]

Comment list array

next_page_token
string | null

Next page token, used to get the next page of data, null indicates all data has been retrieved

page_info
object

Pagination information