TikTokApi.api.user module

class TikTokApi.api.user.User(username: str | None = None, user_id: str | None = None, sec_uid: str | None = None, data: dict | None = None)[source]

Bases: object

A TikTok User.

Example Usage:
user = api.user(username='therock')
as_dict: dict

The raw data associated with this user.

async info(**kwargs) dict[source]

Returns a dictionary of information associated with this User.

Returns:

A dictionary of information associated with this User.

Return type:

dict

Raises:

InvalidResponseException – If TikTok returns an invalid response, or one we don’t understand.

Example Usage:
user_data = await api.user(username='therock').info()
async liked(count: int = 30, cursor: int = 0, **kwargs) Iterator[Video][source]

Returns a user’s liked posts if public.

Parameters:
  • count (int) – The amount of recent likes you want returned.

  • cursor (int) – The the offset of likes from 0 you want to get.

Returns:

Yields TikTokApi.video objects.

Return type:

async iterator/generator

Raises:

InvalidResponseException – If TikTok returns an invalid response, the user’s likes are private, or one we don’t understand.

Example Usage:
async for like in api.user(username="davidteathercodes").liked():
    # do something
parent: ClassVar[TikTokApi]
sec_uid: str

The sec UID of the user.

user_id: str

The ID of the user.

username: str

The username of the user.

async videos(count=30, cursor=0, **kwargs) Iterator[Video][source]

Returns a user’s videos.

Parameters:
  • count (int) – The amount of videos you want returned.

  • cursor (int) – The the offset of videos from 0 you want to get.

Returns:

Yields TikTokApi.video objects.

Return type:

async iterator/generator

Raises:

InvalidResponseException – If TikTok returns an invalid response, or one we don’t understand.

Example Usage:
async for video in api.user(username="davidteathercodes").videos():
    # do something