TwoSec

TikTok followers API: export a followers list

Page through the followers of a public TikTok account, or the accounts it follows, and get each profile as JSON: username, nickname, bio, verified flag and follower, following, like and video counts. 30 accounts per request, newest first.

Typical uses: checking which creators and brands follow an account before a partnership, mapping who a creator follows, and spotting creators in a brand's audience. The TikTok Video & Creator API reads the lists TikTok shows to logged-out visitors, so no TikTok account is needed.

Setup

You need Python 3, requests (pip install requests) and a key from the RapidAPI listing; the free plan's 100 requests are enough to try it. Put the key in an environment variable called RAPIDAPI_KEY.

import csv
import os
import time

import requests

BASE = "https://tiktok-video-creator-api.p.rapidapi.com"
HEADERS = {
    "X-RapidAPI-Key": os.environ["RAPIDAPI_KEY"],
    "X-RapidAPI-Host": "tiktok-video-creator-api.p.rapidapi.com",
}


def get(path, **params):
    """GET a path and return the JSON. Retries rate limits and upstream errors."""
    for attempt in range(4):
        response = requests.get(BASE + path, headers=HEADERS, params=params, timeout=30)
        if response.status_code in (429, 502, 503) and attempt < 3:
            time.sleep(2 ** attempt)
            continue
        response.raise_for_status()
        return response.json()

Read one page

GET /v1/tiktok/users/{username}/followers takes the username without the @ (with it also works).

curl --request GET \
  --url 'https://tiktok-video-creator-api.p.rapidapi.com/v1/tiktok/users/tiktok/followers' \
  --header "X-RapidAPI-Key: $RAPIDAPI_KEY" \
  --header 'X-RapidAPI-Host: tiktok-video-creator-api.p.rapidapi.com'

Response shape, shortened to one follower. total and sec_uid are from a live response for @tiktok; the follower is a placeholder

{
  "username": "tiktok",
  "sec_uid": "MS4wLjABAAAAv7iSuuXDJGDvJkmH_vz1qkDZYo1apxgzaxdBSeIuPiM",
  "total": 95918545,
  "count": 1,
  "has_more": true,
  "next_cursor": "1790381879",
  "users": [
    {
      "id": "7000000000000000061",
      "username": "example_follower",
      "nickname": "Example Follower",
      "avatar": "https://p16-common-sign.tiktokcdn-us.com/…",
      "verified": false,
      "sec_uid": "MS4wLjABAAAA…",
      "url": "https://www.tiktok.com/@example_follower",
      "bio": "bio text",
      "bio_link": "",
      "private": false,
      "language": "",
      "created_at": "",
      "stats": { "followers": 12801, "following": 7104, "likes": 104660, "videos": 281, "friends": 0 }
    }
  ]
}

total is TikTok's follower count for the account. Each follower is a profile as logged-out visitors see it, so language, created_at and bio_link are usually empty.

Page through the list

Pass next_cursor back as cursor. Also pass sec_uid from the first page: it skips a profile lookup on every later page.

def user_list(username, kind="followers", max_pages=20):
    users, params = {}, {}
    for _ in range(max_pages):
        data = get(f"/v1/tiktok/users/{username}/{kind}", **params)
        for u in data.get("users") or []:
            users[u["id"]] = u
        if not data.get("has_more") or not data.get("next_cursor"):
            break
        params = {"cursor": data["next_cursor"], "sec_uid": data["sec_uid"]}
    return list(users.values())


followers = user_list("tiktok")
print(len(followers), "followers collected")

20 pages is up to 600 accounts for 20 requests.

Following list

The accounts a creator follows use the same shape and parameters:

following = user_list("zachking", kind="following")

Creators usually follow far fewer accounts than follow them, so this list is often short enough to collect in full.

Find creators among followers

Each follower comes with its own counts, so you can pick out creators and verified accounts without extra requests:

creators = [u for u in followers
            if u["stats"]["followers"] >= 10_000 or u["verified"]]
for u in sorted(creators, key=lambda u: u["stats"]["followers"], reverse=True)[:20]:
    print(u["stats"]["followers"], u["username"], u["verified"])

For more detail on any of them, call GET /v1/tiktok/users/{username} (one request) or list their videos.

Save a CSV

FIELDS = ["id", "username", "nickname", "verified", "private", "followers",
          "following", "likes", "videos", "bio", "url"]

with open("followers.csv", "w", newline="", encoding="utf-8") as f:
    writer = csv.DictWriter(f, fieldnames=FIELDS, extrasaction="ignore")
    writer.writeheader()
    for u in followers:
        writer.writerow({**u, **u["stats"]})

Things to know

Next steps

Plans

Each page of 30 accounts is one request. A free plan covers testing. Plans, monthly quotas and rate limits are listed on the RapidAPI listing. For more volume or a custom plan, use Contact provider on the listing.