This article will discuss about how to use TikTok API with step-by-step integration guide and full documentation list. Let’s get started!
Overview of TikTok API
TikTok is quite popular among social media users and those who love to gain global popularity. But does TikTok have an API? Yes, TikTok API exists that helps in creating videos and profile formation. In this article, we will discuss in detail TikTok API for developers and its salient features.
TikTok developer API and key functionalities
At the start of the article, we will discuss TikTok developer API and its key functionalities:
- TikTok public API is RESTful and the resource URLs.
- While thinking of TikTok API integration, the usage of HTTP response codes is a unique feature
- TikTok open API accepts JSON code and also returns the same in the body of the HTTP response
- The REST or HTTP library is used to work with TikTok Open API
- The endpoints of TikTok API are divided into two categories.
- Authenticated users used to receive information and perform interactions on the TikTik accounts
- Public data for receiving public information like profile data, feed data, hashtags, videos, etc.
Also read: How to use Yelp API a step-by-step integration guide and full documentation list
How to use TikTok API – step-by-step integration guide
In this section, we will discuss how to use TikTok API, a step-by-step integration guide for reference and support:
Step 1: The first step is to create a TikTok rest API account. Go here and click on My Apps to create a TikTok developer account. Then click on Create App to create a TikTok user API account, fill in the required information, confirm, and submit the application.
Step 2: To access the settings page of the Tiktok web API, click on the app in the My Apps dashboard. Find out the Authorized URL after scrolling down the page and then keep it saved for future use
Step 3: The Tiktok live API authorized URL needs to be sent across to the Tiktok advertising client. The client will access the URL in the browser. To visit the Tiktok data API URL, the Tiktok API login will be prompted for the ads account. After login, the browser will be redirected to the dedicated page of authorization. Once confirm is clicked, the page will be redirected to the callback address. This is the step for the TikTok API access.
Step 4: The next step is to receive a Tiktok API key or token. First, you need to open up a terminal in Mac OS or a command prompt in Windows OS. Enter the command below: curl -H “Content-Type:application/json” -X POST -d “{\”secret\”: \”APP SECRET\”, \”app_id\”: \”APP ID\”, \”auth_code\”: \”AUTH_CODE\”}” https://ads.tiktok.com/open_api/oauth2/access_token_v2/
Step 5: Then the step for how to use Tiktok API is to get the URL for the Tiktok API endpoints. Here is the code. If you want to know details of the endpoints then you can find it in the link – the purpose, the URL details, the HTTP Method, and many more.
Step 6: Calls to the Tiktok Marketing API need to follow certain protocols i.e. to the base domain.
Step 7: Some example codes for TikTok API endpoint Method: GET
API URL Path: https://business-api.tiktok.com/open_api/v1.3/campaign/get/
Headers:
Header 1 Key:
Access-Token
Header 1 Value:
Your_token
Step 8: Code example for creating a TikTok API download task Method: GET
API URL Path: https://business-api.tiktok.com/open_api/v1.3/page/lead/task/download/
Headers:
Header 1 Key:
Access-Token
Header 1 Value:
your_token
Step 9: Code example for getting the data for automated creative ads and regular ads for a TikTok Mobile API Method: GET
API URL Path: https://business-api.tiktok.com/open_api/v1.3/ad/get/
Headers:
Header 1 Key:
Access-Token
Header 1 Value:
Your_token
Step 10: Code example for receiving a feed or all the feeds of a catalog found in TikTok API GitHub URL Method: GET
API URL Path: https://business-api.tiktok.com/open_api/v1.3/catalog/feed/get/
Headers:
Header 1 Key:
Access-Token
Header 1 Value:
your_token
Step 11: Code example for receiving the audience list Method: GET
API URL Path: https://business-api.tiktok.com/open_api/v1.3/dmp/custom_audience/list/?advertiser_id=ADVERTISER_ID&page=PAGE&page_size=PAGE_SIZE
Headers:
Header 1 Key:
Access-Token
Header 1 Value:
Your_token
Step 12: Code example for updating the video name
Method: POST
API URL Path: https://business-api.tiktok.com/open_api/v1.3/file/video/ad/update/
Headers:
Header 1 Key:
Access-Token
Header 1 Value:
your_token
POST Body:
{
“advertiser_id”: “ADVERTISER_ID”,
“file_name”: “FILE_NAME”,
“video_id”: “VIDEO_ID”
}
Step 13: Now next step in how to use TikTok API is Pagination. A large dataset needs to be divided into smaller pages. To use the pagination option, certain parameters needed to be added at the end of the TikTok API URL:
-
- page – the number of the page you want to obtain;
- page_size – the number of records per page;
- cursor – cursor for pagination. If response.data.has_more is true, pass the response.data.cursor in this parameter in the subsequent request to receive the next page of results.
- max_count – the maximum number of records that will be returned for each page.
Step 14: Now coming to the steps of installing SDK for iOS. You can get the details here. Steps for adding the library to the project XCode
-
- Click on File -> Add packages
- Then paste the URL
- Select the dependency rule for the major version and then enter the major version
- Select your project by clicking on Add to Project
- Then click on Copy Dependency and select the required libraries – TikTokOpenAuthSDK, TikTokOpenShareSDK, and TikTokOpenShareSDK
Step 15: In iOS, the code for adding the pods to the profile is
pod ‘TikTokOpenSDKCore’
pod ‘TikTokOpenAuthSDK’
pod ‘TikTokOpenShareSDK’
Step 16: Then you need to configure the XCode project in iOS. No, you need to open the Info.plist file and add the values as follows:
- LSApplicationQueriesSchemes:
-
-
- tiktokopensdk for Login Kit.
- tiktoksharesdk for Share Kit.
- snssdk1233 and snssdk1180 to check if TikTok is installed on your device.
-
- The client key of the applications to the TikTokClientKey key and CFBundleURLSchemes
<key>LSApplicationQueriesSchemes</key>
<array>
<string>tiktokopensdk</string>
<string>tiktoksharesdk</string>
<string>snssdk1180</string>
<string>snssdk1233</string>
</array>
<key>TikTokClientKey</key>
<string>$TikTokClientKey</string>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>$TikTokClientKey</string>
</array>
</dict>
</array>
- AppDelegate
import TikTokOpenSDKCore
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ app: UIApplication,open url: URL,
options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
if (TikTokURLHandler.handleOpenURL(url)) {
return true
}
return false
}
func application(_ application: UIApplication,
continue userActivity: NSUserActivity,
restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
if (TikTokURLHandler.handleOpenURL(userActivity.webpageURL)) {
return true
}
return false
}
}
- SceneDelegate
import TikTokOpenSDKCore
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
func scene(_ scene: UIScene,
openURLContexts URLContexts: Set<UIOpenURLContext>) {
if (TikTokURLHandler.handleOpenURL(URLContexts.first?.url)) {
return
}
}
}
Step 17: In Android, for installing the SDK need to switch to the Android View tab from the Project window. Next is to locate the project build.gradle after opening Gradle Scripts. The code that needs to be added to the repositories {} section is
repositories {
maven { url “https://artifact.bytedance.com/repository/AwemeOpenSDK” }
}
The next step is to locate the app module from build.gradle after opening Gradle Scripts. The code is added to the dependencies {} section
dependencies {
implementation ‘com.tiktok.open.sdk:tiktok-open-sdk-core:latest.release’
implementation ‘com.tiktok.open.sdk:tiktok-open-sdk-auth:latest.release’ // to use authorization api
implementation ‘com.tiktok.open.sdk:tiktok-open-sdk-share:latest.release’ // to use share api
}
Read more: How to use Instagram API a step-by-step integration guide and full documentation list
TikTok API documentation references and examples
Let us check out the TikTok API documentation references and examples in this section.
- The overview of the TikTok API can be checked in the link for TikTok API documentation link.
- For registering the app, the link for TikTok API docs is here.
- The TikTok Marketing API docs can be checked from here.
- The content posting TikTok ADs API documentation link.
- The TikTok API examples documentation for commercial content TikTok API is here.
1. How to use TikTok API Python
The steps for using TikTok API Python are as below:
- Set up the Python TikTok API package by running pip install TikTokApi and python -m playwright install
- From the cookies, copy the content of the s_v_webid cookie and paste it into verifyFp as part of the process of using TikTok Python API
- To generate TikTok API Python compilations, use the code
from TikTokApi import TikTokApi
verifyFp=”verify_YOUR_S_V_WEB_ID_COOKIE”
api = TikTokApi.get_instance(custom_verifyFp=verifyFp)
print(api.trending(count=1))
- For Tiktok marketing API python or any other TikTok API, you need to check the methods used in the Package API like API.discoverMusic(), API.trending(), etc.
2. How to use TikTok API Javascript
The steps for using TikTok API javascript are as follows:
- Install the TikTok API by using npm i tiktok-app-api
- Import into your TikTok API Javascript program by using const tiktok = require(‘tiktok-app-api’);
To initiate an instance of the TikTok API use the code const tiktok = require(‘tiktok-app-api’);
let tiktokApp;
(async () => {
tiktokApp = await tiktok();
})();
- For getting top trending videos use the codes const iterator = tiktokApp.getTrendingVideos();
const videosResult = await iterator.next();
const trendingVideos = videosResult.value;
console.log(trendingVideos);
- Retrieve the user information using the code onst user = await tiktokApp.getUserByName(‘example’);
3. How to use NPM TikTok API
Here are the steps for using NPM TikTok API:
- Install TikTok API NPM using npm install node-tiktok-web-api
- The code for using NPM TikTok API is const Tiktok = require(‘node-tiktok-web-api’); const TiktokClient = new Tiktok(); const fs = require(‘fs’); (async() => { //get video cover image const data = await TiktokClient.getVideoCoverImageByUrl(‘https://www.tiktok.com/@jiangyou511/video/6855575034182798598’); console.log(data) //downloading video const data = await TiktokClient.getVideoBase64AndBufferByUrl(‘https://www.tiktok.com/@jiangyou511/video/6855575034182798598’); fs.writeFileSync(‘./test.mp4’, data.base64, ‘base64’) console.log(data) })();
- To get a video cover image in TikTok API NodeJS, use const data = await TiktokClient.getVideoCoverImageByUrl(‘https://www. Tiktok.com/@xxxxx/video/xxxxxx’); console.log(data)
- To get video base and URL, use const data = await TiktokClient.getVideoBase64AndBufferByUrl(‘https://www.tiktok.com/@xxxxx/video/xxxxxx’); fs.writeFileSync(‘./test.mp4’, data.base64, ‘base64’) console.log(data)
4. How to use TikTok API C#
The steps for using TikTok API C# are as follows:
- Install the version of TikTok API using dotnet and add the package TikTok.ApiClient –version 0.0.3-beta
- The command to be used within the Package Manager is NuGet\Install-Package TikTok.ApiClient -Version 0.0.3-beta
- To reference the package use <PackageReference Include=”TikTok.ApiClient” Version=”0.0.3-beta” />
- To add the client to Paket CLI use the code paket and add TikTok.ApiClient –version 0.0.3-beta
- To refer to the r# directive, use the code #r “nuget: TikTok.ApiClient, 0.0.3-beta”
- To install the TikTok API client using the Cake Addin or Toll use the code // Install TikTok.ApiClient as a Cake Addin
#addin nuget:?package=TikTok.ApiClient&version=0.0.3-beta&prerelease
// Install TikTok.ApiClient as a Cake Tool
#tool nuget:?package=TikTok.ApiClient&version=0.0.3-beta&prerelease
5. How to use TikTok API PHP
The ways of using TikTok API PHP are given below:
- To install PHP TikTok API via composer use composer require ssovit/tiktok-api
- To check available options in TikTok API PHP the code is $api=new \Sovit\TikTok\Api(array(
“user-agent” => ‘Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.106 Safari/537.36’, // Valid desktop browser HTTP User Agent
“proxy-host” => false,
“proxy-port” => false,
“proxy-username” => false,
“proxy-password” => false,
“cache-timeout” => 3600 // 1 hours cache timeout
“cookie_file” => sys_get_temp_dir() . ‘tiktok.txt’, // cookie file path
“nwm_endpoint” => “https://my-api.example.com” // private api endpoint
“api_key” => “API_KEY” // see below on how to get API key
), $cache_engine=false);
- To get available methods in TikTok API for PHP getTrendingFeed –
- getTrendingFeed – Get trending feed getTrendingFeed($maxCursor)
- getUser – Get profile data for TikTok User getUser($username)
- getUserFeed – Get user feed by ID getUserFeed($user_id,$maxCursor)
- getUserFeedByName – Get user feed by Name getUserFeedByName($username,$maxCursor)
- getChallenge – Get challenge/hashtag info getChallenge($challenge)
- getChallengeFeed – Get challenge feed by ID getChallengeFeed($challenge_id, $maxCursor)
- getChallengeFeedByName – Get challenge feed by name getChallengeFeedByName($challenge,$maxCursor)
- getMusic – Get music info getMusic($music_id)
- getMusicFeed – Get music feed getMusicFeed($music_id,$maxCursor)
- getVideoByID – Get video by ID getVideoByID($video_id)
- getVideoByUrl – Get video by URL getVideoByUrl($video_url)
- getNoWatermark – Get no watermark for video by URL getNoWatermark($video_url)
6. How to use TikTok API Java
<no content available>
Read more: How To Use Airtable API a step-by-step Integration Guide and Full Documentation List
TikTok API pricing
Let us now focus on TikTok API pricing. The basic plan is free to use offering 30 requests per minute of TikTok API limits and 200 requests per day. The Pro plan with USD 19 per month offers 50 requests per minute of TikTok API rate limits and 5000 requests per day. The Ultra plan with USD 49 per month offers 50 requests per minute of TikTok API rate limits and 12000 requests per day. The Mega plan with USD 99 per month offers 40 requests per minute of TikTok API rate limits and 26000 requests per day.
Most used TikTok APIs
In this section, we will focus on the most used TikTok APIs as elaborated with short descriptions and their respective reference links.
TikTok marketing API
TikTok marketing API interacts with the TikTok API Ads managed to help a developer to query data, manage and create ADs, and other tasks. The link for the API is here.
TikTok ads API
TikTok Ads API is leveraged to create and manage the ADs, campaigns, and AD groups, and the details of TikTok Advertising API are available.
TikTok analytics API
TikTok Analytics API helps to find out the total views, likes, comments, shares, watch time, and traffic for videos. Details of TikTok API Analytics to be checked here.
TikTok TTS API
TikTok TTS API converts text to a lady voice, robot voice, and other TikTok voices. Find the URL for checking details.
TikTok creator marketplace API
TikTok creator marketplace API is to collaborate with creators based on budget, industry, and goals of the business. Link to be check is here.
TikTok reporting API
TikTok reporting API is used to extract synchronous and asynchronous reports.
TikTok conversion API
The TikTok conversion API is an integration between the servers with the Events API permitting to share visitor events directly from the website to TikTok. Here is the link for checking details.
TikTok no watermark API
TikTok no watermark API helps to download videos with no watermark, the details can be checked here.
TikTok upload API
The TikTok Upload API is used to upload video without posting it and the link for the details of the TikTok API upload is here.
TikTok video API
TikTok video API is used to post videos and even share videos. You can check the documentation for the TikTok API post video.
TikTok events API
TikTok events API is used to assist advisors in establishing a link between Tiktok and the marketing data of the advisor. Details of events API TikTok to be checked here.
TikTok shopping API
TikTok shopping API will enable sellers and creators to avail the professional e-commerce services so that they can prosper on TikTok shop, details are here.
TikTok Audience API
TikTok audience API is used to measure the engagement of the audience and the return on investment. Find details in this link.
TikTok Music API
TikTok music API is used to search for music and also gather music data from the already uploaded music videos. Details are here.
TikTok text to speech API
<already covered in TTS API>
TikTok search API
TikTok search API is used to search any keyword, scrape videos, get music details, and retrieve user details. Details in this link.
TikTok Business API
TikTok business API is used by developers for connecting to business platforms and create innovative solutions. Details are here.
TikTok post API
TikTok Post API helps to upload videos in TikTok, find the documentation here.
TikTok embed API
TikTok embed API is used to convert the video URL for TikTok into embedded video markup. Details are here.
TikTok API get followers
TikTok API get followers is used to retrieving 5000 followers per user and convert them into .csv format. Documentation is here.
TikTok Comments API
TikTok Comments API is used to extract the comments from a TikTok video. Details in here.
TikTok voice API
<no api>
Kuntala is a versatile writer with a focus on diverse areas around work, productivity, collaboration at work, hiring, management, HR, and training. Her background of past experience in technology and consulting helps in molding razor-sharp insights into the research and user-focused content she creates. Professionally she is an IT consultant in a sales role and also a writer of short stories and poems, travel blogger, and fashion influencer.
Leave a Reply