通过 Scavio API 提取 TikTok 个人资料数据(用户名、关注者数量、关注数量、视频数量、简介、验证状态),费用为 0.005 美元/请求。无需抓取,无需浏览器自动化,每个配置文件一次 API 调用。
前置条件
- 来自 scavio.dev 的 Scavio API 密钥
- Python 3.8+ 或 Node.js 18+
- 请求库 (Python) 或 fetch (Node.js)
操作指南
步骤 1: 获取您的 API 密钥
在 scavio.dev 注册即可获得每月 250 个免费积分。从仪表板复制您的 API 密钥。
Bash
# Set your API key as environment variable
export SCAVIO_API_KEY=your_key_here步骤 2: 按用户名查找个人资料
使用目标用户名调用 TikTok 个人资料端点。
Python
import requests, os
resp = requests.post('https://api.scavio.dev/api/v1/tiktok/profile',
headers={'Authorization': f'Bearer {os.environ["SCAVIO_API_KEY"]}',
'Content-Type': 'application/json'},
json={'username': 'charlidamelio'})
profile = resp.json()['data']['user']
print(f"Followers: {profile['follower_count']:,}")
print(f"Videos: {profile['aweme_count']}")
print(f"Verified: {profile.get('verified', False)}")步骤 3: 提取 sec_uid 以进行进一步的 API 调用
关注者、关注者和帖子端点需要配置文件响应中的 sec_uid。
Python
sec_uid = profile['sec_uid']
print(f'sec_uid: {sec_uid}')
# Use this for /api/v1/tiktok/user/posts,
# /api/v1/tiktok/user/followers, etc.Python 示例
Python
import requests, os
API_KEY = os.environ['SCAVIO_API_KEY']
HEADERS = {'Authorization': f'Bearer {API_KEY}', 'Content-Type': 'application/json'}
def get_profile(username):
resp = requests.post('https://api.scavio.dev/api/v1/tiktok/profile',
headers=HEADERS, json={'username': username})
data = resp.json()['data']['user']
return {
'username': data['unique_id'],
'nickname': data['nickname'],
'followers': data['follower_count'],
'following': data['following_count'],
'videos': data['aweme_count'],
'likes': data['total_favorited'],
'verified': data.get('verified', False),
'sec_uid': data['sec_uid'],
}
profile = get_profile('charlidamelio')
for k, v in profile.items():
print(f'{k}: {v}')JavaScript 示例
JavaScript
const H = {'Authorization': `Bearer ${process.env.SCAVIO_API_KEY}`, 'Content-Type': 'application/json'};
async function getProfile(username) {
const r = await fetch('https://api.scavio.dev/api/v1/tiktok/profile', {
method: 'POST', headers: H,
body: JSON.stringify({username})
}).then(r => r.json());
const u = r.data.user;
return {username: u.unique_id, followers: u.follower_count,
videos: u.aweme_count, sec_uid: u.sec_uid};
}
getProfile('charlidamelio').then(p => console.log(p));预期输出
JSON
Profile data including follower count, video count, verification status, and sec_uid for use in subsequent API calls.