Comment data for sentiment analysis

Pull comments with like counts from public videos and posts.

The job

Comments are the audience talking. Fetch them with likes, author and time, then run your classifier or model over the text column.

Endpoints

EndpointReturnsCost
GET /v1/youtube/video/commentsYouTube video comments1 credit
GET /v1/tiktok/video/commentsTikTok video comments1 credit
GET /v1/instagram/post/commentsInstagram post comments1 credit
GET /v1/facebook/post/commentsFacebook post comments1 credit

Failed requests and cached repeats cost 0 credits. Send max_age_days to accept a recent cached copy. See credits and caching.

Recipe

  1. Pick the videos or posts.
  2. Page through the comments.
  3. Score the text; keep likes as a weight.
Preview
The API is in early access. Calls use api.socialscrape.io and return the shapes in the reference.
Python
import os
import requests

API = "https://api.socialscrape.io"
HEADERS = {"x-api-key": os.environ["SOCIALSCRAPE_API_KEY"]}


def get(path, **params):
    res = requests.get(API + path, headers=HEADERS, params=params, timeout=60)
    res.raise_for_status()
    return res.json()["data"]

# YouTube video comments
comments = get("/v1/youtube/video/comments", url="https://www.youtube.com/watch?v=dQw4w9WgXcQ", sort="top")

rows = [(c["text"], c["stats"]["likes"]) for c in comments["items"]]
print(len(rows), rows[:3])
TypeScript
const API = "https://api.socialscrape.io";
const headers = { "x-api-key": process.env.SOCIALSCRAPE_API_KEY! };

async function get(path: string, params: Record<string, string | number | boolean>) {
  const query = new URLSearchParams(Object.entries(params).map(([k, v]) => [k, String(v)]));
  const res = await fetch(`${API}${path}?${query}`, { headers });
  if (!res.ok) throw new Error(`${res.status} ${await res.text()}`);
  return (await res.json()).data;
}

// YouTube video comments
const comments = await get("/v1/youtube/video/comments", { url: "https://www.youtube.com/watch?v=dQw4w9WgXcQ", sort: "top" });

const rows = comments.items.map((c: any) => [c.text, c.stats.likes]);
console.log(rows.length, rows.slice(0, 3));

Good to know

A page is a slice of the thread, not all of it. Page until has_more is false if you need the whole thread.

Build on social data early.

Developers and agent builders get the first keys.

Get early access