AsyncTikTokAPI

class AsyncTikTokAPI(*, headless=None, data_dump_file=None, navigation_timeout=30, navigation_retries=0, context_kwargs=None, navigator_type=None, **kwargs)[source]

Bases: TikTokAPI

Asynchronous API used to scrape data from TikTok

Parameters:
  • headless (Optional[bool], default: None) – Whether to use headless browsing.

  • data_dump_file (Optional[str], default: None) – If the data scraped from TikTok should also be dumped to a JSON file before parsing, specify the name of the dump file (excluding ‘.json’).

  • navigation_timeout (float, default: 30) – How long (in milliseconds) page navigation should wait before timing out. Set to 0 to disable the timeout.

  • navigation_retries (int, default: 0) – How many times to retry navigation if network_timeout is exceeded. Set to 0 to not retry navigation.

  • context_kwargs (Optional[dict], default: None) – Any extra kwargs used to initialize the playwright browser context. For full details, see Browser::new_context().

  • navigator_type (Optional[Literal['Firefox', 'firefox', 'Chromium', 'chromium']], default: None) – DEPRECATED as of 0.1.13, left in for backwards-compatibility.

  • kwargs – Any extra kwargs used to initialize the playwright browser (e.g.: proxy, etc.). For full details, see BrowserType::launch().

Attributes

browser

The playwright Browser instance used for data scraping

context

The playwright Context instance used for data scraping

playwright

The playwright instance used for data scraping

Methods

challenge

Retrieve data on a Challenge (hashtag) from TikTok.

user

Retrieve data on a User from TikTok.

video

Retrieve data on a Video from TikTok.

async challenge(challenge_name, *, video_limit=-1)[source]

Retrieve data on a Challenge (hashtag) from TikTok. Only up to the video_limit most recent videos will be retrievable by the scraper.

Parameters:

challenge_name (str) – The name of the challenge. e.g.: "fyp"

Returns:

A Challenge object containing the scraped data

Return type:

Challenge

async user(user, *, video_limit=-1)[source]

Retrieve data on a User from TikTok. Only up to the video_limit most recent videos will be retrievable by the scraper.

Parameters:

user (str) – The unique user or id of the user. e.g.: for @tiktok, use "tiktok"

Returns:

A User object containing the scraped data

Return type:

User

async video(link_or_id)[source]

Retrieve data on a Video from TikTok. If the video is a slideshow, emulate_mobile must be set to True at API initialization or this method will raise a TikTokAPIError.

Parameters:

link_or_id (Union[int, str]) – The link to the video or its unique ID.

Returns:

A Video object containing the scraped data

Return type:

Video

property browser

The playwright Browser instance used for data scraping

property context

The playwright Context instance used for data scraping

property playwright

The playwright instance used for data scraping