InsightSocial API
Recipes

TikTok analytics dashboard

Build the data layer of a TikTok dashboard for accounts you do not own, with account KPIs, a per-video table and a labelled comment feed. 60 to 260 credits per refresh.

This recipe gathers everything a TikTok dashboard needs for any public account: headline account numbers, a table of how each recent video performed, and the comments on the strongest video, each already tagged with a sentiment label.

Cost per run

60 to 260 credits per refresh: profile (20), one page of profile/videos (20–100) and one page of post/comments (20–140). Re-running the same calls is free for 24 hours on the profile and 6 hours on the lists, so a dashboard that reloads all day pays once per window. Refreshing 50 accounts once a day costs at least 90,000 credits a month.

Which calls feed a TikTok dashboard?

A full refresh takes three calls. Start with GET /v1/tiktok/profile for followers and computed account metrics. Then GET /v1/tiktok/profile/videos gives the latest videos with their view, like, comment and share counts, and GET /v1/tiktok/post/comments fetches the comments for whichever video URL you pass.

TikTok's built-in analytics stop at the accounts you log in to. Working from public numbers with one fixed engagement formula lets you chart any account, whether for a creator tool, a client report or a brand team.

What you need

EndpointReturnsParametersCredits
GET /v1/tiktok/profileFollowers, likes, bio, verification and computed fieldshandle or user_id20
GET /v1/tiktok/profile/videosRecent videos with views, likes, comments and shareshandle; page with max_cursor20–100
GET /v1/tiktok/post/commentsA page of comments on one video, labelledurl; page with cursor20–140

Need audience geography? GET /v1/tiktok/user/audience (100 credits) returns the top follower countries and each one's share. Age and gender are not public on TikTok, so no endpoint returns them.

The code

Python
# tiktok_dashboard.py
# One full refresh for a TikTok account you do not own.
# Run with: INSIGHTSOCIAL_API_KEY=isk_live_... python tiktok_dashboard.py
import os
import requests

KEY = os.environ["INSIGHTSOCIAL_API_KEY"]
BASE = "https://api.insightsocial.app/v1"
HANDLE = "khaby.lame"

def get(path, **params):
    res = requests.get(f"{BASE}/{path}", params=params,
                       headers={"x-api-key": KEY}, timeout=120)
    body = res.json()
    if not body["success"]:
        raise RuntimeError(f'{body["error"]["type"]}: {body["error"]["message"]}')
    return body

# Panel 1: account KPIs
profile = get("tiktok/profile", handle=HANDLE)
author = profile["data"]["author"]
computed = profile["data"].get("computed") or {}
print("followers:", author.get("followers"))
print("engagement_rate:", computed.get("engagement_rate"))  # may be null, see below

# Panel 2: per-video table
videos = get("tiktok/profile/videos", handle=HANDLE)
rows = []
for item in videos["data"].get("items", []):
    post = item["post"]
    eng = post.get("engagement") or {}
    rows.append({
        "caption": (post.get("text") or "")[:40],
        "views": eng.get("views"),
        "likes": eng.get("likes"),
        "comments": eng.get("comments"),
        "shares": eng.get("shares"),
        "url": post.get("url"),
    })
for r in rows[:10]:
    print(r)

# Panel 3: comment feed of the most-viewed video, with free sentiment labels
top = max(rows, key=lambda r: r["views"] or 0, default=None)
if top:
    comments = get("tiktok/post/comments", url=top["url"])
    for item in comments["data"].get("items", [])[:5]:
        text = (item.get("comment") or {}).get("text")
        sentiment = ((item.get("computed") or {}).get("labels") or {}).get("sentiment")
        level = sentiment["level"] if sentiment else "pending"
        print(f"[{level}] {text}")

total = sum(b["credits_used"] for b in (profile, videos)) + (comments["credits_used"] if top else 0)
print("credits used:", total)

What you get back

Example output
followers: 161000000
engagement_rate: None
{'caption': '...', 'views': 12400000, 'likes': 2100000, 'comments': 18400, 'shares': 41000, 'url': 'https://www.tiktok.com/@khaby.lame/video/...'}
{'caption': '...', 'views': 8100000, 'likes': 1400000, 'comments': 12100, 'shares': 22000, 'url': 'https://www.tiktok.com/@khaby.lame/video/...'}
[4] this man never needs to say a word
[2] which country is this
...
credits used: 60

The figures are illustrative. On a TikTok profile, engagement_rate is often null: the like count is lifetime hearts, and when that exceeds the follower count the ratio is not a real rate, so it is left out with a note in data._warnings. For a per-video rate, compute (likes + comments + shares) / views from the table, or use GET /v1/tiktok/profile/full (100 credits), which returns the profile plus its latest 10 videos with engagement by views and by followers already computed.

Sentiment is a level on a five-point scale, where 0 is the most negative and 4 the most positive. If a comment has no sentiment key, its label is still being computed; request the same page again later and it will be there. See Labels.

What to change

  • HANDLE. Any public TikTok account. Run the script over a list of handles and store each refresh keyed by (handle, date), and follower and engagement charts come straight out of the table.
  • Go past the first page. Send max_cursor from the videos response to get older videos, and cursor on comments. See Pagination.
  • Only new videos. Pass the id of the newest video you already hold as stop_at_id, or a date as since.
  • Comment order. Add sort=recent for newest first or sort=top for most liked.
  • Add audience geography. One GET /v1/tiktok/user/audience call adds 100 credits per account.

On this page