### Run example script with python -m Source: https://github.com/davidteather/tiktok-api/blob/main/README.md Runs the trending example script from the repository root using the -m option. Assumes the examples module is available in the current directory. ```sh python -m examples.trending_example ``` -------------------------------- ### Get playlist videos (basic) Source: https://github.com/davidteather/tiktok-api/blob/main/_autodocs/api-reference/playlist.md Basic example of calling `videos`. Note that this is an async generator, so you must use `async for` to iterate over the results, as shown in the next example. ```python playlist_videos = await api.playlist(id='7426714779919797038').videos() ``` -------------------------------- ### Nested user playlists and videos Source: https://github.com/davidteather/tiktok-api/blob/main/_autodocs/api-reference/playlist.md Nested example: get a user's playlists, then for each playlist get its videos. Demonstrates the `user.playlists()` and `playlist.videos()` async generators together. ```python user = api.user('therock') async for playlist in user.playlists(count=3): print(playlist.name) async for video in playlist.videos(count=3): print(" ", video.id) ``` -------------------------------- ### Basic usage example Source: https://github.com/davidteather/tiktok-api/blob/main/_autodocs/api-reference/tiktok-api.md Basic example showing how to create a TikTokApi instance, create sessions, iterate over trending videos, and close sessions. Uses asyncio.run(). ```python import asyncio import logging from TikTokApi import TikTokApi async def main(): api = TikTokApi(logging_level=logging.DEBUG) await api.create_sessions(num_sessions=1) async for video in api.trending.videos(count=3): print(video.id) await api.close_sessions() asyncio.run(main()) ``` -------------------------------- ### playlists with cursor pagination example Source: https://github.com/davidteather/tiktok-api/blob/main/_autodocs/api-reference/user.md Iterates over playlists starting from cursor 100 with a count of 50, printing playlist ID and video count. ```python async for playlist in api.user('tiktok').playlists(count=50, cursor=100): print(playlist.id, playlist.video_count) ``` -------------------------------- ### info() basic example Source: https://github.com/davidteather/tiktok-api/blob/main/_autodocs/api-reference/video.md Fetches video info for a given URL and prints the description. ```python url = "https://www.tiktok.com/@davidteathercodes/video/7106686413101468970" video_info = await api.video(url=url).info() print(video_info['desc']) ``` -------------------------------- ### bytes() basic example Source: https://github.com/davidteather/tiktok-api/blob/main/_autodocs/api-reference/video.md Downloads the video file and saves it to a local file. ```python video_bytes = await api.video(id='7041997751718137094').bytes() with open('saved_video.mp4', 'wb') as output: output.write(video_bytes) ``` -------------------------------- ### run_fetch_script usage example Source: https://github.com/davidteather/tiktok-api/blob/main/_autodocs/api-reference/tiktok-api.md Example usage of run_fetch_script, passing a URL and headers dictionary. The result is awaited and stored in a variable. ```python result = await api.run_fetch_script(url, {"User-Agent": "..."}) ``` -------------------------------- ### Video.__init__ Source: https://github.com/davidteather/tiktok-api/blob/main/_autodocs/api-reference/video.md Documentation for the Video class constructor, including parameters, exceptions, and usage examples. ```APIDOC ## Video ### Description A TikTok Video entity. Public docstring: "A TikTok Video class". ### Constructor ```python def __init__( self, id: Optional[str] = None, url: Optional[str] = None, data: Optional[dict] = None, **kwargs, ): ``` Docstring: "You must provide the id or a valid url, else this will fail." #### Parameters | Parameter | Type | Required | Default | Description | |-----------|------|----------|---------|-------------| | `id` | `Optional[str]` | no (see note) | `None` | TikTok video ID | | `url` | `Optional[str]` | no (see note) | `None` | A `https://www.tiktok.com/@user/video/` URL; the ID is extracted with `extract_video_id_from_url` (which does a redirect-following `requests.head`), using the session headers/proxy | | `data` | `Optional[dict]` | no | `None` | Raw TikTok dict — parsed via `__extract_from_data()` | | `**kwargs` | — | no | — | `proxy: dict` override for the URL-extraction HTTP call | #### Throws - `TypeError("You must provide id or url parameter.")` — when neither `id`, `url`, nor a `data` with an `id` is available (`video.py:73-75`). - `TypeError` — raised by `helpers.extract_video_id_from_url` for unsupported URL formats (see [Helpers](helpers.md)). #### Example (basic) ```python video = api.video(id='7041997751718137094') ``` #### Example (from a share URL, with fallback) ```python try: video = api.video(url="https://www.tiktok.com/@therock/video/6829267836783971589") except TypeError as e: print("Unsupported URL format:", e) ``` Source: `TikTokApi/api/video.py:48`. ``` -------------------------------- ### User.__init__ Source: https://github.com/davidteather/tiktok-api/blob/main/_autodocs/api-reference/user.md Documentation for the User class constructor, including parameters, examples, and usage notes. ```APIDOC ## User ### Description A TikTok User entity. This class represents a TikTok user and provides methods to interact with user data. ### Constructor ```python def __init__( self, username: Optional[str] = None, user_id: Optional[str] = None, sec_uid: Optional[str] = None, data: Optional[dict] = None, ): ``` You must provide the username or (user_id and sec_uid) otherwise this will not function correctly. #### Parameters | Parameter | Type | Required | Default | Description | |-----------|------|----------|---------|-------------| | `username` | `Optional[str]` | no (see note) | `None` | The TikTok username | | `user_id` | `Optional[str]` | no (see note) | `None` | Numeric user ID — only meaningful when paired with `sec_uid` | | `sec_uid` | `Optional[str]` | no (see note) | `None` | The secret UID required to fetch user data | | `data` | `Optional[dict]` | no | `None` | Raw TikTok dictionary; parsed by `__extract_from_data()` which reads either `userInfo` or top-level `id`/`secUid`/`uniqueId` keys (`user.py:249-268`) | #### Throws - None at construction (validation happens in `info()`); `TypeError("You must provide the username when creating this class to use this method.")` when `info()` is called without a username (`user.py:63-64`). #### Example (basic) ```python user = api.user(username='therock') ``` #### Example (by id/sec_uid, plus data object) ```python user = api.user(user_id="123456789", sec_uid="abcdef123456") # or build from a raw dict you already have: user = api.user(data={"userInfo": {"user": {"id": "1", "secUid": "s1", "uniqueId": "therock"}}}) ``` Source: `TikTokApi/api/user.py:32`. ``` -------------------------------- ### generate_js_fetch usage example Source: https://github.com/davidteather/tiktok-api/blob/main/_autodocs/api-reference/tiktok-api.md Example usage of generate_js_fetch, generating JavaScript for a GET request and printing the resulting string. ```python js = api.generate_js_fetch("GET", "https://www.tiktok.com", {"accept": "application/json"}) print(js) ``` -------------------------------- ### Async context manager usage example Source: https://github.com/davidteather/tiktok-api/blob/main/_autodocs/api-reference/tiktok-api.md Example of using TikTokApi as an async context manager. Sessions, browser, and playwright are torn down on exit. ```python async with TikTokApi() as api: await api.create_sessions(num_sessions=1) # sessions, browser, and playwright are all torn down on exit ``` -------------------------------- ### Install TikTokApi and Playwright Source: https://github.com/davidteather/tiktok-api/blob/main/README.md Install the TikTokApi package and the Playwright browser. Requires Python 3.9+. ```sh pip install TikTokApi python -m playwright install ``` -------------------------------- ### Constructor Source: https://github.com/davidteather/tiktok-api/blob/main/_autodocs/api-reference/tiktok-api.md Initializes a TikTokApi instance. No network work happens here; connectivity starts at `create_sessions()`. ```APIDOC ## Constructor ### Description Initializes a TikTokApi instance. No network work happens here; connectivity starts at `create_sessions()`. ### Method Constructor ### Signature ```python def __init__(self, logging_level: int = logging.WARN, logger_name: str = None): ``` ### Parameters - `logging_level` (int) - Optional - Logging level for the library logger. Default: `logging.WARN`. - `logger_name` (str) - Optional - Name of the logger; if `None`, defaults to `__name__` (i.e. `TikTokApi.tiktok`). ### Returns `TikTokApi` instance. ### Throws None. ### Example (basic) ```python import asyncio import logging from TikTokApi import TikTokApi async def main(): api = TikTokApi(logging_level=logging.DEBUG) await api.create_sessions(num_sessions=1) async for video in api.trending.videos(count=3): print(video.id) await api.close_sessions() asyncio.run(main()) ``` ### Example (context-manager + explicit logger name) ```python import asyncio from TikTokApi import TikTokApi async def main(): async with TikTokApi(logger_name="my.app.tiktok") as api: await api.create_sessions(ms_tokens=[...], num_sessions=2, sleep_after=3) await api.health_check() ``` ``` -------------------------------- ### Basic videos() usage Source: https://github.com/davidteather/tiktok-api/blob/main/_autodocs/api-reference/user.md Basic usage example from the docstring. Iterates over videos for a user and prints each video's ID. ```python async for video in api.user(username="davidteathercodes").videos(): # do something print(video.id) ``` -------------------------------- ### Create user by username Source: https://github.com/davidteather/tiktok-api/blob/main/_autodocs/api-reference/user.md Basic example of creating a User object by username. This is the simplest way to instantiate a user. ```python user = api.user(username='therock') ``` -------------------------------- ### Fetch sound info Source: https://github.com/davidteather/tiktok-api/blob/main/_autodocs/api-reference/sound.md Basic example of calling info() on a Sound instance. Returns a dict with raw sound details. ```python sound_info = await api.sound(id='7016547803243022337').info() ``` -------------------------------- ### videos() with count and cursor Source: https://github.com/davidteather/tiktok-api/blob/main/_autodocs/api-reference/user.md Example showing how to limit the number of videos and set a cursor offset. Prints the description of each video. ```python async for video in api.user('therock').videos(count=5, cursor=30): print(video.as_dict['desc']) ``` -------------------------------- ### Context-manager example with explicit logger name Source: https://github.com/davidteather/tiktok-api/blob/main/_autodocs/api-reference/tiktok-api.md Example using TikTokApi as an async context manager with a custom logger name. It creates sessions with ms_tokens and performs a health check. ```python import asyncio from TikTokApi import TikTokApi async def main(): async with TikTokApi(logger_name="my.app.tiktok") as api: await api.create_sessions(ms_tokens=[...], num_sessions=2, sleep_after=3) await api.health_check() ``` -------------------------------- ### Session cookie usage example Source: https://github.com/davidteather/tiktok-api/blob/main/_autodocs/api-reference/tiktok-api.md Example usage of get_session_cookies and set_session_cookies. Retrieves cookies from a session, prints a specific cookie value, and then sets them back on the session. ```python cookies = await api.get_session_cookies(session) print(cookies.get("msToken")) await api.set_session_cookies(session, cookies) ``` -------------------------------- ### info basic usage example Source: https://github.com/davidteather/tiktok-api/blob/main/_autodocs/api-reference/user.md Fetches user info for the 'tiktok' user and prints the follower count. ```python user_data = await api.user(username='tiktok').info() print(user_data['stats']['followerCount']) ``` -------------------------------- ### Create Video by ID Source: https://github.com/davidteather/tiktok-api/blob/main/_autodocs/api-reference/video.md Basic example of creating a Video instance by providing the TikTok video ID. ```python video = api.video(id='7041997751718137094') ``` -------------------------------- ### bytes() streaming example Source: https://github.com/davidteather/tiktok-api/blob/main/_autodocs/api-reference/video.md Streams video chunks asynchronously for processing or uploading. ```python async for chunk in api.video(id='7041997751718137094').bytes(stream=True): # Process or upload chunk pass ``` -------------------------------- ### GET /api/music/item_list/ Source: https://github.com/davidteather/tiktok-api/blob/main/_autodocs/endpoints.md Endpoint for retrieving videos associated with a sound. ```APIDOC ## GET /api/music/item_list/ ### Description Retrieves a list of videos associated with a specific sound (music). This endpoint is used by the `Sound.videos` method to fetch videos for a given music ID. ### Method GET ### Endpoint https://www.tiktok.com/api/music/item_list/ ### Parameters #### Query Parameters - **musicID** (string) - Required - The ID of the sound/music. - **count** (integer) - Required - Fixed value of 30. - **cursor** (integer) - Required - Paging cursor for pagination. ### Response #### Success Response (200) - **itemList** (array) - List of video items. - **hasMore** (boolean) - Indicates if more items are available. - **cursor** (integer) - Cursor for the next page. #### Response Example { "itemList": [], "hasMore": false, "cursor": 0 } ``` -------------------------------- ### Iterate over sound videos Source: https://github.com/davidteather/tiktok-api/blob/main/_autodocs/api-reference/sound.md Basic example of iterating over videos associated with a sound. count defaults to 30, cursor defaults to 0. ```python async for video in api.sound(id='7016547803243022337').videos(count=30): print(video) print(video.as_dict) ``` -------------------------------- ### Create Sound by ID Source: https://github.com/davidteather/tiktok-api/blob/main/_autodocs/api-reference/sound.md Basic example of creating a Sound instance by providing the TikTok sound ID. This is the recommended way to instantiate the class. ```python sound = api.sound(id='7016547803243022337') ``` -------------------------------- ### Basic example: random_choice Source: https://github.com/davidteather/tiktok-api/blob/main/_autodocs/api-reference/helpers.md Imports random_choice and demonstrates its usage: returns a random element from a list, or None for an empty list. ```python from TikTokApi.helpers import random_choice token = random_choice(["a", "b", "c"]) # 'a' | 'b' | 'c' none_val = random_choice([]) # None ``` -------------------------------- ### Basic search_type example Source: https://github.com/davidteather/tiktok-api/blob/main/_autodocs/api-reference/search.md Basic usage of api.search.search_type to search for users. Requires ms_token to have performed a search before. ```python async for user in api.search.search_type('david teather', 'user'): # do something print(user) ``` -------------------------------- ### playlists basic usage example Source: https://github.com/davidteather/tiktok-api/blob/main/_autodocs/api-reference/user.md Iterates over the first three playlists of the 'therock' user and prints each playlist's name. ```python user = api.user(username='therock') async for playlist in user.playlists(count=3): print(playlist.name) ``` -------------------------------- ### Check sound metadata then list videos Source: https://github.com/davidteather/tiktok-api/blob/main/_autodocs/api-reference/sound.md Advanced example: first fetch sound metadata with info(), then iterate over a limited number of videos. Shows how to access sound attributes and video properties. ```python sound = api.sound(id='7016547803243022337') await sound.info() print(f"'{sound.title}' by {sound.author} ({sound.duration}s)") async for video in sound.videos(count=5): print(video.id, video.create_time) ``` -------------------------------- ### Basic example: extract_video_id_from_url Source: https://github.com/davidteather/tiktok-api/blob/main/_autodocs/api-reference/helpers.md Imports extract_video_id_from_url and uses it to get a video ID from a standard TikTok URL. The function returns the video ID as a string. ```python from TikTokApi.helpers import extract_video_id_from_url video_id = extract_video_id_from_url("https://www.tiktok.com/@therock/video/6829267836783971589") ``` -------------------------------- ### Iterate over video comments Source: https://github.com/davidteather/tiktok-api/blob/main/_autodocs/api-reference/comment.md Basic example of iterating over comments of a video. Uses api.video() to get a video object and then iterates over its comments, printing text and raw dict. ```python video = api.video(id='7248300636498890011') async for comment in video.comments(count=30): print(comment.text) print(comment.as_dict) ``` -------------------------------- ### stop_playwright usage example Source: https://github.com/davidteather/tiktok-api/blob/main/_autodocs/api-reference/tiktok-api.md Example usage of the stop_playwright method. It closes the browser and stops playwright. ```python await api.stop_playwright() ``` -------------------------------- ### Basic create_sessions example Source: https://github.com/davidteather/tiktok-api/blob/main/_autodocs/api-reference/tiktok-api.md Basic usage of create_sessions to initialize a single session with an msToken from the environment. Requires the ms_token environment variable and optionally TIKTOK_BROWSER to select the browser. After creation, api.sessions contains the created sessions. ```python import asyncio, os from TikTokApi import TikTokApi async def main(): async with TikTokApi() as api: await api.create_sessions( ms_tokens=[os.environ["ms_token"]], num_sessions=1, sleep_after=3, browser=os.getenv("TIKTOK_BROWSER", "chromium"), ) print(len(api.sessions)) # 1 asyncio.run(main()) ``` -------------------------------- ### GET /api/recommend/item_list/ Source: https://github.com/davidteather/tiktok-api/blob/main/_autodocs/endpoints.md Endpoint for retrieving the trending feed. ```APIDOC ## GET /api/recommend/item_list/ ### Description Retrieves the trending (For-You) feed. This endpoint is used by the `Trending.videos` method to fetch recommended videos. ### Method GET ### Endpoint https://www.tiktok.com/api/recommend/item_list/ ### Parameters #### Query Parameters - **from_page** (string) - Required - Fixed value of "fyp". - **count** (integer) - Required - The count argument passed to the method. ### Response #### Success Response (200) - **itemList** (array) - List of video items. - **hasMore** (boolean) - Indicates if more items are available. #### Response Example { "itemList": [], "hasMore": false } ``` -------------------------------- ### GET /api/challenge/detail/ Source: https://github.com/davidteather/tiktok-api/blob/main/_autodocs/endpoints.md Endpoint for retrieving hashtag details. ```APIDOC ## GET /api/challenge/detail/ ### Description Retrieves detailed information about a hashtag (challenge). This endpoint is used by the `Hashtag.info` method to fetch hashtag details. ### Method GET ### Endpoint https://www.tiktok.com/api/challenge/detail/ ### Parameters #### Query Parameters - **challengeName** (string) - Required - The name of the hashtag/challenge. - **msToken** (string) - Optional - A token passed via `kwargs`. ### Response #### Success Response (200) - **challengeInfo** (object) - Contains the full hashtag details. #### Response Example { "challengeInfo": {} } ``` -------------------------------- ### Canonical usage with session creation Source: https://github.com/davidteather/tiktok-api/blob/main/_autodocs/api-reference/trending.md Canonical repository usage from examples/trending_example.py. Creates one session first with ms_tokens, then iterates over trending videos with count=30 and prints each video. ```python async with TikTokApi() as api: await api.create_sessions( ms_tokens=[ms_token], num_sessions=1, sleep_after=3, browser=os.getenv("TIKTOK_BROWSER", "chromium"), ) async for video in api.trending.videos(count=30): print(video) ``` -------------------------------- ### GET /api/challenge/item_list/ Source: https://github.com/davidteather/tiktok-api/blob/main/_autodocs/endpoints.md Endpoint for retrieving videos associated with a hashtag. ```APIDOC ## GET /api/challenge/item_list/ ### Description Retrieves a list of videos associated with a specific hashtag (challenge). This endpoint is used by the `Hashtag.videos` method to fetch videos for a given challenge ID. ### Method GET ### Endpoint https://www.tiktok.com/api/challenge/item_list/ ### Parameters #### Query Parameters - **challengeID** (string) - Required - The ID of the hashtag/challenge. If not set, it is resolved via `info()`. - **count** (integer) - Required - Fixed value of 30. - **cursor** (integer) - Required - Paging cursor for pagination. ### Response #### Success Response (200) - **itemList** (array) - List of video items. - **hasMore** (boolean) - Indicates if more items are available. - **cursor** (integer) - Cursor for the next page. #### Response Example { "itemList": [], "hasMore": false, "cursor": 0 } ``` -------------------------------- ### GET /api/comment/list/ Source: https://github.com/davidteather/tiktok-api/blob/main/_autodocs/endpoints.md Retrieves comments for a video using the TikTok API. ```APIDOC ## GET /api/comment/list/ ### Description Retrieves a list of comments for a video. ### Method GET ### Endpoint https://www.tiktok.com/api/comment/list/ ### Parameters #### Query Parameters - **aweme_id** (str) - Required - The ID of the video. - **count** (int) - Required - Fixed value: 20. - **cursor** (int) - Required - Paging cursor. ### Response #### Success Response (200) - **comments** (list) - List of comments. - **has_more** (bool) - Indicates if more comments are available. - **cursor** (int) - Next page cursor. ``` -------------------------------- ### Docker build and run TikTokApi Source: https://github.com/davidteather/tiktok-api/blob/main/README.md Build a Docker image from the repository and run a script inside a container. Assumes your script is named your_script.py in the root directory. ```sh docker pull mcr.microsoft.com/playwright:focal docker build . -t tiktokapi:latest docker run -v TikTokApi --rm tiktokapi:latest python3 your_script.py ``` -------------------------------- ### Import and use SCRIPTS Source: https://github.com/davidteather/tiktok-api/blob/main/_autodocs/api-reference/stealth.md Shows how to import SCRIPTS, print its length (19), and add a script to a page using add_init_script. The webdriver script is used as an example. ```python from TikTokApi.stealth.stealth import SCRIPTS print(len(SCRIPTS)) # 19 await page.add_init_script(SCRIPTS["webdriver"]) ``` -------------------------------- ### Sound.__init__ Source: https://github.com/davidteather/tiktok-api/blob/main/_autodocs/api-reference/sound.md Constructor for the Sound class. Requires either an id or data parameter. ```APIDOC ## Sound Constructor ### Description Creates a Sound object representing a TikTok sound/music/song. You must provide the id of the sound or it will not work. ### Method Constructor ### Endpoint `Sound.__init__(self, id: Optional[str] = None, data: Optional[str] = None)` ### Parameters - `id` (Optional[str]) - Optional - TikTok sound ID - `data` (Optional[str]) - Optional - Raw data dict (treated as data dict, not string) ### Throws - `TypeError` - When neither `id` nor `data` is supplied ### Request Example ```python sound = api.sound(id='7016547803243022337') ``` ### Response Returns a Sound object with attributes: `id`, `title`, `author`, `duration`, `original`, and optionally `play_url`, `cover_large`, `stats`. ### Response Example ```python sound = api.sound(data={'music': {'id': '7016547803243022337', 'title': 'My Song'}}) print(sound.title) ``` ``` -------------------------------- ### GET /api/music/detail/ Source: https://github.com/davidteather/tiktok-api/blob/main/_autodocs/endpoints.md Retrieves details for a specific sound using the TikTok API. ```APIDOC ## GET /api/music/detail/ ### Description Retrieves details for a specific sound (music). ### Method GET ### Endpoint https://www.tiktok.com/api/music/detail/ ### Parameters #### Query Parameters - **msToken** (str) - Optional - Token from kwargs. - **musicId** (str) - Required - The ID of the sound. ### Response #### Success Response (200) - **musicInfo** (object) - Full sound details. ``` -------------------------------- ### Playlist.__init__ Source: https://github.com/davidteather/tiktok-api/blob/main/_autodocs/api-reference/playlist.md Constructor for the Playlist class. Requires either a playlist ID or raw playlist data. ```APIDOC ## [CONSTRUCTOR] Playlist.__init__ ### Description Creates a Playlist object. You must provide the playlist id or playlist data otherwise this will not function correctly. ### Method Constructor ### Endpoint `Playlist.__init__(self, id: Optional[str] = None, data: Optional[dict] = None)` ### Parameters - **id** (Optional[str]) - Optional - TikTok playlist (mix) ID - **data** (Optional[dict]) - Optional - Raw playlist dict ### Throws - `TypeError` - with a real bug caveat: the guard reads `if id is None and data.get("id") is None:` and will raise `AttributeError` when `id` is `None` and `data` is `None` (calling `.get` on `None`). Behavior verified from source: provide `id` or a non-`None` `data` dict. ### Request Example ```python playlist = api.playlist(id='7426714779919797038') ``` ### Request Example (from data) ```python playlist = api.playlist(data={'mixInfo': {'id': '7426714779919797038', 'mixName': 'My Mix'}}) print(playlist.name) ``` ``` -------------------------------- ### GET /api/comment/list/reply/ Source: https://github.com/davidteather/tiktok-api/blob/main/_autodocs/endpoints.md Retrieves replies to a specific comment using the TikTok API. ```APIDOC ## GET /api/comment/list/reply/ ### Description Retrieves replies to a specific comment. ### Method GET ### Endpoint https://www.tiktok.com/api/comment/list/reply/ ### Parameters #### Query Parameters - **count** (int) - Required - Fixed value: 20. - **cursor** (int) - Required - Paging cursor. - **item_id** (str) - Required - The author's user ID. - **comment_id** (str) - Required - The ID of the comment. ### Response #### Success Response (200) - **comments** (list) - List of replies. - **has_more** (bool) - Indicates if more replies are available. - **cursor** (int) - Next page cursor. ``` -------------------------------- ### GET /api/related/item_list/ Source: https://github.com/davidteather/tiktok-api/blob/main/_autodocs/endpoints.md Retrieves related videos for a given video using the TikTok API. ```APIDOC ## GET /api/related/item_list/ ### Description Retrieves a list of related videos for a given video. ### Method GET ### Endpoint https://www.tiktok.com/api/related/item_list/ ### Parameters #### Query Parameters - **itemID** (str) - Required - The ID of the video. - **count** (int) - Required - Fixed value: 16. ### Response #### Success Response (200) - **itemList** (list) - List of related videos. ``` -------------------------------- ### Create playlist by ID Source: https://github.com/davidteather/tiktok-api/blob/main/_autodocs/api-reference/playlist.md Basic example creating a Playlist instance using a TikTok playlist (mix) ID. This is the recommended way to instantiate when you have the ID. ```python playlist = api.playlist(id='7426714779919797038') ``` -------------------------------- ### Create user by id/sec_uid or data dict Source: https://github.com/davidteather/tiktok-api/blob/main/_autodocs/api-reference/user.md Example of creating a User object by user_id and sec_uid, or from a raw data dictionary. The data dict is parsed by __extract_from_data() which reads either userInfo or top-level id/secUid/uniqueId keys. ```python user = api.user(user_id="123456789", sec_uid="abcdef123456") # or build from a raw dict you already have: user = api.user(data={"userInfo": {"user": {"id": "1", "secUid": "s1", "uniqueId": "therock"}}}) ```