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.
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.
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.
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
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
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
Array of comment objects with text, user info, like count, reply count, and timestamps. Separate reply extraction for threaded discussions.