How to Post to TikTok Using a Social Media API

you probably Official TikTok App Create and share videos. But did you know that you can also publish videos directly using the TikTok API?

Using the social media API opens up a world of possibilities to create your own app, platform or service for your users, such as scheduling TikTok posts directly from the platform.

Ayrshare recently introduced direct TikTok video sharing and improved user profile data and analytics. Continue to learn how to use the TikTok API for your own platform.

TikTok’s growth

TikTok is great if you haven’t heard of it! TikTok has been installed more than 3.3 billion times worldwide, 1 billion monthly active users, Q4 2021 had the most installs in a single quarter. Their growth seems unstoppable and continues to accelerate during the pandemic lockdown.

TikTok is also thriving. ecosystem Apps that support video creation and download. Just like Facebook and Instagram did, there will be new major companies based on TikTok. How did the developers create these third-party Facebook and Instagram apps? using the API.

social media API

APIs or application programming interfaces provide you or your developers the ability to create your own apps or platforms and leverage the capabilities of third parties. Build experiences (GUIs) that precisely meet your business needs and leverage the power of external data sets or features on the backend.

For example, Dark Skies, a popular weather app currently owned by Apple, has a unique interface and feature that tells you it’s going to rain in 15 minutes. Dark Skies and all other weather apps have to get this weather data from somewhere and guarantee they don’t have their own network of weather satellites. In the United States, most weather apps get their data from the National Weather Service through: API Build your own GUI frontend and unique features.

The social media scheduler does the same using the social media APIs available on social networks like LinkedIn, Facebook, or Twitter.

Share videos using the TikTok API

TikTok recently introduced the ability to share videos directly. API – They are called video kits. Previously, you could only share via an iOS or Android app, but now you can publish directly to an endpoint. Note that, TikTok Marketing API If you want to manage your ads

TikTok social media endpoints use generic OAuth with tokens. OAuth allows users to both authenticate and authorize. These authorization tokens expire after 24 hours, but can be refreshed with additional API calls. However, after one year, the user must re-authenticate and authorize.

TikTok must request approval and go through a review process for API access, which can take days or weeks. Since the API endpoint is so new, there are some missing features such as post deletion and bugs that can prevent rapid development.

Finally, there are some interesting aspects you can explore in the TikTok API documentation: sound kit Receive task notifications by sharing sounds or webhooks.

Alternative integration

Another option to integrate directly with the TikTok API is to integrate with Ayrshare’s social media API, which includes: TikTok Integration. No more approvals or worries about the details of TikTok’s evolving API.

For example, to publish a new TikTok video, use the following JavaScript code: /post endpoint. Replace API_KEY with the following key. dashboard:

var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer API_KEY");

var raw = JSON.stringify({
  "post": "Today is a great day!",
  "platforms": [
    "tiktok"
  ],
  "mediaUrls": [
    "https://images.ayrshare.com/imgs/test-video.mp4"
  ]
});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://app.ayrshare.com/api/post", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

Or if you want to call the Ayrshare TikTok API from Python:

import requests
import json

url = "https://app.ayrshare.com/api/post"

payload = json.dumps({
  "post": "Today is a great day!",
  "platforms": [
    "tiktok"
  ],
  "mediaUrls": [
    "https://images.ayrshare.com/imgs/test-video.mp4"
  ]
})
headers = {
  'Authorization': 'Bearer API_KEY'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

After publishing, go to the TikTok app, select a video and follow the instructions to complete the publication.

Improved TikTok user and post analytics

In addition to posting videos to TikTok, we may also need analytics information about users or individual posts, such as views, shares, or likes.

For example, to get user level analytics on all TikTok videos: /hermeneutics endpoint. Here is the code in Javascript.

var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer API_KEY");

var urlencoded = new URLSearchParams();
urlencoded.append("platforms[0]", "tiktok");

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: urlencoded,
  redirect: 'follow'
};

fetch("https://app.ayrshare.com/api/analytics/social", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

And the Python TikTok API code:

import requests

url = "https://app.ayrshare.com/api/analytics/social"

payload='platforms%5B0%5D=tiktok'
headers = {
  'Authorization': 'Bearer API_KEY'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

User-level analytics data returned includes average video duration and total number of likes, comments, shares, and views.

{
   "tiktok": {
        "analytics": {
            "durationAverage": 4.8,
            "likeCountTotal": 4,
            "commentCountTotal": 6,
            "shareCountTotal": 34,
            "viewCountTotal": 193
        }
}

For all past video posts and a breakdown of each, please call: /history endpoint. The returned post-level analytics data includes the video’s share links, descriptions, likes, comments, shares, and views. This feature is unique to Ayrshare.

{
    "createTime": 1641604664,
    "shareUrl": "https://www.tiktok.com/@funtime/video/705063834032649?utm_campaign=tt4d_open_api&utm_source=wawnhyitaos7o7",
    "videoDescription": "Blah",
    "duration": 4,
    "id": "7050638340353264943",
    "title": "Blah",
    "embedLink": "https://www.tiktok.com/embed/v2/7050638340353264943",
    "likeCount": 0,
    "commentCount": 0,
    "shareCount": 0,
    "viewCount": 0
},
{
    "createTime": 1641603132,
    "shareUrl": "https://www.tiktok.com/@funtime/video/7050631761763536?utm_campaign=tt4d_open_api&utm_source=wawnhyictaos7o7",
    "videoDescription": "Yes",
    "duration": 4,
    "id": "705063176176353",
    "title": "Yes",
    "embedLink": "https://www.tiktok.com/embed/v2/705063176176353",
    "likeCount": 0,
    "commentCount": 0,
    "shareCount": 0,
    "viewCount": 0
}

This insight data can be integrated into apps or platforms for users.

Start sharing to TikTok

To learn more about linking your TikTok account and posting videos, check out: guide. Also, we have several integrated package To make things easier.

Of course, let me know if you have any questions.

Source

Explore additional categories

Explore Other Classes