Notice: Ayrshare now presents direct publishing of TikTok videos, feedback, and superior analytics. This imply you not want to open the TikTok cellular app to manually enter the caption textual content and publish the video. Just despatched the API request with the caption textual content and the TikTok video is printed.
You are in all probability accustomed to the official TikTok app to create and share movies. But, do you know you can too put up movies utilizing the TikTok API?
Using a social media API opens worlds of potentialities to create your individual app, platform, or service on your customers, akin to scheduling TikTok posts instantly out of your platform.
Ayrshare just lately launched direct TikTok video sharing and enhanced person profile information and analytics. Continue studying to find out about how to use the TikTok API on your personal platform.
TikTok’s Growth
If you haven’t heard, TikTok is huge! TikTok has over 3.3B installs worldwide, 1B monthly active users, and in This fall 2021 had essentially the most installs ever in a single quarter. Their progress appears unstoppable and continues to speed up in the course of the pandemic lockdowns.
TikTok additionally has a thriving ecosystem of apps that assist video creation and downloads. Major new firms that construct upon TikTok will emerge – as has occurred for Facebook and Instagram. And how did builders create these Facebook and Instagram third occasion apps? By utilizing an API.
An API, or Application Programming Interface, offers you, or your builders, the facility to create your individual app or platform and leverage the capabilities of third events. You construct the expertise (GUI) that precisely meets your online business wants and on the backend harness the facility of exterior datasets or performance.
For instance, the favored climate app Dark Skies, now owned by Apple, has a distinctive interface and capabilities akin to letting you understand it should rain in quarter-hour. Dark Skies and all different climate apps want to get this climate information from someplace and I assure they don’t have their very own community of climate satellites. In the U.S. most climate apps get their information from the National Weather Service by way of their API and construct their very own GUI front-end and distinctive capabilities.
Social media schedulers do the identical factor through the use of the social media APIs out there from social networks akin to LinkedIn, Facebook, or Twitter.
Share Videos Using the TikTok API
TikTok just lately launched the flexibility to instantly share movies by way of their API – known as the Video Kit. Previously you may solely share by way of an iOS or Android app, however now you may put up instantly to their endpoint. Side notice, there may be additionally a TikTok Business API if you would like to handle adverts.
The TikTok social media endpoint makes use of typical OAuth with tokens. OAuth permits customers to authenticate and grant permissions to your app. These grant tokens expire after 24 hours, however might be refreshed with a further API name. However, after a yr the person want to re-authenticate and provides permissions once more.
TikTok requires you to request approval and undergo a evaluate course of for API entry, which may take a few days to a few weeks. Since their API endpoint is so new, there are a number of lacking options, such deleting posts, and bugs which may forestall fast growth.
Finally, there are a few different fascinating facets of the TikTok API documentation you may want to discover, such because the Login Kit for integrating TikTok OAuth or TikTok Webhooks to get notified of actions.
Update: TikTok continues to improve their APIs with a V2. The V2 API simplifies calls, error messaging, and workflow. All of the beneath calls nonetheless perform.
Alternative Integration
An different possibility to instantly integrating with the TikTok API is to combine with Ayrshare’s social media API which incorporates TikTok integration. You not want approval or fear concerning the particulars of TikTok’s evolving API.
For instance, to put up a new TikTok video use the next Javascript code with the /post endpoint. Be certain to substitute API_KEY along with your key from the dashboard:
const information = {
"post": "Today is a great day I say!",
"platforms": [
"tiktok"
],
"mediaUrls": [
"https://img.ayrshare.com/012/tiktok.mp4"
]
};
const requestOptions = {
technique: 'POST',
headers: {
"Authorization": `Bearer ${API_KEY}`,
"Content-Type": "application/json"
},
physique: JSON.stringify(information)
};
fetch("https://app.ayrshare.com/api/post", requestOptions)
.then(res => res.json())
.then(consequence => console.log(consequence))
.catch(error => console.log('error', error));
Or in the event you desire to name the Ayrshare TikTok API in Python:
import requests
payload = {'put up': 'Today is a nice day!',
'platforms': ['tiktok'],
'mediaUrls': ['https://img.ayrshare.com/012/tiktok.mp4']}
headers = {'Content-Type': 'software/json',
'Authorization': 'Bearer API_KEY'}
r = requests.put up('https://app.ayrshare.com/api/post',
json=payload,
headers=headers)
print(r.json())
After posting, go to your TikTok app to full the posting by deciding on the video and following the directions.
TikTok Analytics API
In addition to posting movies to TikTok, you additionally would possibly need TikTok analytics concerning the person’s account or particular person put up, akin to what number of views, shares, or likes. These insights into person conduct, engagement, and attain may also help construct your social media technique.
For instance, to get the person degree analytics throughout all their TikTok movies name the /analytics API endpoint. Here is the code in Javascript:
const information = { platforms: ["tiktok"] };
const requestOptions = {
technique: 'POST',
headers: {
"Authorization": `Bearer ${API_KEY}`,
"Content-Type": "application/json"
},
physique: JSON.stringify(information)
};
fetch("https://app.ayrshare.com/api/analytics/social", requestOptions)
.then(res => res.json())
.then(consequence => console.log(consequence))
.catch(error => console.log('error', error));
And the Python TikTok API code:
import requests
payload = {'platforms': ['tiktok']}
headers = {'Content-Type': 'software/json',
'Authorization': 'Bearer API_KEY'}
r = requests.put up('https://app.ayrshare.com/analytics/social',
json=payload,
headers=headers)
print(r.json())
The person degree analytics information returned consists of the common video period and complete like, feedback, share, and views.
{
"tiktok": {
"analytics": {
"commentCountTotal": 23,
"durationAverage": 10.058823529411764,
"likeCountTotal": 1,
"shareCountTotal": 2,
"url": "https://www.tiktok.com/@funsun",
"username": "@funsun",
"videoCountTotal": 26,
"viewCountTotal": 16
}
}
}
If you need to get analytics on particular person TikTok movies, name the /analytics post endpoint. The put up degree analytics information returned consists of the share hyperlink of the video, description, and counts of likes, feedback, shares, and views. This function is exclusive to Ayrshare.
{
"tiktok": {
"id": "7034682002927550598", // ID of the put up at TikTok
"postUrl": "https://www.tiktok.com/@borneild/video/7034682002927550598?utm_campaign=tt4d_open_api&utm_source=awawnhyictaos7o",
"analytics": {
"commentCount": 23,
"createTime": 1660057702, // UTC Unix epoch (in seconds)
"created": "2022-08-09T15:08:22Z",
"duration": 6,
"embedLink": "https://www.tiktok.com/embed/v2/7129893524253756713",
"likeCount": 22,
"mediaType": "video",
"musicTitle": "♬ original sound - tiff", // if out there
"musicUrl": "https://www.tiktok.com/music/original-sound-6689804660171082501?refer=embed", // if out there
"name": "Mackly",
"postUrl": "https://www.tiktok.com/@tiktoktime/video/7129893524253756713?utm_campaign=tt4d_open_api&utm_source=awawnhyictaos7o7",
"shareCount": 0,
"shareUrl": "https://www.tiktok.com/@tiktoktime/video/7129893524253756713?utm_campaign=tt4d_open_api&utm_source=awawnhyictaos7o7", // Deprecated, person postUrl
"tags": [ // Tags included in the description
{
"tag": "#foryoupage",
"url": "https://www.tiktok.com/tag/foryoupage"
},
{
"tag": "#petsoftiktok",
"url": "https://www.tiktok.com/tag/petsoftiktok"
},
{
"tag": "#aesthetic",
"url": "https://www.tiktok.com/tag/aesthetic"
}
],
"thumbnailHeight": 576,
"thumbnailUrl": "https://p16-sign.tiktokcdn-us.com/obj/tos-useast5-p-0068-tx",
"thumbnailWidth": 1006,
"title": "Scramble up ur name & I’ll try to guess it #foryoupage #petsoftiktok #aesthetic"",
"url": "https://www.tiktok.com/@tiktoktime",
"videoDescription": "Scramble up ur name & I’ll try to guess it #foryoupage #petsoftiktok #aesthetic"",
"viewCount": 34
}
}
}
This insights information might be built-in into your app or platform on your customers.
Start Sharing to TikTok
If you need to discover out extra about how to join your TikTok account and put up movies utilizing our social API, try our guide. Also, now we have a number of integration packages to make issues simpler.
And in fact, tell us when you have any questions.