DEV Community

Mastel
Mastel

Posted on

TikTok profile stats as JSON: followers, likes and video counts in one request

If you want to track a creator's follower count, total likes, and video count over time, TikTok's official APIs are usually the wrong fit: they require an approved app and, for most endpoints, OAuth consent from the account owner. Yet all of those public profile totals sit right on the public profile page.

Instead of maintaining a browser scraper every time TikTok tweaks its hydration JSON, you can call a tiktok profile api with just the handle and get a fixed JSON shape back. Full disclosure: I work with SerpBase, and /tiktok/profile below is one of our endpoints.

One POST request (no @ prefix)

curl -X POST 'https://api.serpbase.dev/tiktok/profile' \
  -H 'Content-Type: application/json' \
  -H 'X-API-Key: YOUR_API_KEY' \
  -d '{"username":"nba"}'
Enter fullscreen mode Exit fullscreen mode

Pass the handle without @. Responses always come back as HTTP 200 with a status field (0 means success; anything else includes an error string and is not billed).

What we got in live tests

We tested three public accounts on November 26, 2026:

username followers_count likes_count videos_count Latency
nba 27530526 1218540111 26060 ~4 s
khaby.lame 162899145 2697415458 1361 ~2 s
tiktok 97153407 470208587 1522 ~13 s

Inside profile, you get:

  • username, name, id: handle, display name, numeric account ID
  • bio: profile text
  • followers_count, following_count, friends_count: exact audience numbers
  • likes_count: total likes across the account
  • videos_count: number of public videos
  • verified, private_account: booleans
  • joined: account creation timestamp (e.g., 2016-08-30T08:01:...) and avatar

Python: log daily snapshots to CSV (with a single retry)

TikTok does not expose historical follower curves, so if you want growth charts you need to snapshot accounts daily yourself. Here is a short script you can run from cron:

import csv
import datetime
import pathlib
import time
import requests

API_KEY = "YOUR_API_KEY"
ACCOUNTS = ["nba", "khaby.lame", "tiktok"]
OUT = pathlib.Path("tiktok_profiles.csv")

def fetch_profile(username: str) -> dict | None:
    for attempt in range(2):
        r = requests.post(
            "https://api.serpbase.dev/tiktok/profile",
            headers={"X-API-Key": API_KEY},
            json={"username": username},
            timeout=60,
        ).json()
        if r.get("status") == 0:
            return r["profile"]
        time.sleep(2)
    return None

today = datetime.date.today().isoformat()
write_header = not OUT.exists()
with OUT.open("a", newline="", encoding="utf-8") as f:
    w = csv.writer(f)
    if write_header:
        w.writerow(["date", "username", "followers", "likes", "videos", "verified"])
    for user in ACCOUNTS:
        p = fetch_profile(user)
        if not p:
            print(user, "failed after retry (not charged)")
            continue
        w.writerow([
            today,
            user,
            int(p["followers_count"]),
            int(p["likes_count"]),
            int(p["videos_count"]),
            p.get("verified"),
        ])
        time.sleep(1)
Enter fullscreen mode Exit fullscreen mode

Five small gotchas to keep in mind

  1. Counts are exact, and they come back as strings. You get "27530526", not "27.5M". Cast with int() before doing deltas or sorting.
  2. Build one retry into your job. In our November 26 run, the first call for tiktok returned a non-zero status (not charged) and succeeded on retry.
  3. It returns profile totals, not the video list. If you want individual videos and view counts for a keyword, use /tiktok/search instead.
  4. Check private_account. Public creator accounts return false; handle true gracefully if your list includes mixed accounts.
  5. Every call is a point-in-time snapshot. Start logging early if you need week-over-week growth.

Each successful call to /tiktok/profile uses 2 credits (failed calls are not charged). New SerpBase accounts start with 500 free credits and no credit card required.

Full field details and docs are in the TikTok Profile API walkthrough.

Top comments (0)