Appearance
RankingReels Pipeline
Pull a creator's top-performing reels across TikTok and Instagram, score by engagement, and produce a ranked CSV plus a JSON manifest for downstream rendering.
Steps
- Resolve the creator handle on both platforms.
- Pull profile videos (TikTok) and reels (Instagram) with pagination.
- Compute an engagement score per asset:
(likes + comments + shares) / followers. - Sort descending and keep the top 25.
- Write a CSV plus a JSON manifest containing video URLs and transcripts.
Node Script
js
import fs from 'node:fs';
import { stringify } from 'csv-stringify/sync';
const SC_KEY = process.env.SCRAPECREATORS_API_KEY;
async function sc(path, params) {
const qs = new URLSearchParams(params).toString();
const res = await fetch(`https://api.scrapecreators.com${path}?${qs}`, {
headers: { 'x-api-key': SC_KEY },
});
if (!res.ok) throw new Error(`${path} -> ${res.status}`);
return res.json();
}
async function rankCreator(tiktokHandle, instagramHandle) {
const tiktokProfile = await sc('/v1/tiktok/profile', { handle: tiktokHandle });
const tiktokVideos = await sc('/v3/tiktok/profile/videos', { handle: tiktokHandle });
const igProfile = await sc('/v1/instagram/profile', { handle: instagramHandle });
const igReels = await sc('/v1/instagram/user/reels', { handle: instagramHandle });
const tiktokFollowers = tiktokProfile.stats?.followerCount || 1;
const igFollowers = igProfile?.user?.edge_followed_by?.count || 1;
const tiktokRanked = (tiktokVideos.videos || []).map((v) => ({
platform: 'tiktok',
url: `https://www.tiktok.com/@${tiktokHandle}/video/${v.id}`,
score: ((v.stats?.diggCount || 0) + (v.stats?.commentCount || 0) + (v.stats?.shareCount || 0)) / tiktokFollowers,
raw: v,
}));
const igRanked = (igReels.reels || []).map((r) => ({
platform: 'instagram',
url: `https://www.instagram.com/reel/${r.shortcode}`,
score: ((r.like_count || 0) + (r.comment_count || 0)) / igFollowers,
raw: r,
}));
return [...tiktokRanked, ...igRanked].sort((a, b) => b.score - a.score).slice(0, 25);
}
const top = await rankCreator('stoolpresidente', 'stoolpresidente');
fs.writeFileSync('top-reels.json', JSON.stringify(top, null, 2));
fs.writeFileSync(
'top-reels.csv',
stringify(top.map(({ raw, ...rest }) => rest), { header: true })
);
console.log(`Wrote ${top.length} ranked reels.`);Notes
- This costs roughly 4 credits per creator (2 profile, 2 list endpoints).
- Add
GET /v1/tiktok/video/transcriptper top reel if you want to feed text into a ranking model. - Use
countryandtime_periodfilters onGET /v1/tiktok/videos/popularto scope the trending pool.
Related Endpoints
GET /v1/tiktok/profileGET /v3/tiktok/profile/videosGET /v1/instagram/profileGET /v1/instagram/user/reelsGET /v1/youtube/channel-videos