# SocialGrid — Post Comments Scraper (`fulinlabs/socialgrid-comments-harvester`) Actor

Scrape YouTube and TikTok post comments into flat JSON — handle, text, likes, reply count, date. YouTube mode is live-verified and guaranteed-working; TikTok is best-effort via residential proxy, with an honest structured error if gated — never fake data.

- **URL**: https://apify.com/fulinlabs/socialgrid-comments-harvester.md
- **Developed by:** [Giovanni](https://apify.com/fulinlabs) (community)
- **Categories:** Social media
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-usage

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js/docs.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python/docs.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## SocialGrid — Post Comments Scraper

> **Unofficial community Actor.** Not affiliated with, endorsed by, or sponsored by YouTube, Google, or TikTok.

Unified-schema post comments for **YouTube** and **TikTok**, returned as flat, agent-ready JSON — one dataset item per comment, never a nested platform-specific blob. Comments are the highest-signal source of engaged fans, potential collab partners, and micro-creators; each `author_handle` this actor returns is a ready-made input to a profile/creator-resolver lookup.

### What it does

| Platform | Status | Notes |
|---|---|---|
| `youtube` | **Guaranteed-working core.** Live-verified, paginated, no proxy needed. | Reuses `@socialgrid/scraper-youtube`'s already-live-verified `getComments` (including its two-endpoint `onResponseReceivedEndpoints` pagination fix). |
| `tiktok` | **Best-effort — live-verified working as of this writing, via Apify's RESIDENTIAL proxy.** Can degrade to an explicit gated-error item if TikTok tightens signature enforcement. | Resolves the video via TikTok's public `api/comment/list/` endpoint. No `X-Bogus`/`msToken` signing is implemented — this works today because that endpoint currently accepts an anonymous request carrying just a valid session cookie through a residential IP. This is inherently more fragile than the YouTube path; if TikTok starts requiring signed requests, every call will fail the same documented way (see "Honest gating" below), never silently return nothing. |

Each run pushes **one dataset item per comment**. If a request is fully gated (platform rejects the request, video/URL can't be resolved, etc.), the run instead pushes exactly **one** explicit error item — comments are never fabricated and an unreachable post never silently looks like "zero comments."

### Input

```json
{
  "platform": "youtube",
  "postUrl": "https://www.youtube.com/watch?v=jNQXAC9IVRw",
  "maxComments": 100,
  "includeReplies": false
}
````

- `platform` (required): `"youtube"` or `"tiktok"`
- `postUrl` (required): full URL of the video/post
  - YouTube: any `youtube.com/watch?v=...` or `youtu.be/...` URL
  - TikTok: full video URL that includes the author's handle in the path (`tiktok.com/@handle/video/123...`)
- `maxComments` (default `100`, max `2000`): paginates internally to reach this count
- `includeReplies` (default `false`): **currently has no effect on YouTube** (see Known limitations) — TikTok returns `reply_count` per top-level comment but does not expand reply threads in this version
- `proxyGroup` (default `"RESIDENTIAL"`, TikTok only): Apify proxy group; TikTok mandatory-login-walls datacenter IPs, so this must stay `RESIDENTIAL` for `platform=tiktok` to work at all. Unused for `platform=youtube`.

### Output — one item per comment

```json
{
  "platform": "youtube",
  "post_id": "jNQXAC9IVRw",
  "comment_id": "UgzuC3zzpRZkjc5Qzsd4AaABAg",
  "text": "We're so honored that the first ever YouTube video was filmed here!",
  "author_handle": "@SanDiegoZoo",
  "author_name": "@SanDiegoZoo",
  "likes": 4600000,
  "reply_count": null,
  "published_at": "2020-07-19T18:22:35.014Z"
}
```

Real TikTok example (live-verified — note `author_handle` and `author_name` are genuinely distinct on this platform, and `reply_count` is a real number):

```json
{
  "platform": "tiktok",
  "post_id": "7635602188613487894",
  "comment_id": "7636247254504866580",
  "text": "whatever you say handsome 😜",
  "author_handle": "aaronjhon28",
  "author_name": "Aaron_jhon",
  "likes": 8407,
  "reply_count": 2,
  "published_at": "2026-05-05T03:39:39.000Z"
}
```

`null` means the platform genuinely doesn't expose that field for that comment (or, for YouTube's `reply_count`, that this actor version doesn't parse it out yet — see below) — never fabricated as `0` or `""`.

#### Gated / failed request

```json
{ "error": "tiktok-comments-gated", "detail": "TikTok comment/list rejected the request (status_code=10202: verify required)" }
```

```json
{ "error": "comments-harvester-failed", "detail": "No comments panel found for \"...\" (comments may be disabled)" }
```

### Known limitations (honest, not silently hidden)

- **YouTube `reply_count` is always `null`.** `getComments` (the reused, live-verified core scraper) currently only parses top-level comment threads — YouTube's reply threads live behind a separate per-comment continuation token that isn't fetched yet. `includeReplies: true` is accepted as input but has no effect on YouTube in this version.
- **YouTube `author_name` duplicates `author_handle`.** YouTube's comment renderer exposes a single author label field, not a separate display-name/@handle pair, so there's nothing further to honestly split out.
- **TikTok comments are inherently more fragile than YouTube's.** This actor makes a genuine anonymous request to TikTok's public `api/comment/list/` endpoint (real session cookie, real residential-proxy IP, real aweme id resolved via the already-live-verified `getPost`) — it does **not** implement TikTok's `X-Bogus`/`msToken` request signing. This was confirmed working live as of this writing; if TikTok tightens enforcement on that endpoint, every TikTok call will fail with the same explicit `tiktok-comments-gated` error rather than degrading to fake or empty data.
- Instagram is intentionally out of scope (login-walled).

### Usage

#### Apify CLI

```bash
apify actors call fulinlabs/socialgrid-comments-harvester \
  --input '{"platform": "youtube", "postUrl": "https://www.youtube.com/watch?v=jNQXAC9IVRw", "maxComments": 50}'
```

#### REST API

```bash
curl "https://api.apify.com/v2/acts/fulinlabs~socialgrid-comments-harvester/run-sync-get-dataset-items?token=$APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"platform": "tiktok", "postUrl": "https://www.tiktok.com/@handle/video/1234567890", "maxComments": 50}'
```

### Deploy

```bash
./deploy.sh          # pnpm run bundle && apify push
```

### Fair use / ToS note

This actor reads only publicly viewable comment data (no login, no private/friends-only content). Scraping social platforms is contrary to most platforms' Terms of Service; use conservatively, respect rate limits, and don't use this to harvest personal data for spam or harassment. YouTube is accessed via its public InnerTube endpoints with no proxy; TikTok is accessed through Apify's residential proxy pool specifically because its comment/video endpoints wall off datacenter IPs.

# Actor input Schema

## `platform` (type: `string`):

Which platform postUrl belongs to. YouTube is the guaranteed-working core of this actor; TikTok is best-effort and may return an explicit gated-error item instead of comments — see README.

## `postUrl` (type: `string`):

Full URL of the video/post to fetch comments from, e.g. 'https://www.youtube.com/watch?v=...' or 'https://www.tiktok.com/@handle/video/...'.

## `maxComments` (type: `integer`):

Maximum number of comments to return, paginating as needed.

## `includeReplies` (type: `boolean`):

If true, attempt to also include reply comments. Currently has no effect on YouTube (see README known limitation); on TikTok, reply\_count is reported per top-level comment but reply threads themselves are not expanded in this version.

## `proxyGroup` (type: `string`):

TikTok mandatory-login-walls datacenter IPs — RESIDENTIAL is required for platform=tiktok to work at all. Unused for platform=youtube.

## Actor input object example

```json
{
  "platform": "youtube",
  "maxComments": 100,
  "includeReplies": false,
  "proxyGroup": "RESIDENTIAL"
}
```

# Actor output Schema

## `results` (type: `string`):

Dataset items containing one normalized YouTube or TikTok comment per item, or one explicit error item when harvesting fails.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {};

// Run the Actor and wait for it to finish
const run = await client.actor("fulinlabs/socialgrid-comments-harvester").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {}

# Run the Actor and wait for it to finish
run = client.actor("fulinlabs/socialgrid-comments-harvester").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{}' |
apify call fulinlabs/socialgrid-comments-harvester --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=fulinlabs/socialgrid-comments-harvester",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "SocialGrid — Post Comments Scraper",
        "description": "Scrape YouTube and TikTok post comments into flat JSON — handle, text, likes, reply count, date. YouTube mode is live-verified and guaranteed-working; TikTok is best-effort via residential proxy, with an honest structured error if gated — never fake data.",
        "version": "0.1",
        "x-build-id": "rieyzwZLeq07gbjxG"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/fulinlabs~socialgrid-comments-harvester/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-fulinlabs-socialgrid-comments-harvester",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/fulinlabs~socialgrid-comments-harvester/runs": {
            "post": {
                "operationId": "runs-sync-fulinlabs-socialgrid-comments-harvester",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/fulinlabs~socialgrid-comments-harvester/run-sync": {
            "post": {
                "operationId": "run-sync-fulinlabs-socialgrid-comments-harvester",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "platform",
                    "postUrl"
                ],
                "properties": {
                    "platform": {
                        "title": "Platform",
                        "enum": [
                            "youtube",
                            "tiktok"
                        ],
                        "type": "string",
                        "description": "Which platform postUrl belongs to. YouTube is the guaranteed-working core of this actor; TikTok is best-effort and may return an explicit gated-error item instead of comments — see README.",
                        "default": "youtube"
                    },
                    "postUrl": {
                        "title": "Post URL",
                        "type": "string",
                        "description": "Full URL of the video/post to fetch comments from, e.g. 'https://www.youtube.com/watch?v=...' or 'https://www.tiktok.com/@handle/video/...'."
                    },
                    "maxComments": {
                        "title": "Max comments",
                        "minimum": 1,
                        "maximum": 2000,
                        "type": "integer",
                        "description": "Maximum number of comments to return, paginating as needed.",
                        "default": 100
                    },
                    "includeReplies": {
                        "title": "Include replies",
                        "type": "boolean",
                        "description": "If true, attempt to also include reply comments. Currently has no effect on YouTube (see README known limitation); on TikTok, reply_count is reported per top-level comment but reply threads themselves are not expanded in this version.",
                        "default": false
                    },
                    "proxyGroup": {
                        "title": "Apify proxy group (TikTok only)",
                        "type": "string",
                        "description": "TikTok mandatory-login-walls datacenter IPs — RESIDENTIAL is required for platform=tiktok to work at all. Unused for platform=youtube.",
                        "default": "RESIDENTIAL"
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
