Skip to content

Fetching Users

At the core of TikTok are the users; those posting content and interacting with it. As such, the first item we'll take a look at is how we can fetch TikTok account data and what sort of information we can find.

The EnsembleData has two endpoints for fetching user information. The first reqiures a TikTok username, while the second requires a TikTok secuid. Let's take a look.

User Info From Username API

API Documentation

Sample Response

This is the slightly simpler of the two endpoints; we need to supply a TikTok username, which is easier to find, and we're done.

import requests

result = requests.get(
    "https://ensembledata.com/apis/tt/user/info",
    params={
        "username": "daviddobrik",
        "token": "API_TOKEN",
    }
).json()["data"]

user = result["user"]
stats = result["stats"]
from ensembledata.api import EDClient

client = EDClient("API_TOKEN")
result = client.tiktok.user_info_from_username(
    username="daviddobrik"
)

user = result.data["user"]
stats = result.data["stats"]
import { EDClient } from "ensembledata";

const client = new EDClient({ token: "API_TOKEN" });
const result = await client.tiktok.userInfoFromUsername({
    username: "daviddobrik"
});

const user = result.data.user;
const stats = result.data.stats;

User data

There is a whole lot of information inside the user object. Here useful fields you can find inside the user object are:

  • id: The user's primary user id which you may need for other API calls.
  • secUid: The user's secondary user id which you may need for other API calls.
  • nickname: The user's display name.
  • signature: The user's TikTok bio.
  • verified: Whether the user is verified on TikTok.
  • language
  • region
  • ins_id: The user's Instagram id if they have connected their Instagram account.
  • youtube_channel_id: The user's YouTube channel title if they have connected their YouTube account.
  • avatar...: Various avatar fields which contains the profile picture in different resolutions.

Tip

The avatar... fields in the user object contain links to the profile picture that expire after a relatively short period of time. If you want to be able to access the profile picture later on, you should download it and store it yourself. Otherwise, you'll need to send another request later on to get the profile picture again.

User stats

Here's a little overview of what you'll find in the user stats:

{
    "user": ...,
    "stats": {
        "followingCount": 214, // Number of users this user is following
        "followerCount": 26357770,
        "heartCount": 1304183341, // Total number of likes this user's videos have received
        "videoCount": 629, // Total number of videos this user has posted
        "diggCount": 7244, // Total number of videos this user has liked
    }
}

User Info From Secuid API

API Documentation

Sample Response

This endpoint requires a TikTok secuid.

result = requests.get(
    "https://ensembledata.com/apis/tt/user/info-from-secuid",
    params={
        "secUid": "MS4wLjABAAAALJEOFGMMb1NGn73hAlyCaNThVNS4NE9WfE-T4JA_mtg",
        "token": "API_TOKEN",
    }
).json()["data"]

user = result["user"]
result = client.tiktok.user_info_from_secuid(
    sec_uid="MS4wLjABAAAALJEOFGMMb1NGn73hAlyCaNThVNS4NE9WfE-T4JA_mtg"
)
user = result.data["user"] 
const result = await client.tiktok.userInfoFromSecuid({
    secUid: "MS4wLjABAAAALJEOFGMMb1NGn73hAlyCaNThVNS4NE9WfE-T4JA_mtg"
});

const user = result.data.user;

Where do I find the secuid?

You'll find the secuid in the response payloads for other EnsembleData TikTok API endpoints. For example, in the response payload for the Post Info API, you'll find the secuid under the author object. If you're not using other endpoints, we would recommend using the User Info From Username API instead of this one.

User data

Many of the fields are the same as what you will find in the User Info From Username API response, though there are differences. For example, the user ids in this response are instead found under uid and sec_uid.

User stats

  • aweme_count: Total number of videos this user has posted
  • follower_count: Number of followers this user has
  • following_count: Number of users this user is following
  • total_favorited: Total number of likes this user's videos have received
  • favoriting_count: Number of videos this user has liked

Alternative method

Sample Response

There is an optional parameter to this endpoint called alternative_method. By default it is set to false, but if you set it to true, the API will use an alternative method to fetch the user data. When using the the alternative method, the response payload will differ, though there may be some extra information available which you won't find in the default response.

Tip

We recommend, checking out the full response payload with the alternative_method both enabled and disabled to see which option is most appropriate for your use case.