Analyze audience overlap between TikTok creators by comparing follower samples via Scavio API. Cost: $0.16 per creator pair (15 pages each + 2 profile lookups). Essential for influencer campaign planning to maximize unique reach.
Prerequisites
- Scavio API key
- Two or more TikTok usernames to compare
- Python 3.8+
Walkthrough
Step 1: Get follower samples for each creator
Pull follower pages for both creators.
import requests, os
HEADERS = {'Authorization': f'Bearer {os.environ["SCAVIO_API_KEY"]}',
'Content-Type': 'application/json'}
def get_sec_uid(username):
return requests.post('https://api.scavio.dev/api/v1/tiktok/profile',
headers=HEADERS, json={'username': username}).json()['data']['user']['sec_uid']
def get_followers(sec_uid, pages=15):
followers = []
params = {'sec_user_id': sec_uid, 'count': 20}
for _ in range(pages):
data = requests.post('https://api.scavio.dev/api/v1/tiktok/user/followers',
headers=HEADERS, json=params).json()['data']
followers.extend(data.get('followers', []))
if not data.get('has_more'): break
params['page_token'] = data['next_page_token']
params['min_time'] = data['min_time']
return followersStep 2: Calculate overlap
Compare follower sets using Jaccard similarity.
uid_a = get_sec_uid('creator_a')
uid_b = get_sec_uid('creator_b')
set_a = {f['unique_id'] for f in get_followers(uid_a)}
set_b = {f['unique_id'] for f in get_followers(uid_b)}
overlap = set_a & set_b
jaccard = len(overlap) / len(set_a | set_b) if (set_a | set_b) else 0
print(f'Sampled: {len(set_a)} + {len(set_b)} followers')
print(f'Overlap: {len(overlap)} ({jaccard:.1%} Jaccard similarity)')Python Example
import requests, os
HEADERS = {'Authorization': f'Bearer {os.environ["SCAVIO_API_KEY"]}',
'Content-Type': 'application/json'}
def overlap_analysis(username_a, username_b, sample_pages=15):
uid_a = requests.post('https://api.scavio.dev/api/v1/tiktok/profile',
headers=HEADERS, json={'username': username_a}).json()['data']['user']['sec_uid']
uid_b = requests.post('https://api.scavio.dev/api/v1/tiktok/profile',
headers=HEADERS, json={'username': username_b}).json()['data']['user']['sec_uid']
def fetch(uid):
followers = []
params = {'sec_user_id': uid, 'count': 20}
for _ in range(sample_pages):
data = requests.post('https://api.scavio.dev/api/v1/tiktok/user/followers',
headers=HEADERS, json=params).json()['data']
followers.extend(data.get('followers', []))
if not data.get('has_more'): break
params['page_token'] = data['next_page_token']
params['min_time'] = data['min_time']
return {f['unique_id'] for f in followers}
set_a, set_b = fetch(uid_a), fetch(uid_b)
overlap = set_a & set_b
return {'a': len(set_a), 'b': len(set_b), 'overlap': len(overlap),
'jaccard': len(overlap) / len(set_a | set_b) if (set_a | set_b) else 0}
result = overlap_analysis('creator_a', 'creator_b')
print(f"Overlap: {result['overlap']} ({result['jaccard']:.1%})")JavaScript Example
const H = {'Authorization': `Bearer ${process.env.SCAVIO_API_KEY}`, 'Content-Type': 'application/json'};
async function overlapAnalysis(usernameA, usernameB) {
async function getUid(u) {
const r = await fetch('https://api.scavio.dev/api/v1/tiktok/profile', {
method: 'POST', headers: H, body: JSON.stringify({username: u})
}).then(r => r.json());
return r.data.user.sec_uid;
}
async function fetchFollowers(uid) {
const set = new Set();
let params = {sec_user_id: uid, count: 20};
for (let i = 0; i < 15; i++) {
const r = await fetch('https://api.scavio.dev/api/v1/tiktok/user/followers', {
method: 'POST', headers: H, body: JSON.stringify(params)
}).then(r => r.json());
(r.data.followers || []).forEach(f => set.add(f.unique_id));
if (!r.data.has_more) break;
params.page_token = r.data.next_page_token;
params.min_time = r.data.min_time;
}
return set;
}
const [uidA, uidB] = await Promise.all([getUid(usernameA), getUid(usernameB)]);
const [setA, setB] = await Promise.all([fetchFollowers(uidA), fetchFollowers(uidB)]);
const overlap = [...setA].filter(x => setB.has(x));
console.log(`Overlap: ${overlap.length} out of ${setA.size} + ${setB.size}`);
}
overlapAnalysis('creator_a', 'creator_b');Expected Output
Audience overlap metrics: follower sample sizes, shared follower count, and Jaccard similarity coefficient for the creator pair.