TikTok

The Social Media Scraping API allows you to scrape information from TikTok.

The following API-powered targets are available. You should prefer using these, they are on average faster and offer more parameters:

  • tiktok_api_profile
  • tiktok_api_hashtag

The following legacy targets are also available. You should only use them if you encounter issues with API targets:

  • tiktok_profile
  • tiktok_hashtag
  • tiktok_post

API targets

tiktok_profile

POST https://scraper-api.smartproxy.com/v2/scrape

Payload type: JSON

ParameterTypeRequiredDescriptionExample
querystringTikTok user handlegordonramsayofficial
targetstringTargettiktok_api_profile
countnumberNumber of results to be returned.
At least 1. At most 35. Defaults to 10.
20
timestampnumberGiven a timestamp date, the last count entries will be returned, starting from that date.

Timestamp must be in seconds format (this will generally be 10 digits long)
1681938000 (2023 Apr 20)
geostringGeolocation

Note that this target does not work with geolocation United States
United Kingdom
localestringLanguage localeen-GB

Extracting more profile results

There is an upper-limit of 35 videos per request when scraping a TikTok profile. If you wish to extract more results, copy the timestamp of the last result obtained after making a request, and make a new request with the timestamp value passed as a parameter. This allows you to paginate through profile videos.

As an example, to fetch the first 35 results, the following payload should be used:

{
    "target": "tiktok_api_profile",
    "query": "gordonramsayofficial",
    "count": 35
}

Each returned result will have a createTime field. The last one would need to be copied.

{
  "data": {
    "content": {
      "itemList": [
        // first 14 entries
        ...
        // last item
        {
          // other fields
          ...
          "createTime": 1676266498
        }
      ]
    }
  }
}      

In order to get the next page, the following payload should be used:

{
    "target": "tiktok_api_profile",
    "query": "gordonramsayofficial",
    "count": 35,
    "timestamp": 1676266498 // added
}

tiktok_api_hashtag

ParameterTypeRequiredDescriptionExample
targetstringTargettiktok_api_hashtag
querystringEither query orhashtag_idHashtag search querytasty
hashtag_idstringEither query orhashtag_idThe hashtag id extracted from https://www.tiktok.com/tag/<hashtag>21945 (id for tag tasty)
countnumberReturns the most recent count results.
At least 1. At most 35. Defaults to 10.
15
cursornumberNumber for indicating how offset the results should be. Defaults to 0 (fetches results that you would see at the top of the page)10

Query fallback

Some requests may not work with some query values. As an escape hatch, the hashtag_id parameter can be used instead. To obtain the hashtag id from a given query (tasty, as an example):

  1. Navigate to https://www.tiktok.com/tag/tasty
  2. Open developer tools
  3. Inside the HTML of the page, look for a string that looks like snssdk1233://challenge/detail/21945. The number 21945 can be provided as the hashtag_id parameter.

🚧

Using hashtag_id will not work with async/batch requests.

Extracting more hashtag results

In order to extract more hashtag results, increase the count parameter.

{
    "target": "tiktok_api_hashtag",
    "query": "tasty",
    "count": 35
}

In order to fetch the next page:

{
    "target": "tiktok_api_hashtag",
    "query": "tasty",
    "count": 35,
    "cursor": 35
}

Legacy targets

tiktok_profile (legacy)

POST https://scraper-api.smartproxy.com/v2/scrape

Payload type: JSON

ParameterTypeRequiredDescriptionExample
urlurlTikTok profile URLhttps://www.tiktok.com/@nba
targetstringtargettiktok_profile
localestringlanguage localeen-GB
geostringgeolocationUnited States
curl -u username:password -X POST --url https://scraper-api.smartproxy.com/v2/scrape -H "Content-Type: application/json" -d "{\"url\": \"https://www.tiktok.com/@nba\", \"target\": \"tiktok_profile\",\"locale\": \"en-us\",\"geo\": \"United States\" }"
import requests

headers = {
    'Content-Type': 'application/json'
}

task_params = {
    'url': 'https://www.tiktok.com/@nba',
  	'target': 'tiktok_profile',
  	'locale': 'en-us',
  	'geo': 'United States'
}

username = 'username'
password = 'password'
  
