TikTok does not give a product an easy way to read the public numbers of any video: its official APIs read the account that logs in, or serve approved researchers. This tutorial shows how to get a video’s statistics, author, sound and qualities from nothing but its URL, and how to turn them into an engagement rate.
Before you start
Create a free key in the dashboard and keep it in an environment variable called IGRAMAPI_KEY. The free plan has 100 credits a month, and every TikTok endpoint works on it. A video lookup costs 1 credit.
Step 1: look up a video
Pass the video URL, a short link copied from the app, or the numeric video id:
curl "https://api.igramapi.com/v1/tiktok/videos?url=https://www.tiktok.com/@example_creator/video/7401234567890123456" \
-H "Authorization: Bearer $IGRAMAPI_KEY"
The parts of the response you will use most:
{
"id": "7401234567890123456",
"type": "video",
"description": "Sunday market haul #streetfood #vlog",
"created_at": 1761900000,
"author": { "username": "example_creator", "followers": 1820000, "is_verified": true },
"plays": 2450000,
"likes": 312400,
"comments": 4120,
"shares": 9800,
"saves": 15600,
"duration": 27,
"hashtags": ["streetfood", "vlog"],
"music": { "title": "original sound", "is_original": true },
"formats": [
{ "quality": "1080p", "codec": "h265_hvc1", "size_bytes": 9987936 },
{ "quality": "576p", "codec": "h264", "size_bytes": 15553308 }
],
"cached": false
}
All numbers are integers, created_at is Unix time, and formats is sorted best first.
Step 2: Python, with an engagement rate
import os
import requests
API = "https://api.igramapi.com"
HEADERS = {"Authorization": f"Bearer {os.environ['IGRAMAPI_KEY']}"}
def tiktok_video(url):
response = requests.get(f"{API}/v1/tiktok/videos", params={"url": url}, headers=HEADERS, timeout=30)
if not response.ok:
raise RuntimeError(response.json()["error"]["message"])
return response.json()
def engagement(video):
interactions = video["likes"] + video["comments"] + video["shares"] + video["saves"]
return {
"per_play": interactions / video["plays"] if video["plays"] else None,
"per_follower": interactions / video["author"]["followers"] if video["author"]["followers"] else None,
}
video = tiktok_video("https://vm.tiktok.com/ZMabc123/")
print(video["author"]["username"], video["plays"], engagement(video))
Engagement per play is the fairer number for TikTok, because the For You feed shows videos to people who do not follow the creator.
Step 3: the same in Node.js
const API = "https://api.igramapi.com";
async function tiktokVideo(url) {
const response = await fetch(`${API}/v1/tiktok/videos?url=${encodeURIComponent(url)}`, {
headers: { Authorization: `Bearer ${process.env.IGRAMAPI_KEY}` },
});
if (!response.ok) throw new Error((await response.json()).error.message);
return response.json();
}
const video = await tiktokVideo("https://www.tiktok.com/@example_creator/video/7401234567890123456");
const interactions = video.likes + video.comments + video.shares + video.saves;
console.log(video.author.username, (interactions / video.plays).toFixed(4));
Step 4: add the creator’s profile
The video already carries the author’s follower count. For the full header, call the TikTok Profile API with the username:
curl "https://api.igramapi.com/v1/tiktok/profiles/example_creator" \
-H "Authorization: Bearer $IGRAMAPI_KEY"
It returns followers, following, total likes, the number of videos, bio, link in bio, verification, business flag, region and language.
Things to know
- There is no link to the video file. TikTok’s own video links only work inside its page, so the response lists the qualities in
formats(with their size) but not a link. To get the file, send the same URL to the TikTok Downloader API and pass thequalityyou want; see how to download TikTok videos without the watermark. - Other links are temporary.
cover,author.avatar, the sound and the subtitle files are TikTok CDN links that work for a while and then expire, so do not store them as permanent references. - Numbers are cached for up to 30 minutes. The
cachedfield tells you. To track growth, storeplaysandlikeswith the request time and call again on a schedule. - Slideshows return
type: "photo"and aphotoslist instead of video formats. - Comments and a creator’s other videos come from their own endpoints: the TikTok Comments API and the TikTok User Videos API, which also carries full statistics for every video. Search is not available.
Handling errors
| Status | Code | What to do |
|---|---|---|
| 400 | invalid_target |
The input is not a TikTok video link or id. Ask the user for another link. |
| 404 | video_unavailable |
The video was deleted, is private, or is restricted. Do not retry. |
| 429 | rate_limit_exceeded |
Wait for Retry-After seconds. |
| 502 | upstream_error |
TikTok could not be reached. Retry shortly; this is refunded. |
See error handling for retry advice, and credits and rate limits for what each call costs.