TikTokApi.api.video module

class TikTokApi.api.video.Video(id: str | None = None, url: str | None = None, data: dict | None = None, **kwargs)[source]

Bases: object

A TikTok Video class

Example Usage `py video = api.video(id='7041997751718137094') `

as_dict: dict

The raw data associated with this Video.

author: User | None

The User who created the Video

async bytes(stream: bool = False, **kwargs) bytes | AsyncIterator[bytes][source]

Returns the bytes of a TikTok Video.

Example Usage:
video_bytes = await api.video(id='7041997751718137094').bytes()

# Saving The Video
with open('saved_video.mp4', 'wb') as output:
    output.write(video_bytes)

# Streaming (if stream=True)
async for chunk in api.video(id='7041997751718137094').bytes(stream=True):
    # Process or upload chunk
async comments(count=20, cursor=0, **kwargs) Iterator[Comment][source]

Returns the comments of a TikTok Video.

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

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

Returns:

Yields TikTokApi.comment objects.

Return type:

async iterator/generator

Example Usage .. code-block:: python

async for comment in api.video(id=’7041997751718137094’).comments():

# do something

```

create_time: datetime | None

The creation time of the Video

hashtags: list[Hashtag] | None

A List of Hashtags on the Video

id: str | None

TikTok’s ID of the Video

async info(**kwargs) dict[source]

Returns a dictionary of all data associated with a TikTok Video.

Note: This is slow since it requires an HTTP request, avoid using this if possible.

Returns:

A dictionary of all data associated with a TikTok Video.

Return type:

dict

Raises:

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

Example Usage:
url = "https://www.tiktok.com/@davidteathercodes/video/7106686413101468970"
video_info = await api.video(url=url).info()
parent: ClassVar[TikTokApi]
async related_videos(count: int = 30, cursor: int = 0, **kwargs) Iterator[Video][source]

Returns related videos of a TikTok Video.

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

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

Returns:

Yields TikTokApi.video objects.

Return type:

async iterator/generator

Example Usage .. code-block:: python

async for related_videos in api.video(id=’7041997751718137094’).related_videos():

# do something

```

sound: Sound | None

The Sound that is associated with the Video

stats: dict | None

TikTok’s stats of the Video

url: str | None

The URL of the Video