100 free credits. No credit card required.Start building
Logo
Back to blog

Sentiment Analysis API for Comments on 6 Platforms

··8 min read

A sentiment analysis API that labels every TikTok, Instagram, YouTube, Reddit, X and Facebook comment for sentiment, questions, purchase intent and complaints.

Sentiment Analysis API for Comments on 6 Platforms

SocialCrawl is a sentiment analysis API that works on the comments themselves. Call a comment endpoint on TikTok, Instagram, YouTube, Reddit, X or Facebook and every comment arrives with a sentiment level, plus the probability that it is a question, shows purchase intent or is a complaint. There is no second call and no extra credit, and you can switch the labels off with judgments=off.

That makes it a fit for monitoring, triage and lead-spotting jobs where the text you want to score is a comment you were going to fetch anyway. If you already have the text and only need a scorer, see the comparison further down.

A social media comment moving through an API pipeline and getting stamped with sentiment, question, purchase intent and complaint tags.

What does the sentiment analysis API return on each comment?

Each comment carries a computed.labels block with four labels, next to computed.language. You fetch the comments as usual and the labels are already there:

bash
curl "https://www.socialcrawl.dev/v1/tiktok/post/comments?url=https://www.tiktok.com/@USERNAME/video/VIDEO_ID" \
  -H "x-api-key: $SOCIALCRAWL_API_KEY"

One comment from the response, trimmed to the fields that matter:

json
{
  "comment": { "text": "Ordering it for my 13 year old ❤️" },
  "computed": {
    "language": "en",
    "labels": {
      "sentiment": { "level": 4, "score_0_1": 0.91, "confidence": 0.71 },
      "question": { "p": 0.03 },
      "purchase_intent": { "p": 0.98 },
      "complaint": { "p": 0.02 }
    }
  }
}
LabelValueWhat it tells you
sentimentlevel 0 to 4, score_0_1, confidenceHow the comment feels, from very negative (0) to very positive (4)
questionp from 0 to 1A real question. A rhetorical one that complains or mocks does not count
purchase_intentp from 0 to 1Bought it, ordered it, is switching to it, or asks for a link or price. "Is it worth it?" does not count
complaintp from 0 to 1Something that happened to the author. Criticising a price or a spec does not count

The probabilities are raw, so you pick the cut-off that suits your job. A comment the system could not judge carries labels: null, which is different from a low probability. The full field reference is in the labels docs.

Which platforms and endpoints carry the labels?

All comment-list endpoints on six platforms: TikTok, Instagram, YouTube, Reddit, X (tweet replies) and Facebook, including the reply-thread endpoints. A few of the common ones:

EndpointCredits per page
tiktok/post/comments1
youtube/video/comments1
twitter/tweet/replies1
instagram/post/comments5
reddit/post/comments5

The labels docs list every endpoint. The TikTok and Instagram endpoint pages cover each parameter.

Does labelling cost extra credits?

No. The four labels above are free on every comment call, so a page costs what it cost before labels existed. Add judgments=off to remove computed.labels, data.label_share and data.comment_language from the response.

Three further comment labels, spam, toxic and low_quality, are opt-in through label= and are metered. They hold a few extra credits up front and refund down to 1 credit per started 25 comments that were newly judged.

What does label_share tell you about a whole comment page?

Comment lists also return data.label_share, which turns the per-comment labels into page-level numbers. For each label you get the share of decided comments, a 90% confidence interval, and up to three verbatim comments as evidence.

json
{
  "n": 49,
  "counted": 36,
  "abstained": 6,
  "share": 0.8372,
  "low": 0.7252,
  "high": 0.9093,
  "too_few": false
}

This is the sentiment.positive entry from the documented TikTok example. n is the comments considered, abstained is the ones the system could not call either way, and share is counted divided by n minus abstained. So one GET on a reply thread can answer "how negative is this thread, and how sure are we?" without a scoring pipeline of your own. For alerting on top of that, a social media monitoring API job can read the same numbers.

A measurement gauge comparing a wide, uncertain confidence interval with a narrow one, a picture of withholding a percentage when a comment sample is too small.

What happens when the sample is too small to trust?

The API withholds the headline number. When the 90% interval is wider than 0.25, share comes back null and too_few is true. A page where two comments were decided positive would otherwise print a confident percentage that two comments cannot support. Read low and high if you still want a rough range.

Comments that could not be judged count as abstained, never as a silent "no".

Can you read more of a thread, or sort it newest first?

Yes, on TikTok and Instagram. scan_pages (1 to 3, default 1) reads several pages, drops repeats and returns the comments together. TikTok bills 1 credit and Instagram 5 credits for each page that added new comments, and a page of repeats is not billed. data.scan reports the pages read and billed and whether the thread ended.

sort=recent returns comments newest first. TikTok has no newest-first order of its own, so this sorts the comments that were read. Raise scan_pages to read more of the thread, and check data.scan.complete before treating the result as the whole conversation. Calling it on a schedule is as close to real-time sentiment analysis as the endpoint gets. It polls and does not stream.

Does comment_language tell you where your audience is?

No. data.comment_language is the mix of languages the page's commenters write in, not a country. For audience location on TikTok, prism/audience-language is the endpoint to look at.

How does this compare with Google, AWS and Azure sentiment APIs?

The cloud NLP services score text you send them: Google Cloud Natural Language, AWS Comprehend and Azure AI Language all bill by the amount of text. None of them fetches a comment, so a social workflow needs a fetching step and a scoring step wired together.

SocialCrawl does both in one call, but only for comments on the platforms above. It does not score text you paste in. If that is what you need, 8 sentiment analysis tools compares standalone options.

How do you start?

Sign up to get an API key and starting credits, then send a comment call with curl. No SDK is needed:

bash
curl "https://www.socialcrawl.dev/v1/youtube/video/comments?url=https://www.youtube.com/watch?v=VIDEO_ID" \
  -H "x-api-key: $SOCIALCRAWL_API_KEY"

The visual explorer shows a labelled response before you write code. For paging a YouTube thread, see the YouTube comment scraper guide, and for TikTok see the TikTok comment scraping tutorial. To read a whole thread in one call, use prism/comments. It also takes X, Threads and LinkedIn post links, and it judges the same four labels on up to 100 new comments per call. When you want the comments that show purchase intent turned into leads, the social listening leads API does that.

FAQ

Does SocialCrawl's comment sentiment analysis cost extra?

No. The four default labels are free on every comment call, and the price is the same with or without them. judgments=off removes them from the response.

What does label_share measure on a comment page?

The share of decided comments for a label, such as negative sentiment or purchase intent, with the sample size, the number of comments left out as undecidable, and a 90% confidence interval. When that interval is wider than 0.25, share is null and too_few is true.

Does comment_language tell you where an audience is from?

No. It is a language mix, not a country. On TikTok, prism/audience-language adds a sample of follower locations.

Can I sort TikTok or Instagram comments newest first?

Yes. Use sort=recent and raise scan_pages (1 to 3) to read more of the thread. TikTok sorts only the comments the call read, so check data.scan.complete. A page that only repeats earlier comments is not billed.

Which platforms carry the comment labels?

TikTok, Instagram, YouTube, Reddit, X (through tweet replies) and Facebook, on their comment and reply endpoints.

Topics
#sentiment-analysis-api#ai-sentiment-analysis-tool#sentiment-analysis-nlp#real-time-sentiment-analysis#sentiment-analysis-applications#twitter-sentiment-analysis-api#free-sentiment-analysis-api

Related posts

🤖 AI agent or LLM? Read this page as markdown