### Create BufferSourceNode (incomplete example) Source: https://github.com/rioanandaputra-bot/tiktok-docs/blob/main/docs/developers_tiktok_com/Mini_Games.md Starts an example for creating a BufferSourceNode, but the code is truncated in the source. ```javascript const audioCtx = TTMinis.game.createWebAudioContext() const ``` -------------------------------- ### TTMinis.game.init() - Example Source: https://github.com/rioanandaputra-bot/tiktok-docs/blob/main/docs/developers_tiktok_com/Mini_Games.md Example of initializing the Mini Games SDK with a client key. ```javascript TTMinis.game.init({ clientKey: '{app-client-key}' }); ``` -------------------------------- ### mkdir example Source: https://github.com/rioanandaputra-bot/tiktok-docs/blob/main/docs/developers_tiktok_com/Mini_Games.md Creates a directory asynchronously. The example creates a directory named 'example' in the user data path with recursive set to false, and logs the result or error. ```javascript const fs = TTMinis.game.getFileSystemManager(); fs.mkdir({ dirPath: `${TTMinis.game.env.USER_DATA_PATH}/example`, recursive: false, success(res) { console.log(res) }, fail(res) { console.error(res) } }) ``` -------------------------------- ### mkdirSync example Source: https://github.com/rioanandaputra-bot/tiktok-docs/blob/main/docs/developers_tiktok_com/Mini_Games.md Creates a directory synchronously. The example creates a directory named 'example' in the user data path with recursive set to false, and logs the result or error. ```javascript const fs = TTMinis.game.getFileSystemManager() fs.mkdir({ dirPath: `${TTMinis.game.env.USER_DATA_PATH}/example`, recursive: false, success(res) { console.log(res) }, fail(res) { console.error(res) } }) ``` -------------------------------- ### GET /v2/user/info/ - Example Response Source: https://github.com/rioanandaputra-bot/tiktok-docs/blob/main/docs/developers_tiktok_com/Display_API.md Example JSON response from the user info endpoint containing user profile data and an error object with code 'ok'. ```json { "data":{ "user":{ "avatar_url":"https://p19-sign.tiktokcdn-us.com/tos-useast5-avt-0068-tx/b17f0e4b3a4f4a50993cf72cda8b88b8~c5_168x168.jpeg", "open_id":"723f24d7-e717-40f8-a2b6-cb8464cd23b4", "union_id":"c9c60f44-a68e-4f5d-84dd-ce22faeb0ba1", "display_name": "Tik Toker" } }, "error":{ "code":"ok", "message":"", "log_id":"20220829194722CBE87ED59D524E727021" } } ``` -------------------------------- ### getSystemInfoSync example Source: https://github.com/rioanandaputra-bot/tiktok-docs/blob/main/docs/developers_tiktok_com/Mini_Games.md Use during initialization to get layout information immediately. Blocks the main thread, so use sparingly. ```javascript try { const res = TTMinis.game.getSystemInfoSync() console.log(res.pixelRatio) console.log(res.windowWidth) console.log(res.windowHeight) console.log(res.language) console.log(res.version) console.log(res.platform) } catch (e) { // Do something when catch error } ``` -------------------------------- ### Get Access Token - Response Example Source: https://github.com/rioanandaputra-bot/tiktok-docs/blob/main/docs/developers_tiktok_com/TikTok_GO.md Example JSON response containing access_token, expires_in, refresh_expires_in, and refresh_token fields. ```json { "access_token": "xxx", "expires_in": 1749368707, "refresh_expires_in": 1906616707, "refresh_token": "xxx" } ``` -------------------------------- ### getWindowInfo example Source: https://github.com/rioanandaputra-bot/tiktok-docs/blob/main/docs/developers_tiktok_com/Mini_Games.md Returns an object with current device and window metrics. Supported starting from SDK version 0.2.0; compatibility handling is required for lower versions. ```javascript const windowInfo = TTMinis.game.getWindowInfo() console.log(windowInfo.pixelRatio) console.log(windowInfo.screenWidth) console.log(windowInfo.screenHeight) console.log(windowInfo.windowWidth) console.log(windowInfo.windowHeight) console.log(windowInfo.statusBarHeight) console.log(windowInfo.safeArea) console.log(windowInfo.screenTop) ``` -------------------------------- ### Get User Info Response Example Source: https://github.com/rioanandaputra-bot/tiktok-docs/blob/main/docs/developers_tiktok_com/Display_API.md Example response from the /v2/user/info/ endpoint. It contains a data object with the requested user fields and an error object with code, message, and log_id. ```json { "data":{ "user":{ "avatar_url":"https://p19-sign.tiktokcdn-us.com/tos-avt-0068-tx/b17f0e4b3a4f4a50993cf72cda8b88b8~c5_168x168.jpeg", "open_id":"723f24d7-e717-40f8-a2b6-cb8464cd23b4", "union_id":"c9c60f44-a68e-4f5d-84dd-ce22faeb0ba1" } }, "error":{ "code":"ok", "message":"", "log_id":"20220829194722CBE87ED59D524E727021" } } ``` -------------------------------- ### Example: TTMinis.getDeviceInfo usage Source: https://github.com/rioanandaputra-bot/tiktok-docs/blob/main/docs/developers_tiktok_com/Mini_Dramas.md Example usage of TTMinis.getDeviceInfo to access the device's bottomHeight. ```javascript const { data } = TTMinis.getDeviceInfo(); if (data) { const { bottomHeight } = data; // use the device info for your program } ``` -------------------------------- ### TTMinis.openBalance example Source: https://github.com/rioanandaputra-bot/tiktok-docs/blob/main/docs/developers_tiktok_com/Mini_Dramas.md Incomplete example of calling TTMinis.openBalance, likely for opening the balance page. ```javascript TTMinis.openBalance( ``` -------------------------------- ### TTMinis.game.setLoadingProgress() - Example Source: https://github.com/rioanandaputra-bot/tiktok-docs/blob/main/docs/developers_tiktok_com/Mini_Games.md Example of setting loading progress and handling success, fail, and complete callbacks. ```javascript TTMinis.game.setLoadingProgress({ progress: 1, success: () => { // do something when succeed }, fail: (error) => { // do something when failed } complete: () => { // do something when completed } }) ``` -------------------------------- ### Show surface coupon example with TTMinis.showSurfaceCoupon Source: https://github.com/rioanandaputra-bot/tiktok-docs/blob/main/docs/developers_tiktok_com/Mini_Dramas.md Example call to TTMinis.showSurfaceCoupon with a callback that checks is_success and handles success. ```typescript TTMinis.showSurfaceCoupon(function({ is_success }) => { if (is_success) { // Display successful } }) ``` -------------------------------- ### Run pod install Source: https://github.com/rioanandaputra-bot/tiktok-docs/blob/main/docs/developers_tiktok_com/Legacy_Products.md Run this command in the terminal to install the pods after adding the pod to your Podfile. ```bash pod install --repo-update ``` -------------------------------- ### Activate subscription example with TTMinis.activateSubscription Source: https://github.com/rioanandaputra-bot/tiktok-docs/blob/main/docs/developers_tiktok_com/Mini_Dramas.md Example call to TTMinis.activateSubscription with a callback that checks is_success and passes a trade_order_id option. ```typescript TTMinis.activateSubscription((result) => { if(result?.is_success) { // do something } else { // do something } }, { trade_order_id: 'your-trade-order-id', }) ``` -------------------------------- ### Example: TTMinis.enableCapture callback Source: https://github.com/rioanandaputra-bot/tiktok-docs/blob/main/docs/developers_tiktok_com/Mini_Dramas.md Example usage of TTMinis.enableCapture with a callback that checks the isSuccess flag. ```javascript TTMinis.enableCapture((response) => { if (response.isSuccess === true) { } )) ``` -------------------------------- ### Example minigame.manifest.json Source: https://github.com/rioanandaputra-bot/tiktok-docs/blob/main/docs/developers_tiktok_com/Mini_Games.md Example manifest file generated by the build command, describing the resource list for TikTok Minis service. ```json { "name": "minigame.manifest.json", "resource_list": [ { "type": "file", "name": "404.html" }, { "type": "file", "name": "android-chrome-192x192.png" }, { "type": "file", "name": "safari-pinned-tab.svg" }, { "type": "folder", "name": "static", "children": [ { "type": "folder", "name": "css", "children": [ { "type": "file", "name": "main.ec164663.css" }, { "type": "file", "name": "main.ec164663.css.map" } ] }, { "type": "folder", "name": "js", "children": [ { "type": "file", "name": "main.eca09dd8.js" }, { "type": "file", "name": "453.d855a71b.chunk.js" } ] } ] }, { "type": "file", "name": "index.html" } ] } ``` -------------------------------- ### Minis.pay example Source: https://github.com/rioanandaputra-bot/tiktok-docs/blob/main/docs/developers_tiktok_com/Mini_Dramas.md Example usage of Minis.pay with a callback that checks is_success and passes trade_order_id as "demo". ```javascript Minis.pay((result)=>{ if(result.is_success){ // do something } else { // do something } },{trade_order_id: "demo"}) ``` -------------------------------- ### copyFile example Source: https://github.com/rioanandaputra-bot/tiktok-docs/blob/main/docs/developers_tiktok_com/Mini_Games.md Copies a file asynchronously. The example copies 'hello.txt' to 'hello_copy.txt' in the user data path, logging the result or error. ```javascript const fs = TTMinis.game.getFileSystemManager() fs.copyFile({ srcPath: `${TTMinis.game.env.USER_DATA_PATH}/hello.txt`, destPath: `${TTMinis.game.env.USER_DATA_PATH}/hello_copy.txt` success(res) { console.log(res) }, fail(res) { console.error(res) } }) ``` -------------------------------- ### Decode audio data (incomplete example) Source: https://github.com/rioanandaputra-bot/tiktok-docs/blob/main/docs/developers_tiktok_com/Mini_Games.md Starts an example for decoding audio data using TTMinis.game.request, but the code is truncated in the source. ```javascript TTMinis.game.request({ url: url, ``` -------------------------------- ### Get User Pinned Videos Response Example Source: https://github.com/rioanandaputra-bot/tiktok-docs/blob/main/docs/developers_tiktok_com/Research_Tools.md Example response body for the Get User Pinned Videos endpoint. Shows the structure of the data object containing a pinned_videos_list array with video objects, and an error object with code, message, and log_id fields. ```json { "data": { "pinned_videos_list": [ { "like_count": 6205646, "share_count": 15864, "view_count": 44199736, "comment_count": 15597, "id": 7777777777777777777 }, { "share_count": 6630, "view_count": 16171042, "comment_count": 6830, "id": 3333333333333333333, "like_count": 1464523 }, { "comment_count": 2685, "id": 9999999999999999999, "like_count": 189552, "share_count": 4796, "view_count": 1305777 } ] }, "error": { "code": "ok", "message": "ok", "log_id": "202499999999999999999999999" } } ``` -------------------------------- ### Complete minis.config.json Example Source: https://github.com/rioanandaputra-bot/tiktok-docs/blob/main/docs/developers_tiktok_com/Mini_Dramas.md Complete example of minis.config.json with navbar, dev, build, and domain settings. The domain.allowList is required and specifies allowed API request domains. ```json // minis.config.json { "navbar": { "lightModeBgColor": "#ffffff", "darkModeBgColor": "#000000", }, "dev": { "port": "3000", "host": "localhost" }, "build": { "outputDir": "build", "htmlEntry": "public/index.html" }, "domain": { "allowList": ["https://www.xxx.com"] } } ``` -------------------------------- ### copyFileSync example Source: https://github.com/rioanandaputra-bot/tiktok-docs/blob/main/docs/developers_tiktok_com/Mini_Games.md Copies a file synchronously. The example copies 'hello.txt' to 'hello_copy.txt' in the user data path, logging the result or error. ```javascript const fs = TTMinis.game.getFileSystemManager(); try { fs.copyFileSync( `${TTMinis.game.env.USER_DATA_PATH}/hello.txt`, `${TTMinis.game.env.USER_DATA_PATH}/hello_copy.txt` ) } catch(e) { console.error(e) } ``` -------------------------------- ### minis.config.json Example Configuration Source: https://github.com/rioanandaputra-bot/tiktok-docs/blob/main/docs/developers_tiktok_com/Mini_Dramas.md Example configuration for minis.config.json showing navbar, dev, and build settings. Note that the build.htmlEntry and build.output values are shown as alternatives, not valid JSON syntax. ```json { "navbar": { "lightModeBgColor": "#ffffff", "darkModeBgColor": "#000000" }, "dev": { "port": "3000", "host": "localhost" }, "build": { "htmlEntry": "index.html" or "public/index.html" "output": "build" or "dist" } } ``` -------------------------------- ### GET /v2/user/info/ - Example Request Source: https://github.com/rioanandaputra-bot/tiktok-docs/blob/main/docs/developers_tiktok_com/Display_API.md Example curl request to retrieve user profile fields (open_id, union_id, avatar_url, display_name) using an access token. ```bash curl -L -X GET 'https://open.tiktokapis.com/v2/user/info/?fields=open_id,union_id,avatar_url,display_name' \ -H 'Authorization: Bearer act.example12345Example12345Example' ``` -------------------------------- ### Direct Post Video init with FILE_UPLOAD and response Source: https://github.com/rioanandaputra-bot/tiktok-docs/blob/main/docs/developers_tiktok_com/Content_Posting_API.md Initialize video upload with source=FILE_UPLOAD. The response provides publish_id and upload_url for the subsequent PUT upload. ```bash curl --location 'https://open.tiktokapis.com/v2/post/publish/video/init/' \ --header 'Authorization: Bearer act.example12345Example12345Example' \ --header 'Content-Type: application/json; charset=UTF-8' \ --data-raw '{ "post_info": { "title": "this will be a funny #cat video on your @tiktok #fyp", "privacy_level": "MUTUAL_FOLLOW_FRIENDS", "disable_duet": false, "disable_comment": true, "disable_stitch": false, "video_cover_timestamp_ms": 1000 }, "source_info": { "source": "FILE_UPLOAD", "video_size": 50000123, "chunk_size": 10000000, "total_chunk_count": 5 } }' ``` ```json 200 OK { "data": { "publish_id": "v_pub_file~v2-1.123456789", "upload_url": "https://open-upload.tiktokapis.com/video/?upload_id=67890&upload_token=Xza123" }, "error": { "code": "ok", "message": "", "log_id": "202210112248442CB9319E1FB30C1073F3" } } ``` -------------------------------- ### Publish video init response example Source: https://github.com/rioanandaputra-bot/tiktok-docs/blob/main/docs/developers_tiktok_com/Content_Posting_API.md Example response from the publish video init endpoint. Contains publish_id, upload_url (valid for one hour), and error details. The upload_url is only for source=FILE_UPLOAD. ```json 200 OK { "data": { "publish_id": "v_pub_file~v2-1.123456789", "upload_url": "https://open-upload.tiktokapis.com/video/?upload_id=67890&upload_token=Xza123" }, "error": { "code": "ok", "message": "", "log_id": "202210112248442CB9319E1FB30C1073F3" } } ``` -------------------------------- ### Get recharge tiers - Request body Source: https://github.com/rioanandaputra-bot/tiktok-docs/blob/main/docs/developers_tiktok_com/TikTok_Minis_Platform.md Example request body for the Get recharge tiers endpoint. It specifies the token type as "BEANS" and includes a list of tier IDs to retrieve details for. ```json { "token_type": "BEANS", "tier_ids": ["1731381720000100"] } ``` -------------------------------- ### Direct Post Video init with PULL_FROM_URL and response Source: https://github.com/rioanandaputra-bot/tiktok-docs/blob/main/docs/developers_tiktok_com/Content_Posting_API.md Initialize video upload with source=PULL_FROM_URL. The response provides publish_id for status checks. ```bash curl --location 'https://open.tiktokapis.com/v2/post/publish/video/init/' \ --header 'Authorization: Bearer act.example12345Example12345Example' \ --header 'Content-Type: application/json; charset=UTF-8' \ --data-raw '{ "post_info": { "title": "this will be a funny #cat video on your @tiktok #fyp", "privacy_level": "MUTUAL_FOLLOW_FRIENDS", "disable_duet": false, "disable_comment": true, "disable_stitch": false, "video_cover_timestamp_ms": 1000 }, "source_info": { "source": "PULL_FROM_URL", "video_url": "https://example.verified.domain.com/example_video.mp4" } }' ``` ```json 200 OK { "data": { "publish_id": "v_pub_url~v2.123456789" }, "error": { "code": "ok", "message": "", "log_id": "202210112248442CB9319E1FB30C1073F4" } } ``` -------------------------------- ### TTMinis.game.getLaunchOptionsSync() Source: https://github.com/rioanandaputra-bot/tiktok-docs/blob/main/docs/developers_tiktok_com/Mini_Games.md Synchronously retrieves the launch options that were provided when the mini game was cold-started. ```APIDOC ## TTMinis.game.getLaunchOptionsSync() ### Description Get the parameters during the cold start of the mini game. ### Return Value - **LaunchOptions** (object) - Contains `scene` (string) and `query` (object). ### Request Example ```typescript const launchOptions = TTMinis.game.getLaunchOptionsSync() ``` ``` -------------------------------- ### startEntranceMission usage example Source: https://github.com/rioanandaputra-bot/tiktok-docs/blob/main/docs/developers_tiktok_com/Mini_Games.md Calls startEntranceMission to guide repeat visits. Provides success, fail, and complete callbacks. ```javascript TTMinis.startEntranceMission({ success: () => { console.log("success"); }, fail: () => { console.log("fail"); }, complete: () => { sonsole.log("complete"); } }) ``` -------------------------------- ### Get Ad Details response example Source: https://github.com/rioanandaputra-bot/tiktok-docs/blob/main/docs/developers_tiktok_com/Commercial_Content_API.md Sample JSON response from the Get Ad Details API, containing ad metadata, advertiser info, reach metrics, and error details. Shows the structure of QueryAdData and ErrorStructV2. ```json { "data": { "ads": [ { "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_user_seen": "11K" } }, "advertiser": { "buisness_id": 3847236290405, "business_name": "Awe Food Co.", "paid_by": "Awe Co." } } ], "has_more": "true", "search_id": "2837438294054038" }, "error": { "code": "ok", "http_status_code": 200, "log_id": "202304280326050102231031430C7E754E", "message": "" } } ``` -------------------------------- ### Response Example for Video Init Source: https://github.com/rioanandaputra-bot/tiktok-docs/blob/main/docs/developers_tiktok_com/Content_Posting_API.md Example response for a successful video init request. The upload_url is only present for FILE_UPLOAD and is valid for one hour. The publish_id can be used to check the posting status. ```json 200 OK { "data": { "publish_id": "v_inbox_file~v2.123456789", "upload_url": "https://open-upload.tiktokapis.com/video/?upload_id=12345&upload_token=Xza123" }, "error": { "code": "ok", "message": "", "log_id": "202210112248442CB9319E1FB30C1073F3" } } ``` -------------------------------- ### Example: Initialize TikTok Minis SDK Source: https://github.com/rioanandaputra-bot/tiktok-docs/blob/main/docs/developers_tiktok_com/Mini_Dramas.md Example of initializing the TikTok Minis SDK with your app client key. After this, you can call any JavaScript API for TikTok Minis. ```javascript TTMinis.init({ clientKey: '{app-client-key}' }); ``` -------------------------------- ### Get recharge tiers - Response body Source: https://github.com/rioanandaputra-bot/tiktok-docs/blob/main/docs/developers_tiktok_com/TikTok_Minis_Platform.md Example response from the Get recharge tiers endpoint. It contains a tier_infos map keyed by tier_id, with details such as tier_name, token_amount, price, currency, and symbol. The error object includes a code, message, and log_od. ```json { "data": { "tier_infos": { "1731381720000100": { "tier_id": "1731381720000100", "tier_name": "pd_beans_showcase_100", "token_amount": 100, "token_type": "BEANS", "price": "1.19", "currency": "USD", "symbol": "$" } } }, "error": { "code": "ok", "message": "", "log_od": "202411190743174589D30620D104990F", } } ``` -------------------------------- ### Get storage info asynchronously with TTMinis.game.getStorageInfo Source: https://github.com/rioanandaputra-bot/tiktok-docs/blob/main/docs/developers_tiktok_com/Mini_Games.md Asynchronously obtains storage information. Supported from SDK version 0.8.0. The example is incomplete in the source. ```javascript TTMinis.game.getStorageInfo({ ``` -------------------------------- ### Video Upload Init with FILE_UPLOAD Source: https://github.com/rioanandaputra-bot/tiktok-docs/blob/main/docs/developers_tiktok_com/Content_Posting_API.md Initiates video upload with source=FILE_UPLOAD. The response provides publish_id and upload_url for subsequent upload. ```bash curl --location 'https://open.tiktokapis.com/v2/post/publish/inbox/video/init/' \ --header 'Authorization: Bearer act.example12345Example12345Example' \ --header 'Content-Type: application/json' \ --data '{ "source_info": { "source": "FILE_UPLOAD", "video_size": exampleVideoSize, "chunk_size" : exampleVideoSize, "total_chunk_count": 1 } }' ``` ```json 200 OK { "data": { "publish_id": "v_inbox_file~v2.123456789", "upload_url": "https://open-upload.tiktokapis.com/video/?upload_id=67890&upload_token=Xza123" }, "error": { "code": "ok", "message": "", "log_id": "202210112248442CB9319E1FB30C1073F3" } } ``` -------------------------------- ### Get menu button bounding rect with TTMinis.getMenuButtonBoundingClientRect Source: https://github.com/rioanandaputra-bot/tiktok-docs/blob/main/docs/developers_tiktok_com/Mini_Dramas.md Example of using TTMinis.getMenuButtonBoundingClientRect to get the layout position of the menu button (capsule button) for custom navigation bar alignment. The API only takes effect when style is "custom"; otherwise all parameters are 0. ```javascript const capsuleButtonLayout = TTMinis.getMenuButtonBoundingClientRect(); // Based on the position of the button as a reference, set the position of other elements to achieve alignment and other capabilities ``` -------------------------------- ### minis.config.json build field references Source: https://github.com/rioanandaputra-bot/tiktok-docs/blob/main/docs/developers_tiktok_com/Mini_Dramas.md Example minis.config.json showing the dev.port, dev.host, build.outputDir, and build.htmlEntry fields. ```json { "dev": { "port": 3000, "host": "localhost" }, "build": { "outputDir": "dist", "htmlEntry": "public/index.html" } } ``` -------------------------------- ### Query TikTok Shop Products - curl Example Source: https://github.com/rioanandaputra-bot/tiktok-docs/blob/main/docs/developers_tiktok_com/Research_Tools.md Example curl command to query TikTok Shop Products. Requires the research.data.basic scope and an access token. The fields parameter is a comma-separated list of desired product fields; page_start starts at 1 and page_size has a maximum of 10. ```bash curl --location 'https://open.tiktokapis.com/v2/research/tts/product/' \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer clt.2.' \ --data '{ "shop_id": 12345678910, "fields": "product_id,product_sold_count,product_review_count,product_rating", "page_start": 1, "page_size": 5 }' ``` -------------------------------- ### Initialize Mini Games SDK with TTMinis.game.init Source: https://github.com/rioanandaputra-bot/tiktok-docs/blob/main/docs/developers_tiktok_com/Mini_Games.md Loads the Mini Games SDK asynchronously and initializes it with the app client key. Place this code after the opening
tag on each page where the SDK is needed. Replace 'app-client-key' with your app's client key from the Credentials section of the Developer Portal. ```HTML ``` -------------------------------- ### Python usage example for scripts.partner_tiktokshop_com Source: https://github.com/rioanandaputra-bot/tiktok-docs/blob/main/_autodocs/api-reference/scripts-partner-tiktokshop-com.md Shows how to import the module and use its main functions: fetch_tree, build_hierarchy, fetch_api_meta, and save_json. The example fetches raw nodes, builds a hierarchy, retrieves API metadata for a specific ID, and saves the result to a JSON file in OUTPUT_DIR. ```python import scripts.partner_tiktokshop_com as ps nodes = ps.fetch_tree() # list node mentah dari /tree roots = ps.build_hierarchy(nodes) # tree ber-hierarki detail = ps.fetch_api_meta("6507ead7b99d5302be949ba9") if detail: ps.save_json(ps.OUTPUT_DIR / "sample.json", {"meta": {}, "detail": detail}) ``` -------------------------------- ### Get Android app signature via PackageManager and MD5 class Source: https://github.com/rioanandaputra-bot/tiktok-docs/blob/main/docs/developers_tiktok_com/Legacy_Products.md Use this Java code to retrieve the MD5 signature of your installed Android app at runtime. It requires the package name of the installation package. The code shows how to get the signature array, compute the MD5 hex digest, and display it via a Toast. It includes a custom MD5 class with hexdigest methods. Note that the code is incomplete as shown, missing the closing brace for the method and the hexDigits array definition. ```java PackageManager manager = getPackageManager(); /** Get the package information of the specified package name including the signature through the package manager **/ PackageInfo packageInfo = null; try { packageInfo = manager.getPackageInfo("your package name", PackageManager.GET_SIGNATURES); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } /** Get the signature array through the returned package information **/ Signature[] signatures = packageInfo.signatures; String ss = MD5.hexdigest(signatures[0].toByteArray()); if(ss != null) { Toast.makeText(this, "signature" + ss, Toast.LENGTH_LONG).show(); } else { Toast.makeText(this, "No signature", Toast.LENGTH_LONG).show(); } /** Create an MD5 tool class **/ public class MD5 { private static final char[] hexDigits = { 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 97, 98, 99, 100, 101, 102 }; public static String hexdigest(String paramString) { try { String str = hexdigest(paramString.getBytes()); return str; } catch (Exception localException) { } return null; } public static String hexdigest(byte[] paramArrayOfByte) { try { MessageDigest localMessageDigest = MessageDigest.getInstance("MD5"); localMessageDigest.update(paramArrayOfByte); byte[] arrayOfByte = localMessageDigest.digest(); char[] arrayOfChar = new char[32]; int i = 0; int j = 0; while (true) { if (i >= 16) return new String(arrayOfChar); int k = arrayOfByte[i]; int m = j + 1; arrayOfChar[j] = hexDigits[(0xF & k >>> 4)]; j = m + 1; arrayOfChar[m] = hexDigits[(k & 0xF)]; i++; } } catch (Exception localException) { } return null; } } ``` -------------------------------- ### POST /v2/post/publish/content/init/ Source: https://github.com/rioanandaputra-bot/tiktok-docs/blob/main/docs/developers_tiktok_com/Content_Posting_API.md Documentation for the photo post endpoint, including request and response examples. ```APIDOC ## [POST] /v2/post/publish/content/init/ ### Description Initiates the photo upload process on TikTok's server. This endpoint is used to upload photos instead of the video post endpoint. ### Method POST ### Endpoint https://open.tiktokapis.com/v2/post/publish/content/init/ ### Parameters #### Request Body - **post_info** (object) - Required - Contains the post information. - **title** (string) - Optional - The title of the post. - **description** (string) - Optional - The description of the post, can include hashtags and mentions. - **disable_comment** (boolean) - Optional - Whether to disable comments on the post. - **privacy_level** (string) - Optional - The privacy level of the post (e.g., PUBLIC_TO_EVERYONE). - **auto_add_music** (boolean) - Optional - Whether to automatically add music to the post. - **source_info** (object) - Required - Contains the source information. - **source** (string) - Required - The source of the media (e.g., PULL_FROM_URL). - **photo_cover_index** (integer) - Optional - The index of the photo to use as the cover. - **photo_images** (array of strings) - Required - The URLs of the photos to upload. - **post_mode** (string) - Required - The post mode (e.g., DIRECT_POST). - **media_type** (string) - Required - The media type (e.g., PHOTO). ### Request Example ``` curl --location 'https://open.tiktokapis.com/v2/post/publish/content/init/' \ --header 'Authorization: Bearer act.example12345Example12345Example' \ --header 'Content-Type: application/json' \ --data-raw '{ "post_info": { "title": "funny cat", "description": "this will be a #funny photo on your @tiktok #fyp", "disable_comment": true, "privacy_level": "PUBLIC_TO_EVERYONE", "auto_add_music": true }, "source_info": { "source": "PULL_FROM_URL", "photo_cover_index": 1, "photo_images": [ "https://tiktokcdn.com/obj/example-image-01.webp", "https://tiktokcdn.com/obj/example-image-02.webp" ] }, "post_mode": "DIRECT_POST", "media_type": "PHOTO" }' ``` ### Response #### Success Response (200) - **data** (object) - Contains the publish ID. - **publish_id** (string) - The ID of the published post. - **error** (object) - Contains error information. - **code** (string) - The error code (e.g., "ok"). - **message** (string) - The error message. - **log_id** (string) - The log ID for tracking. #### Response Example ``` 200 OK { "data": { "publish_id": "p_pub_url~v2.123456789" }, "error": { "code": "ok", "message": "", "log_id": "202210112248442CB9319E1FB30C1073F3" } } ``` ``` -------------------------------- ### Add Data Request Response Example Source: https://github.com/rioanandaputra-bot/tiktok-docs/blob/main/docs/developers_tiktok_com/Data_Portability_API.md Example response from the Add Data Request endpoint. The data object contains a request_id (int64) that is required for subsequent operations like getting request status, canceling the request, and downloading data. The error object includes code, message, and log_id fields. ```json { "data": { "request_id": 123451234512345 }, "error": { "code": "ok", "message": "", "log_id": "1010xyz10101asdf1010101010100a12abc24" } } ``` -------------------------------- ### Create AnalyserNode and get time domain data Source: https://github.com/rioanandaputra-bot/tiktok-docs/blob/main/docs/developers_tiktok_com/Mini_Games.md Creates an AnalyserNode for audio time and frequency analysis. The example sets fftSize and retrieves time domain data into a Uint8Array. ```javascript const audioCtx = TTMinis.game.createWebAudioContext(); const analyser = audioCtx.createAnalyser(); analyser.fftSize = 2048; const bufferLength = analyser.fftSize; const dataArray = new Uint8Array(bufferLength); analyser.getByteTimeDomainData(dataArray); ``` -------------------------------- ### portability.download.ready Example Payload Source: https://github.com/rioanandaputra-bot/tiktok-docs/blob/main/docs/developers_tiktok_com/Integration_Essentials.md Example payload for the portability.download.ready event, fired when data requested via the Data Portability API is in the downloading state. ```json { "client_key": "developer_client_key", "event": "portability.download.ready", "create_time": 1615338610, "content":"{\"request_id\":123123123123123}" } ``` -------------------------------- ### Get New Token - Golang Example Source: https://github.com/rioanandaputra-bot/tiktok-docs/blob/main/docs/developers_tiktok_com/TikTok_GO.md Golang example to obtain a new access token for the first time. Sends a POST request to the TikTok OAuth token endpoint with client credentials and merchant ID, using form-urlencoded body and required headers. Prints the HTTP status code and response body. ```go package main import ( "bytes" "fmt" "io/ioutil" "net/http" "net/url" "strings" ) func main() { apiURL := "https://open.tiktokapis.com/merchant/oauth/token/" data := url.Values{} data.Set("client_key", "{CLIENT_KEY}") data.Set("client_secret", "{CLIENT_SECRET}") data.Set("merchant_id", "{MERCHANT_ID}") data.Set("grant_type", "access_token") req, err := http.NewRequest("POST", apiURL, strings.NewReader(data.Encode())) if err != nil { fmt.Println("Error creating request:", err) return } req.Header.Set("Content-Type", "application/x-www-form-urlencoded") req.Header.Set("x-tt-target-idc", "alisg") client := &http.Client{} resp, err := client.Do(req) if err != nil { fmt.Println("Error sending request:", err) return } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { fmt.Println("Error reading response body:", err) return } fmt.Println("Status Code:", resp.StatusCode) fmt.Println("Response Body:", string(body)) } ``` -------------------------------- ### GET /finance/202507/orders/unsettled Source: https://github.com/rioanandaputra-bot/tiktok-docs/blob/main/_autodocs/api-reference/sdk-finance.md Retrieves unsettled transactions for the 202507 API version. The endpoint returns transaction data with detailed breakdowns. ```APIDOC ## GET /finance/202507/orders/unsettled ### Description Retrieves unsettled transactions for the 202507 API version. The endpoint returns transaction data with detailed breakdowns. ### Method GET ### Endpoint /finance/202507/orders/unsettled ### Response #### Success Response (200) - **code** (number) - Response code. - **data** (Finance202507GetUnsettledTransactionsResponseData) - Contains unsettled transaction records. - **message** (string) - Response message. - **requestId** (string) - Request identifier. #### Response Example ```json { "code": 0, "data": { "transactions": [ { "id": "txn123", "fee_tax_breakdown": { "fee": { "currency": "USD", "value": "1.00" }, "tax": { "currency": "USD", "value": "0.50" } }, "revenue_breakdown": { "currency": "USD", "value": "10.00" }, "shipping_cost_breakdown": { "supplementary_component": { "currency": "USD", "value": "2.00" } } } ] }, "message": "success", "requestId": "req123" } ``` ``` -------------------------------- ### Response Example for video/query/ Source: https://github.com/rioanandaputra-bot/tiktok-docs/blob/main/docs/developers_tiktok_com/Legacy_Products.md Example JSON response containing a list of videos with their IDs and titles, and an error object with code 0 indicating success. ```json { "data":{ "videos":[ { "id":"1234568030997662933", "title":"Test Video 32" }, { "id":"1234580793298373833", "title":"Test Video 22" } ] }, "error":{ "code":0, "message":"" } } ``` -------------------------------- ### Get QR Code - Example Request (curl) Source: https://github.com/rioanandaputra-bot/tiktok-docs/blob/main/docs/developers_tiktok_com/Login_Kit.md POST request to https://open.tiktokapis.com/v2/oauth/get_qrcode/ with Content-Type application/x-www-form-urlencoded. Requires client_key, scope, and optional state. The response includes scan_qrcode_url and token. ```bash curl --location --request POST 'https://open.tiktokapis.com/v2/oauth/get_qrcode/' \ --header 'Content-Type: application/x-www-form-urlencoded' \ --data-urlencode 'client_key=aw7nk86b7czitwc9' \ --data-urlencode 'scope=user.info.basic,user.info.username' \ --data-urlencode 'state=key%3Dabc%26key2%3Ddef' ``` -------------------------------- ### Get New Token - Java Example (JDK 11+) Source: https://github.com/rioanandaputra-bot/tiktok-docs/blob/main/docs/developers_tiktok_com/TikTok_GO.md Java example to obtain a new access token for the first time. Sends a POST request to the TikTok OAuth token endpoint with client credentials and merchant ID, using form-urlencoded body and required headers. Prints the HTTP status code and response body. ```java import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpRequest; import java.net.http.HttpResponse; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.util.Map; import java.util.stream.Collectors; public class GetAccessToken { public static void main(String[] args) throws Exception { HttpClient client = HttpClient.newHttpClient(); Map