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:

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

API targets

tiktok_api_profile

Retrieves information and posts from a specific TikTok profile.

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)

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
}

🚧

Pagination may not work well for TikTok profiles that do not post content regularly.

tiktok_api_hashtag

Retrieves TikTok posts with a specific 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
}

tiktok_post

Retrieves information from a single TikTok video post.

ParameterTypeRequiredDescriptionExample
targetstringtargettiktok_post
urlurlTikTok post URLhttps://www.tiktok.com/@nba/video/7196793231042989354

Downloading video from a TikTok post

🚧

Downloading videos requires logging in with a TikTok account.

Using the tiktok_post target allows obtaining a download link to the video. A downloadAddr property is available in the response:

{
    ...
    "downloadAddr": "https://v16-webapp-prime.us.tiktok.com/video/tos/alisg/tos-alisg-pve-0037c001/oAfTW9DAAQAiFwwZ3mBwqzEOKIKqEOIgti2Chv/?a=1988&bti=ODszNWYuMDE6&ch=0&cr=3&dr=0&lr=tiktok_m&cd=0%7C0%7C1%7C&cv=1&br=3762&bt=1881&cs=0&ds=3&ft=4KJMyMzm8Zmo08z.f-4jV~KlQpWrKsd.&mime_type=video_mp4&qs=0&rc=aTRnZGRpNTdnOWRpaDM3ZEBpM2ppdXE5cjR1czMzODczNEBiLzVjYDNfNTIxLjJfNGM2YSNvLm5gMmRzXl5gLS1kMTFzcw%3D%3D&btag=e00088000&expire=1723138617&l=202408081136144AE053D9571E5409C917&ply_type=2&policy=2&signature=0c5da3af3e3372d1e71a7748d8afaec4&tk=tt_chain_token",
    ...
}

Downloading videos requires logging into TikTok. Once logged in, the tt_chain_token should be copied from cookies:

With this token, the video can be downloaded by sending a GET to downloadAddr and attaching tt_chain_token as a cookie:

curl -L 'https://v16-webapp-prime.tiktok.com/video/tos/alisg/tos-alisg-pve-0037c001/oEdn6roI2PQhqH6MAmgIjaeLfeKPnkIoDGsCAh/?a=1988&bti=NDU3ZjAwOg%3D%3D&ch=0&cr=3&dr=0&lr=all&cd=0%7C0%7C0%7C&cv=1&br=1474&bt=737&cs=0&ds=6&ft=4fUEKMVc8Zmo0s_.f-4jVL.1upWrKsd.&mime_type=video_mp4&qs=5&rc=ZTY1N2g0OjtpaGk2Zjc8OUBpM2ppdXE5cjR1czMzODczNEBiMS5iNS5iXzExMjItNDMwYSNvLm5gMmRzXl5gLS1kMTFzcw%3D%3D&btag=e00088000&expire=1723289013&l=2024080811224972CD300C450534682E98&ply_type=2&policy=2&signature=08bf7eda0e60d6c3ca0865ff1db58640&tk=tt_chain_token' \
     -H 'Cookie: tt_chain_token=P+R8i1eNHk3uHmoxvinB9A=='

If downloading large volumes, you requests may get blocker. Using the Web scraper, along with manually changing tt_chain_token, will overcome blocks.

Legacy targets

tiktok_profile (legacy)

Retrieves information and posts from a specific TikTok profile.

ParameterTypeRequiredDescriptionExample
urlurlTikTok profile URLhttps://www.tiktok.com/@nba
targetstringtargettiktok_profile

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.