Skip to content

Fetching Followers

Now, let's dive into the data you can retreive around followers on TikTok.

User Followers API

API Documentation

Sample Response

Our TikTok Followers API allows you to retrieve a user's most recent 5000 followers, i.e the last 5000 people to follow this user. To do so we'll require both the the user id and the secondary user id.

result = requests.get(
    "https://ensembledata.com/apis/tt/user/followers",
    params={
        "id": "6784819479778378757",
        "secUid": "MS4wLjABAAAAQ45IcDZIqrknyl0FDjs7xDlcxlaRE7CcBx1ENxYkWK00UpeKTTlCQWKxq6t9QM6b",
        "token": "API_TOKEN",
    }
).json()["data"]

followers = result["followers"]
follower_count = result["total"]
next_cursor = result["nextCursor"]
result = client.tiktok.user_followers(
    id="6784819479778378757",
    sec_uid="MS4wLjABAAAAQ45...",
)

followers = result.data["followers"]
follower_count = result.data["total"]
next_cursor = result.data["nextCursor"]
let result = await client.tiktok.userFollowers({
    id: "6784819479778378757",
    secUid: "MS4wLjABAAAAQ45...",
});

let followers = result.data.followers;
let followerCount = result.data.total;
let nextCursor = result.data.nextCursor;

A single request will return 100 followers. To get more, send another request, this time passing in the cursor value we got from the previous request (What is a cursor?). Note: the maximum you can retrieve is 5000.

User Followings API

API Documentation

Sample Response

Additionally, you can fetch the 'followings', which are the people the user themself follows. This endpoint works very similarly to the endpoint to fetch followers:

result = requests.get(
    "https://ensembledata.com/apis/tt/user/followings",
    params={
        "id": "6784819479778378757",
        "secUid": "MS4wLjABAAAAQ45IcDZIqrknyl0FDjs7xDlcxlaRE7CcBx1ENxYkWK00UpeKTTlCQWKxq6t9QM6b",
        "token": "API_TOKEN",
    }
).json()["data"]

followers = result["followings"]
follower_count = result["total"]
next_cursor = result["nextCursor"]
next_page_token = result["nextPageToken"]
result = client.tiktok.user_followings(
    id="6784819479778378757",
    sec_uid="MS4wLjABAAAAQ45...",
)

followers = result.data["followings"]
follower_count = result.data["total"]
next_cursor = result.data.get("nextCursor")
next_page_token = result.data.get("nextPageToken")
let result = await client.tiktok.userFollowings({
    id: "6784819479778378757",
    secUid: "MS4wLjABAAAAQ45...",
});

let followers = result.data.followings;
let followerCount = result.data.total;
let nextCursor = result.data.nextCursor;
let nextPageToken = result.data.nextPageToken;

A single request will return 100 followings. To get more you'll need to use the cursor AND the page_token. Let's see how we can get the next chunk of followings below:

result = requests.get(
    "https://ensembledata.com/apis/tt/user/followings",
    params={
        "id": "6784819479778378757",
        "secUid": "MS4wLjABAAAAQ45IcDZIqrknyl0FDjs7xDlcxlaRE7CcBx1ENxYkWK00UpeKTTlCQWKxq6t9QM6b",
        "cursor": next_cursor,
        "page_token": next_page_token,
        "token": "API_TOKEN",
    }
).json()["data"]

next_cursor = result["nextCursor"]
next_page_token = result["nextPageToken"]
result = client.tiktok.user_followings(
    id="6784819479778378757",
    sec_uid="MS4wLjABAAAAQ45...",
    cursor=next_cursor,
    page_token=next_page_token,
)

next_cursor = result.data.get("nextCursor")
next_page_token = result.data.get("nextPageToken")
result = await client.tiktok.userFollowings({
    id: "6784819479778378757",
    secUid: "MS4wLjABAAAAQ45...",
    cursor: nextCursor,
    pageToken: nextPageToken,
});

nextCursor = result.data.nextCursor;
nextPageToken = result.data.nextPageToken;

Easy! We successfully used the cursor to get more results. You can continue this process until there is no nextCursor or nextPageToken in the response, which indicates that there are no more retrievable results.