response = requests.post(
    'https://scraper-api.smartproxy.com/v2/scrape',
    headers = headers,
    json = task_params,
    auth = (username, password)
)
print(response.text)
<?php

$params = array(
    'url' => 'https://www.tiktok.com/@nba',
  	'target' => 'tiktok_profile',
  	'locale' => 'en-us',
  	'geo' => 'United States'
);

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://scraper-api.smartproxy.com/v2/scrape');
curl_setopt($ch, CURLOPT_USERPWD, 'username' . ':' . 'password');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
curl_setopt($ch, CURLOPT_POST, 1);

$headers = array();
$headers[] = 'Content-Type: application/json';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
echo $result;

if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}
curl_close ($ch);
?>

tiktok_post (legacy)

POST https://scraper-api.smartproxy.com/v2/scrape

Payload type: JSON

ParameterTypeRequiredDescriptionExample
urlurlTikTok post URLhttps://www.tiktok.com/@nba/video/7196793231042989354
targetstringtargettiktok_post
localestringlanguage localeen-GB
geostringgeolocationUnited States
curl -u username:password -X POST --url https://scraper-api.smartproxy.com/v2/scrape -H "Content-Type: application/json" -d "{\"url\": \"https://www.tiktok.com/@nba/video/7196793231042989354\", \"target\": \"tiktok_post\",\"locale\": \"en-us\",\"geo\": \"United States\" }"
import requests

headers = {
    'Content-Type': 'application/json'
}

task_params = {
    'url': 'https://www.tiktok.com/@nba/video/7196793231042989354',
  	'target': 'tiktok_post',
  	'locale': 'en-us',
  	'geo': 'United States'
}

username = 'username'
password = 'password'
  
response = requests.post(
    'https://scraper-api.smartproxy.com/v2/scrape',
    headers = headers,
    json = task_params,
    auth = (username, password)
)
print(response.text)
<?php

$params = array(
    'url' => 'https://www.tiktok.com/@nba/video/7196793231042989354',
  	'target' => 'tiktok_post',
  	'locale' => 'en-us',
  	'geo' => 'United States'
);

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://scraper-api.smartproxy.com/v2/scrape');
curl_setopt($ch, CURLOPT_USERPWD, 'username' . ':' . 'password');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
curl_setopt($ch, CURLOPT_POST, 1);

$headers = array();
$headers[] = 'Content-Type: application/json';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
echo $result;

if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}
curl_close ($ch);
?>

tiktok_hashtag (legacy)

POST https://scraper-api.smartproxy.com/v2/scrape

Payload type: JSON

ParameterTypeRequiredDescriptionExample
urlurlTikTok hashtag URLhttps://www.tiktok.com/tag/satisfying
targetstringtargettiktok_hashtag
localestringlanguage localeen-GB
geostringgeolocationUnited States
curl -u username:password -X POST --url https://scraper-api.smartproxy.com/v2/scrape -H "Content-Type: application/json" -d "{\"url\": \"https://www.tiktok.com/tag/satisfying\", \"target\": \"tiktok_hashtag\",\"locale\": \"en-us\",\"geo\": \"United States\" }"
import requests

headers = {
    'Content-Type': 'application/json'
}

task_params = {
    'url': 'https://www.tiktok.com/tag/satisfying',
  	'target': 'tiktok_hashtag',
  	'locale': 'en-us',
  	'geo': 'United States'
}

username = 'username'
password = 'password'
  
response = requests.post(
    'https://scraper-api.smartproxy.com/v2/scrape',
    headers = headers,
    json = task_params,
    auth = (username, password)
)
print(response.text)
<?php

$params = array(
    'url' => 'https://www.tiktok.com/tag/satisfying',
  	'target' => 'tiktok_hashtag',
  	'locale' => 'en-us',
  	'geo' => 'United States'
);

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'https://scraper-api.smartproxy.com/v2/scrape');
curl_setopt($ch, CURLOPT_USERPWD, 'username' . ':' . 'password');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
curl_setopt($ch, CURLOPT_POST, 1);

$headers = array();
$headers[] = 'Content-Type: application/json';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
echo $result;

if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}
curl_close ($ch);
?>

Asynchronous requests

Asynchronous requests do not require you to keep an open connection and let you retrieve the scraped data later. To learn more, take a look at this article.