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
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
query | string | ✅ | TikTok user handle | gordonramsayofficial |
target | string | ✅ | Target | tiktok_api_profile |
count | number | Number of results to be returned. At least 1 . At most 35 . Defaults to 10 . | 20 | |
timestamp | number | Given 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) | |
geo | string | Geolocation Note that this target does not work with geolocation United States | United Kingdom | |
locale | string | Language locale | en-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 hashtag
POST https://scraper-api.smartproxy.com/v2/scrape
Payload type: JSON
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
query | string | ✅ | Hashtag search query | tasty |
target | string | ✅ | Target | tiktok_api_hashtag |
count | number | Returns the most recent count results.At least 1 . At most 35 . Defaults to 10 . | 15 | |
cursor | number | Number for indicating how offset the results should be. Defaults to 0 (fetches results that you would see at the top of the page) | 10 | |
geo | string | Geolocation | United States | |
locale | string | Language locale | en-GB |
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
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
url | url | ✅ | TikTok profile URL | https://www.tiktok.com/@nba |
target | string | ✅ | target | tiktok_profile |
locale | string | language locale | en-GB | |
geo | string | geolocation | United 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
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
url | url | ✅ | TikTok post URL | https://www.tiktok.com/@nba/video/7196793231042989354 |
target | string | ✅ | target | tiktok_post |
locale | string | language locale | en-GB | |
geo | string | geolocation | United 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
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
url | url | ✅ | TikTok hashtag URL | https://www.tiktok.com/tag/satisfying |
target | string | ✅ | target | tiktok_hashtag |
locale | string | language locale | en-GB | |
geo | string | geolocation | United 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.
Updated about 1 month ago