### Start Debugging Session Source: https://github.com/rioanandaputra-bot/tiktok-docs-mcp/blob/main/docs/developers_tiktok_com/Docs/Mini Dramas/Debug Your Mini Drama.md Navigate to your project root in the terminal and run the 'minis dev' command to start the local development server. ```bash cd path/to/your/project/ minis dev ``` -------------------------------- ### Clone Repository and Run Scripts Source: https://github.com/rioanandaputra-bot/tiktok-docs-mcp/blob/main/README.md Quick start guide to clone the repository and execute the Python scripts to download TikTok API documentation. Requires Python 3.8+ and has no external dependencies. ```bash git clone https://github.com/your-username/tiktok-docs-mcp cd tiktok-docs-mcp # TikTok Platform API (developers.tiktok.com) python scripts/developers_tiktok_com.py # TikTok Shop Partner API (partner.tiktokshop.com) python scripts/partner_tiktokshop_com.py ``` -------------------------------- ### Navigate to Game Directory Source: https://github.com/rioanandaputra-bot/tiktok-docs-mcp/blob/main/docs/developers_tiktok_com/Docs/Mini Games/Debug Your Mini Game.md Use this command to enter your game project's directory before starting the debugging session. ```bash cd path/to/your-game-project ``` -------------------------------- ### Start Debugging Environment Source: https://github.com/rioanandaputra-bot/tiktok-docs-mcp/blob/main/docs/developers_tiktok_com/Docs/Mini Games/Debug Your Mini Game.md Run this command to initiate the debugging environment. Your app's client key will be requested once and stored for future sessions. ```bash ttmg dev ``` -------------------------------- ### Advertiser Query Response Example Source: https://github.com/rioanandaputra-bot/tiktok-docs-mcp/blob/main/docs/developers_tiktok_com/Docs/Commercial Content API/API Reference/Query Advertisers.md This is an example of a successful response when querying for advertisers. It includes a list of advertisers with their business ID, name, and country code. ```json { "data": { "advertisers": [ { "business_id": 1755645247067185, "business_name": "Awesome Food Co.", "country_code": "US" }, { "business_id": 183746395837294, "business_name": "Awesome Drink Co.", "country_code": "CA" } ] }, "error": { "code": "ok", "http_status_code": 200, "log_id": "202207280326050102231031430C7E754E", "message": "" } } ``` -------------------------------- ### Commercial Content Query Response Example Source: https://github.com/rioanandaputra-bot/tiktok-docs-mcp/blob/main/docs/developers_tiktok_com/Docs/Commercial Content API/API Reference/Query Commercial Content.md This is an example of a successful response when querying commercial content. It includes a list of commercial contents, pagination information (has_more), and a search_id for resuming searches. ```json { "data": { "commercial_contents": [ { "brand_names": [ "My Awesome Co.", "HelloWorld Inc." ], "create_date": "20230109", "create_timestamp": 1696875852, "creator": { "username": "joe1234567" }, "id": "v09044g40000ce6enu3c77u36l73sp20", "label": "Paid partnership", "videos": [ { "cover_image_url": "https://asdfcdn.com/17392712.jpeg?x-expires=1679169600\u0026x-signature=asdf", "url":"https://www.tiktok.com/@joe1234567/video/19384729204821234" } ] } ], "has_more": "true", "search_id": "2837438294054038" }, "error": { "code": "ok", "http_status_code": 200, "log_id": "202207280326050102231031430C7E754E", "message": "" } } ``` -------------------------------- ### Rewarded Ad Setup Source: https://github.com/rioanandaputra-bot/tiktok-docs-mcp/blob/main/docs/developers_tiktok_com/Docs/Mini Games/Capability Guides/In-App Ads.md This snippet demonstrates how to create a rewarded video ad instance, set up error and close event listeners, and display the ad. Each instance can only be shown once. ```APIDOC ## Rewarded Ad Setup ### Description This section details the process of setting up rewarded ads, which grant users in-game rewards after watching an ad. It involves obtaining a Placement ID, creating an ad instance using the SDK, and handling ad events. ### Method `TTMinis.game.createRewardedVideoAd` ### Parameters #### Request Body - **adUnitId** (string) - Required - The placement ID obtained from the TikTok Ads Manager. ### Request Example ```javascript const rewardedVideoAd = TTMinis.game.createRewardedVideoAd({ adUnitId: 'xxx' }); ``` ### Event Listeners #### `onError` - **Description**: Callback function that is triggered when an error occurs during ad video playback or material fetching. - **Example**: ```javascript rewardedVideoAd.onError(() => { console.log('ad display error'); }); ``` #### `onClose` - **Description**: Callback function that is triggered when the ad video is closed, either by the user or automatically due to an error. - **Example**: ```javascript rewardedVideoAd.onClose(() => { console.log('ad closed'); }); ``` ### Displaying the Ad #### Method `rewardedVideoAd.show()` ### Response #### Success Response (Promise resolves) - **Description**: Indicates that the ad has been successfully displayed. #### Failure Response (Promise rejects) - **Description**: Indicates that the ad failed to display. ### Request Example ```javascript rewardedVideoAd.show().then(() => { console.log('ad displayed'); }).catch(() => { console.log('ad failed to display'); }); ``` **Note**: Each instance of a rewarded video ad can only be shown once. After displaying, the instance is released, and a new instance must be created for subsequent ad displays. ``` -------------------------------- ### Access Token Response Example Source: https://github.com/rioanandaputra-bot/tiktok-docs-mcp/blob/main/docs/developers_tiktok_com/Docs/TikTok GO/Obtain Access Token for APIs.md This is an example of the JSON response you will receive upon successfully obtaining an access token. It includes the access token itself, its expiration time, and the refresh token with its expiration. ```json { "access_token": "xxx", "expires_in": 1749368707, "refresh_expires_in": 1906616707, "refresh_token": "xxx" } ``` -------------------------------- ### Embed URL with Customization Parameters Source: https://github.com/rioanandaputra-bot/tiktok-docs-mcp/blob/main/docs/developers_tiktok_com/Docs/Embed/Embed.md Example of an embed URL with parameters to display music information and the description. Customize the player by appending query parameters. ```html https://www.tiktok.com/player/v1/6718335390845095173?music_info=1&description=1 ``` -------------------------------- ### Get Ad Details Request Example Source: https://github.com/rioanandaputra-bot/tiktok-docs-mcp/blob/main/docs/developers_tiktok_com/Docs/Commercial Content API/API Reference/Get Ad Details.md This cURL command demonstrates how to request detailed information for a specific ad ID, specifying the desired fields in the query parameters and providing the ad ID in the request body. ```curl curl -L -X POST 'https://open.tiktokapis.com/v2/research/adlib/ad/detail/?fields=ad.id,ad.first_shown_date,ad.last_shown_date' \ -H 'Authorization: Bearer clt.example12345Example12345Example' \ -H 'Content-Type: application/json' \ --data-raw '{ \ "ad_id": 104836593772645 \ }' ``` -------------------------------- ### Configure package.json Scripts Source: https://github.com/rioanandaputra-bot/tiktok-docs-mcp/blob/main/docs/developers_tiktok_com/Docs/Mini Dramas/Debug Your Mini Drama.md Ensure your package.json includes 'dev' or 'start' scripts for the debugging tool to launch your TikTok Minis application. ```json { "scripts": { "dev": "..." // or "start" } } ``` -------------------------------- ### User Info Response Example Source: https://github.com/rioanandaputra-bot/tiktok-docs-mcp/blob/main/docs/developers_tiktok_com/Docs/Research Tools/API Reference/Query User Info.md This JSON object shows a successful response from the Query User Info endpoint, containing various details about the requested user. ```json { "data": { "bio_description": "my_bio", "is_verified": false, "likes_count": 27155089, "video_count": 44, "avatar_url": "https://some_cdn.com/my_avatar", "follower_count": 232, "following_count": 45, "display_name": "my nick name" }, "error": { "code": "ok", "message": "", "log_id": "202207280326050102231031430C7E754E" } } ``` -------------------------------- ### Query User Info Request Example Source: https://github.com/rioanandaputra-bot/tiktok-docs-mcp/blob/main/docs/developers_tiktok_com/Docs/Research Tools/API Reference/Query User Info.md This cURL command demonstrates how to request user information, specifying the desired fields in the query parameters and providing the username in the JSON body. ```curl curl -L 'https://open.tiktokapis.com/v2/research/user/info/?fields=display_name,bio_description,avatar_url,is_verified,follower_count,following_count,likes_count,video_count' \ -H 'Authorization: Bearer clt.example12345Example12345Example' \ -H 'Content-Type:application/json' \ -d '{"username": "joe123456"}' ``` -------------------------------- ### Data Request Status Response Example Source: https://github.com/rioanandaputra-bot/tiktok-docs-mcp/blob/main/docs/developers_tiktok_com/Docs/Data Portability API/API Reference/Check Status of Data Request.md This is an example of a successful response when checking the status of a data request. It includes details such as the request ID, application time, collection time, current status, data format, and the categories selected for the data request. ```json { "data": { "apply_time": 1703186989, "category_selection_list": [ "profile", "video", "direct_messages" ], "collect_time": 1703187862, "data_format": "text", "request_id": 123451234512345, "status": "downloading" }, "error": { "code": "ok", "message": "", "log_id": "2023242526272829300000000000001111" } } ``` -------------------------------- ### Review Info Response Example Source: https://github.com/rioanandaputra-bot/tiktok-docs-mcp/blob/main/docs/developers_tiktok_com/Docs/Research Tools/API Reference/Query TikTok Shop Reviews.md This is an example of a successful response from the TikTok Shop Reviews API. It includes a 'data' object containing an array of 'review_data', where each item represents a product review with its associated details. ```json { "data": { "review_data": [ { "create_time": 1722879716021, "product_name": "Test Product Name", "review_like_count": 1, "review_rating": "FIVE", "review_text": " test Text" } ] } } ``` -------------------------------- ### Query Playlist Info Request Example Source: https://github.com/rioanandaputra-bot/tiktok-docs-mcp/blob/main/docs/developers_tiktok_com/Docs/Research Tools/API Reference/Query Playlist Info.md Use this cURL command to send a POST request to the API to retrieve playlist information. Ensure you include the necessary Authorization header and Content-Type. ```curl curl --location 'https://open.tiktokapis.com/v2/research/playlist/info/?fields=playlist_id' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer abcdefghijklmn' \ --data '{ "playlist_id": 12345677654321, "max_count":100, "cursor":0 }' ``` -------------------------------- ### Initiate Payment with Mini Games SDK Source: https://github.com/rioanandaputra-bot/tiktok-docs-mcp/blob/main/docs/developers_tiktok_com/Docs/Mini Games/Capability Guides/In-App Purchases.md Call the `TTMinis.game.pay` endpoint from the Mini Games SDK to start the payment process after creating an order. Implement success, fail, and complete callbacks to handle the payment outcome. ```javascript TTMinis.game.pay({ trade_order_id: "{your_trade_order_id}", success: () => { // Do something if succeeded }, fail: (error) => { // Do something if failed }, complete: () => { // Do something if completed } }) ``` -------------------------------- ### Get Access Token Source: https://github.com/rioanandaputra-bot/tiktok-docs-mcp/blob/main/docs/developers_tiktok_com/Docs/TikTok GO/Obtain Access Token for APIs.md Use this endpoint to obtain an access token bundle for the first time after merchant approval for specific scopes. ```APIDOC ## POST https://open.tiktokapis.com/merchant/oauth/token/ ### Description Obtain an access token bundle after merchant approval for specific scopes. ### Method POST ### Endpoint https://open.tiktokapis.com/merchant/oauth/token/ ### Headers - Content-Type: application/x-www-form-urlencoded - x-tt-target-idc: alisg ### Request Body - **client_key** (string) - Required - Unique identification key provisioned to the partner - **client_secret** (string) - Required - Unique identification secret provisioned to the partner - **merchant_id** (string) - Required - Unique identification of merchant that partner applied for - **grant_type** (string) - Required - Action type such as `access_token` to retrieve access token ### Request Example ```curl curl --location 'https://open.tiktokapis.com/merchant/oauth/token/' \ --header 'x-tt-target-idc: alisg' \ --header 'Content-Type: application/x-www-form-urlencoded' \ --data-urlencode 'client_key=xxxxxxx' \ --data-urlencode 'client_secret=xxxxxxxx' \ --data-urlencode 'grant_type=access_token' \ --data-urlencode 'merchant_id=xxxxxx' ``` ### Response #### Success Response (200) - **access_token** (string) - Access token used for API call self identification - **expires_in** (int64) - Unix timestamp indicating when the access token expires - **refresh_token** (string) - Refresh token used to request a new access token when the current one expires - **refresh_expires_in** (int64) - Unix timestamp indicating when the refresh token expires #### Response Example ```json { "access_token": "xxx", "expires_in": 1749368707, "refresh_expires_in": 1906616707, "refresh_token": "xxx" } ``` ``` -------------------------------- ### Interstitial Ad Setup Source: https://github.com/rioanandaputra-bot/tiktok-docs-mcp/blob/main/docs/developers_tiktok_com/Docs/Mini Games/Capability Guides/In-App Ads.md This section refers to the general process for setting up interstitial ads, indicating that it follows the same procedure as rewarded ads but utilizes the interstitial ad JavaScript APIs. ```APIDOC ## Interstitial Ad Setup ### Description To set up interstitial ads for your mini games, follow the same process as described for rewarded ads, but use the interstitial ad JavaScript APIs instead. Refer to the provided link for specific API details. ### Reference [See the full list of JavaScript APIs for IAA](https://developers.tiktok.com/doc/mini-games-sdk-iaa#interstitial-ads) ``` -------------------------------- ### Query Creator Info Source: https://github.com/rioanandaputra-bot/tiktok-docs-mcp/blob/main/docs/developers_tiktok_com/Docs/Content Posting API/Content Posting API.md To initiate a direct post to a creator's account, you must first use the Query Creator Info endpoint to get the target creator's latest information. ```APIDOC ## POST /v2/post/publish/creator_info/query/ ### Description Retrieves the latest information for a target creator account, which is necessary to initiate a direct post. ### Method POST ### Endpoint https://open.tiktokapis.com/v2/post/publish/creator_info/query/ ### Parameters #### Headers - **Authorization** (string) - Required - Bearer token for authentication. - **Content-Type** (string) - Required - application/json; charset=UTF-8 ### Request Example ```json { "example": "curl --location --request POST 'https://open.tiktokapis.com/v2/post/publish/creator_info/query/\n--header 'Authorization: Bearer act.example12345Example12345Example' \n--header 'Content-Type: application/json; charset=UTF-8'" } ``` ### Response #### Success Response (200) - **data** (object) - Contains creator information. - **creator_avatar_url** (string) - URL of the creator's avatar. - **creator_username** (string) - The creator's username. - **creator_nickname** (string) - The creator's nickname. - **privacy_level_options** (array) - Available privacy settings for posts. - **comment_disabled** (boolean) - Indicates if comments are disabled. - **duet_disabled** (boolean) - Indicates if duets are disabled. - **stitch_disabled** (boolean) - Indicates if stitches are disabled. - **max_video_post_duration_sec** (integer) - Maximum allowed video duration in seconds. - **error** (object) - Contains error details. - **code** (string) - Error code. - **message** (string) - Error message. - **log_id** (string) - Unique log ID for the request. #### Response Example ```json { "data":{ "creator_avatar_url": "https://lf16-tt4d.tiktokcdn.com/obj/tiktok-open-platform/8d5740ac3844be417beeacd0df75aef1", "creator_username": "tiktok", "creator_nickname": "TikTok Official", "privacy_level_options": ["PUBLIC_TO_EVERYONE", "MUTUAL_FOLLOW_FRIENDS", "SELF_ONLY"] "comment_disabled": false, "duet_disabled": false, "stitch_disabled": true, "max_video_post_duration_sec": 300 }, "error": { "code": "ok", "message": "", "log_id": "202210112248442CB9319E1FB30C1073F3" } } ``` ``` -------------------------------- ### Query User Followers Request Example Source: https://github.com/rioanandaputra-bot/tiktok-docs-mcp/blob/main/docs/developers_tiktok_com/Docs/Research Tools/API Reference/Query User Followers.md This cURL command demonstrates how to make a POST request to the Query User Followers API. Ensure you replace placeholders with your actual access token and desired parameters. ```curl curl --location 'https://platform.tiktokapis.com/v2/research/user/followers/' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer clt.test123test123test123' \ --data '{ "username": "test_user", "max_count":3, "cursor": 12347764 }' ``` -------------------------------- ### Get Ad Details Response Example Source: https://github.com/rioanandaputra-bot/tiktok-docs-mcp/blob/main/docs/developers_tiktok_com/Docs/Commercial Content API/API Reference/Get Ad Details.md This JSON object represents a successful response from the Get Ad Details API, containing detailed information about the ad, its ad group targeting, and the advertiser. ```json { "data": { "ad": { "first_shown_date": 20210101, "id": 1923845247192304, "image_urls": [ "https://asdfcdn.com/17392712.jpeg?x-expires=1679169600\u0026x-signature=asdf" ], "last_shown_date": 20210101, "status": "active", "videos": [ {"url": "https://asdfcdn.com/..../127364jmdfjsa93d8cn30dm2di/?mime_type=video_mp4"}, {"url": "https://asdfcdn.com/..../1kmeidhfb38u21nd82hsk389fd/?mime_type=video_mp4"} ], "reach": { "unique_users_seen": "30K", "unique_users_seen_by_country": { "GB": "18K", "IT": "12K" } }, "rejection_info": { "affected_countries": ["FR", "IT"] } }, "ad_group": { "target" { "number_of_users_targeted": "50K", "country": ["IT", "GB"], "age": { "13-17": false, "18-24": false, "25-34": false, "35-44": true, "35-44": true, "55+": true, }, "gender": { "female": true, "male": true, "other_genders": true }, "audience_targeting": "No", "video_interactions": "Entertainment", "creator_interactions": "Talent", "interest": "News & Entertainment, Business Services" } }, "advertiser": { "business_id": 1755645247067185, "business_name": "Awesome Co.", "country_code": "US", "paid_by": "Awesome Co.", "tiktok_account": { "avatar_url": "https://asdf.tiktokcdn.com/1736254.jpeg?x-expires=1679169600\u0026x-signature=asdf", "follower_count": 26374, "profile_url": "https://www.tiktok.com/@awesome_co" } } }, "error": { "code": "ok", "http_status_code": 200, "log_id": "202207280326050102231031430C7E754E", "message": "" } } ``` -------------------------------- ### Get Ad Report Request Example Source: https://github.com/rioanandaputra-bot/tiktok-docs-mcp/blob/main/docs/developers_tiktok_com/Docs/Commercial Content API/API Reference/Get Ad Report.md This cURL command demonstrates how to request an ad report, specifying the date range, country code, and advertiser business IDs. ```curl curl -L -X POST 'https://open.tiktokapis.com/v2/research/adlib/ad/report/?fields=count_time_series_by_country' \ -H 'Authorization: Bearer clt.example12345Example12345Example' \ -H 'Content-Type: application/json' \ --data-raw '{ "filters":{ "ad_published_date_range": { "min": "20230102", "max": "20230109" }, "country_code":"ALL", "advertiser_business_ids":[21836478203048,3484763562784] } }' ``` -------------------------------- ### Ad Report Response Example Source: https://github.com/rioanandaputra-bot/tiktok-docs-mcp/blob/main/docs/developers_tiktok_com/Docs/Commercial Content API/API Reference/Get Ad Report.md This JSON object shows a sample response from the Get Ad Report API, including the ad count time series by country and error details. ```json { "data": { "count_time_series_by_country": { "IT": [{"date": "20210109", "count": 45}, {"date": "20210108", "count": 24}], "ES": [{"date": "20210109", "count": 48}, {"date": "20210108", "count": 22}], ... } }, "error": { "code": "ok", "http_status_code": 200, "log_id": "202207280326050102231031430C7E754E", "message": "" } } ``` -------------------------------- ### Initialize TikTok Minis SDK Source: https://github.com/rioanandaputra-bot/tiktok-docs-mcp/blob/main/docs/developers_tiktok_com/Docs/Mini Dramas/Capability Guides/Capability Guides.md Include this script in the head of your HTML to initialize the TikTok Minis SDK. Ensure your clientKey is correctly configured. ```html ``` -------------------------------- ### Manually Configure minis.config.json Source: https://github.com/rioanandaputra-bot/tiktok-docs-mcp/blob/main/docs/developers_tiktok_com/Docs/Mini Dramas/Debug Your Mini Drama.md Create a 'minis.config.json' file in your project root and define your development and build environment settings, including port, host, output directory, and HTML entry point. ```json { "dev": { "port": "3000", // The port your local dev server uses "host": "localhost" // Your local host (optional) }, "build": { "outputDir": "dist", // The output directory after building (e.g., dist, build) "htmlEntry": "public/index.html" // The relative path to your index.html } } ``` -------------------------------- ### Initialize TikTok Minis SDK Source: https://github.com/rioanandaputra-bot/tiktok-docs-mcp/blob/main/docs/developers_tiktok_com/Docs/Mini Dramas/Develop Your Mini Drama.md Include this JavaScript code in your index.html to load the SDK asynchronously and initialize it with your project's client key. ```html ``` -------------------------------- ### Initialize TikTok Minis SDK Source: https://github.com/rioanandaputra-bot/tiktok-docs-mcp/blob/main/docs/developers_tiktok_com/Docs/Mini Dramas/Debug Your Mini Drama.md Integrate the TikTok Minis SDK in your entry HTML file and initialize it with your client key. Ensure the client key matches the one used for local debugging. ```html tiktok-minis-demo
``` -------------------------------- ### Generate minis.config.json via CLI Source: https://github.com/rioanandaputra-bot/tiktok-docs-mcp/blob/main/docs/developers_tiktok_com/Docs/Mini Dramas/Debug Your Mini Drama.md Use the 'minis init' command in your project root to automatically generate the configuration file for development and build environments. ```bash cd path/to/your/project minis init ``` -------------------------------- ### Get User Pinned Videos Source: https://github.com/rioanandaputra-bot/tiktok-docs-mcp/blob/main/docs/developers_tiktok_com/Docs/Research Tools/API Reference/Query User Pinned Videos.md Retrieves a list of pinned videos for a specified TikTok user. Requires the 'research.data.basic' scope. ```APIDOC ## POST /v2/research/user/pinned_videos/ ### Description Retrieves a list of pinned videos for a specified TikTok user. ### Method POST ### Endpoint https://open.tiktokapis.com/v2/research/user/pinned_videos/ ### Headers - **Authorization** (string) - Required - The client access token obtained from /v2/oauth/token/. - **Content-Type** (string) - Required - The original media type of the resource (application/json). ### Query Parameters - **fields** (string) - Required - Field names for desired data to be returned. It is a comma-separated list. See Video Object for a full list of values. ### Request Body - **username** (string) - Required - The username as the unique identifier. ### Request Example ```curl curl --location 'https://open.tiktokapis.com/v2/research/user/pinned_videos/?fields=id,share_count,view_count,comment_count,like_count' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer clt.testtemp123test123test123' \ --data '{ "username": "test_username" }' ``` ### Response #### Success Response (200) - **data** (PinnedVideosData) - The returned pinned videos list. - **error** (ErrorStructV2) - Error object. ### PinnedVideosData - **pinned_videos_list** (list