Get TikTok video with less than 10 Lines of Python code

Actually TikTok offers some endpoints for developers, but that doesn't have many functionality and flexibility.

In this post, we will use the following.

GitHub logo davidteather / TikTok-Api

The Unofficial TikTok API Wrapper In Python

Unofficial TikTok API in Python

This is an unofficial api wrapper for in python. With this api you are able to call most trending and fetch specific user information as well as much more.

DOI LinkedIn Sponsor Me GitHub release (latest by date) Build Status GitHub Downloads Support Server


These sponsors have paid to be placed here and beyond that I do not have any affiliation with them, the TikTokAPI package will always be free and open-source. If you wish to be a sponsor of this project check out my GitHub sponsors page.

TikAPI TikAPI is a paid TikTok API service providing an full out-of-the-box solution for developers, trusted by 100+ companies. Learn more

Table of Contents

Getting Started

To get started using this api follow the instructions below.

How to support the project

  • Feel free to sponsor me on GitHub
  • Feel free to tip the project using the…

This python library allows us to use TikTok data easily and documents are organized very well.

Step1. install the library via pip

$ pip install TikTokApi
$ python -m playwright install

Step2. get custom_verifyFp

Go to TikTok and open Dev Tool > Application > Storage > Cookies. Then copy s_v_web_id value and paste it to verifyFp in the following sample code.

You can see what you need to do to get s_v_web_id in the Youtube video.

In this sample code, I used by_hashtag method that gets the fixed number of videos that have Messi as a #tag.
In the sample, I set 10 as count.

from TikTokApi import TikTokApi
api = TikTokApi.get_instance(custom_verifyFp=verifyFp, use_test_endpoints=True)
results = 10
hashtag = 'Messi'
search_results = api.by_hashtag(count=results, hashtag=hashtag)
for tiktok in search_results:

Step3. run the sample code

You can get the video links.

$ python

If you want to know the general return, you can see it ↓