Tutorial

How to Get TikTok Video Comments via API

Extract TikTok video comments and replies with engagement data using Scavio API. Python and JavaScript examples with pagination.

Extract TikTok video comments including text, likes, reply count, and user info via Scavio API at $0.005/page. Separate endpoints for top-level comments and threaded replies. Uses numeric cursor pagination.

Prerequisites

  • Scavio API key
  • Target video ID (aweme_id)
  • Python 3.8+ or Node.js 18+

Walkthrough

Step 1: Get comments for a video

Call the video/comments endpoint with the video's aweme_id.

Python
import requests, os

HEADERS = {'Authorization': f'Bearer {os.environ["SCAVIO_API_KEY"]}',
           'Content-Type': 'application/json'}

resp = requests.post('https://api.scavio.dev/api/v1/tiktok/video/comments',
    headers=HEADERS,
    json={'aweme_id': '7123456789', 'count': 20, 'cursor': 0})

data = resp.json()['data']
for c in data.get('comments', []):
    print(f"{c['user']['unique_id']}: {c['text'][:60]}")
    print(f"  Likes: {c['digg_count']}, Replies: {c.get('reply_comment_total', 0)}")

Step 2: Fetch replies to a comment

Use the comment/replies endpoint with the comment_id for threaded discussions.

Python
comment_id = data['comments'][0]['cid']
replies = requests.post(
    'https://api.scavio.dev/api/v1/tiktok/video/comments/replies',
    headers=HEADERS,
    json={'aweme_id': '7123456789', 'comment_id': comment_id,
          'count': 20, 'cursor': 0}).json()['data']

for r in replies.get('comments', []):
    print(f"  Reply: {r['text'][:60]}")

Step 3: Paginate through comments

Increment cursor to fetch more pages of comments.

Python
cursor = data.get('cursor', 0)
if data.get('has_more'):
    page2 = requests.post(
        'https://api.scavio.dev/api/v1/tiktok/video/comments',
        headers=HEADERS,
        json={'aweme_id': '7123456789', 'count': 20,
              'cursor': cursor}).json()['data']
    print(f'Page 2: {len(page2.get("comments", []))} comments')

Python Example

Python
import requests, os

HEADERS = {'Authorization': f'Bearer {os.environ["SCAVIO_API_KEY"]}',
           'Content-Type': 'application/json'}

def get_comments(video_id, max_pages=5):
    comments = []
    cursor = 0
    for _ in range(max_pages):
        resp = requests.post('https://api.scavio.dev/api/v1/tiktok/video/comments',
            headers=HEADERS,
            json={'aweme_id': video_id, 'count': 20, 'cursor': cursor}).json()['data']
        comments.extend(resp.get('comments', []))
        if not resp.get('has_more'):
            break
        cursor = resp.get('cursor', cursor + 20)
    return comments

comments = get_comments('7123456789')
print(f'{len(comments)} comments extracted')

JavaScript Example

JavaScript
const H = {'Authorization': `Bearer ${process.env.SCAVIO_API_KEY}`, 'Content-Type': 'application/json'};
async function getComments(videoId, maxPages = 5) {
  const comments = [];
  let cursor = 0;
  for (let i = 0; i < maxPages; i++) {
    const r = await fetch('https://api.scavio.dev/api/v1/tiktok/video/comments', {
      method: 'POST', headers: H,
      body: JSON.stringify({aweme_id: videoId, count: 20, cursor})
    }).then(r => r.json());
    comments.push(...(r.data.comments || []));
    if (!r.data.has_more) break;
    cursor = r.data.cursor || cursor + 20;
  }
  return comments;
}
getComments('7123456789').then(c => console.log(`${c.length} comments`));

Expected Output

JSON
Array of comment objects with text, user info, like count, reply count, and timestamps. Separate reply extraction for threaded discussions.

Related Tutorials

Frequently Asked Questions

Most developers complete this tutorial in 15 to 30 minutes. You will need a Scavio API key (free tier works) and a working Python or JavaScript environment.

Scavio API key. Target video ID (aweme_id). Python 3.8+ or Node.js 18+. A Scavio API key gives you 250 free credits per month.

Yes. The free tier includes 250 credits per month, which is more than enough to complete this tutorial and prototype a working solution.

Scavio has a native LangChain package (langchain-scavio), an MCP server, and a plain REST API that works with any HTTP client. This tutorial uses the raw REST API, but you can adapt to your framework of choice.

Start Building

Extract TikTok video comments and replies with engagement data using Scavio API. Python and JavaScript examples with pagination.