TikAPI REST API (v2.0.1)

Download OpenAPI specification:Download

Introduction

The TikAPI API is an unofficial API on top of TikTok application API. Our API is RESTful. It has predictable resource URLs. It uses HTTP response codes to indicate errors. It also accepts and returns JSON in the HTTP body. You can use your favorite HTTP/REST library for your programming language to use TikApi's API.

Check out this demo to see how OAuth works https://youtu.be/JDupJKZ0Yy8

Postman

You can easily test our API with Postman. Make sure you set apiKey & accountKey as environment variables.

Run in Postman

SDK

Check out our Javascript SDK at https://github.com/tikapi-io/tiktok-api

Errors

You can identify errors from the HTTP Status code or response body. As with our normal API responses, your client must be prepared to gracefully handle additional members of the response.

Bad Request (400)

The request could not be understood by the server due to malformed syntax or parameters. The client should not repeat the request without modifications.

Example

{
    "status": "error",
    "message": "Missing fields.", 
    "fields": {
        "sec_user_id": "A valid TikTok user id is required."
    }
}

Forbidden (403)

These can occur for different reasons such as Unauthorized access, Invalid Credentials or API Key Rate Limit reached.

Example

{    
    "status": "error",
    "message":"Something went wrong."
}

Not Found (404)

The server has not found anything matching the Request-URI. No indication is given of whether the condition is temporary or permanent.

Example

{
    "status": "error",
    "message": "The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again."
}

Method Not Allowed (405)

The method specified in the Request-Line is not allowed for the resource identified by the Request-URI.

Example

{
    "status": "error",
    "message": "The method is not allowed for the requested URL."
}

Authentication

api_key

This is your TikApi API Key, must be included in header on every request. You can refresh this key from TikApi Developer Dashboard. When sending an API request you must include this key in Headers with header name X-API-KEY.

Security Scheme Type API Key
Header parameter name: X-API-KEY

account_key

The system of obtaining an users authorization key is based in OAuth 2.0 specification, with some differences. Here are the steps for getting an authorization key:

1. Ask an User for Authorization

To get an access token, you need to ask an user to authorize your application. You can do this by sharing your OAuth link to the user or using the TikAPI Login Button.

Example OAuth Link: https://tikapi.io/account/authorize?client_id=c_1234567890&redirect_uri=https://tikapi.io/success&scope=view_profile%20search

  • client_id required

    • This is your application id, you can find this on TikApi Developer Dashboard.
  • redirect_uri required

    • The user will be redirect here after successful authorization and the params access_token,scope will be passed in query. You must set your application redirect links on TikApi Developer Dashboard.
  • scope optional

    • A list of permissions seperated with space. User can choose to not allow some of these permission.
  • state optional

    • A custom state data to pass on.

2. Using Authorization

After an user has authorized your application, a redirection will occur at your specified redirection link and the query url parameters will include:

  • access_token which is the user authorization key,
  • scope which is the list of allowed permissions, in case the user might have choosen to disallow some permissions.

Also, you can see your current authorized users from your TikApi Developer Dashboard.

The authorization key never expires, but user can choose to revoke access at anytime.

When sending an API request you must include this key in Headers with header name X-ACCOUNT-KEY.

Security Scheme Type User Authorization Key
Header parameter name X-ACCOUNT-KEY
Security Scheme Type OAuth2
implicit OAuth Flow
Authorization URL: https://tikapi.io/account/authorize
Scopes:
  • view_profile -

    To read a user's profile info and activity

  • edit_profile -

    Modify a user's profile

  • view_messages -

    View a user's messages

  • media_actions -

    To like or comment videos on a user behalf

  • follow_actions -

    To follow or unfollow other users

  • live -

    Start, View & End Live videos

  • search -

    To read any profile info and media

Profile

Get user basic profile information

Get profile information

Authorizations:
api_keyaccount_key (view_profile)

Responses

Request samples

curl --request GET \
  --url https://api.tikapi.io/user/info \
  --header 'X-ACCOUNT-KEY: {YOUR_KEY_VALUE}' \
  --header 'X-API-KEY: {YOUR_KEY_VALUE}' \
  --header 'accept: application/json'

Response samples

Content type
application/json
{}

Get creator analytics

Get a wide range of analytics and reports for creator accounts

Authorizations:
api_keyaccount_key (view_profile)
path Parameters
tab
required
string
Enum: "overview" "contant" "video" "followers" "live"

The type of analytics

query Parameters
days
integer
Default: 7

The days for the analytics

media_id
integer

The media ID for specific video analytics. For video tab only.

Responses

Request samples

curl --request GET \
  --url https://api.tikapi.io/creator/analytics/overview?days=7 \
  --header 'X-ACCOUNT-KEY: {YOUR_KEY_VALUE}' \
  --header 'X-API-KEY: {YOUR_KEY_VALUE}' \
  --header 'accept: application/json'

Response samples

Content type
application/json
{
  • "status": "success",
  • "message": null,
  • "extra": {
    },
  • "follower_active_history_days": "string",
  • "follower_active_history_hours": "string",
  • "follower_num": {