TikTok Discover pages, like TikTok Trends, group videos around a keyword. The top videos can vary from showing what's trending, what's popular in a niche, or which sounds and hashtags keep showing up. If you want to track those videos in your own tools, it's easiest to save them as structured data.
That's what SerpApi's TikTok Discover API is for. You give it the keyword from a Discover page URL, and it returns the videos as JSON, with views, likes, comments, shares, authors, music, hashtags, and more.
In this post, we'll try the API in the playground, make requests with cURL, Python, and JavaScript, and then look at pagination and customization.

What data does the TikTok Discover API return?
The API returns a JSON object. The response is stored in the video_results array, and each item describes one video from the Discover page. Here are the fields you'll probably use most:
position: position of the video on the pageidandlink: TikTok video ID and the link to the videodescription: caption of the video, including its hashtags and mentionsduration: duration of the video in secondspublished_date: when the video was posted (ISO 8601, UTC)plays,likes,comments,shares,bookmarks: engagement countscategories: categories TikTok assigned to the videohashtags: array of objects withid,name, andlinkmentions: array of objects withid,username, andlinkauthor: object withusername,name,link,followers,following,likes, andvideosmusic: object withid,title,author,link, andduration
Here's a trimmed excerpt, based on the example in the documentation:
{
"video_results": [
{
"position": 1,
"id": "7696609917196651806",
"link": "https://www.tiktok.com/@bendymoto/video/7696609917196651806",
"duration": 12,
"plays": 693300,
"likes": 37100,
"comments": 560,
"shares": 1835,
"bookmarks": 3844,
"author": {
"username": "bendymoto",
"followers": 149200
},
"music": {
"title": "original sound - Pš¾",
"duration": 12
}
}
]
}
A few things to keep in mind:
- Some fields only appear in some cases. For example,
sponsoredis only present on sponsored videos,author.verifiedonly on verified accounts, andmusic.albumonly on some licensed tracks. Read them defensively in your code. - Thumbnail links (
thumbnail,author.thumbnail,music.thumbnail) expire after about two days, so don't store them as permanent links. - The response also has a
serpapi_paginationobject, which we'll use in the pagination section.
You can find every field, with its type and an example, in the TikTok Discover API documentation.
How to use the TikTok Discover API
Try it in the playground
The fastest way to see the data is with the SerpApi Playground. It opens with the TikTok Discover engine and the query tiktok trends, and you can change the parameters and see the result right away.
The q parameter is the last part of a Discover page URL. For https://www.tiktok.com/discover/tiktok-trends, you can use tiktok trends or tiktok-trends. Only letters, numbers, spaces, and hyphens are supported, so use whats trending, not what's trending?.
Get your API key
To call the API from code, you need a SerpApi API key. Register for a SerpApi account, then copy your private key from your dashboard. In the examples below, we use YOUR_SERPAPI_API_KEY as a placeholder. Never commit your real key to a repository or paste it into a public post.
For scripts and programs, keep your API key out of public source code. Instead, set an environment variable to provide your API key (listed on your dashboard) by running export SERPAPI_KEY="YOUR_API_KEY" for Mac and $env:SERPAPI_KEY="YOUR_API_KEY" for Windows. If a key is accidentally exposed, you can regenerate it from the SerpApi dashboard.
Make a GET request
The API endpoint is https://serpapi.com/search?engine=tiktok_discover. The required parameters are engine, q, and api_key. JSON is the default output, so this request returns JSON:
https://serpapi.com/search?engine=tiktok_discover&q=tiktok+trends&gl=us&api_key=YOUR_SERPAPI_API_KEY
gl is optional. It's a two-letter country code, and it defaults to us.
Request Markdown output
If you want a more readable, token-efficient version of the results, for example to pass to an LLM or AI agent, add output=md:
https://serpapi.com/search?engine=tiktok_discover&q=tiktok+trends&gl=us&output=md&api_key=YOUR_SERPAPI_API_KEY
The documentation also lists the /search.md endpoint and the Accept: text/markdown request header as other ways to get Markdown. Read more on the Markdown output page.
Markdown is a curated view of the results, made for reading. When you need exact field access in code, like the examples below, use the JSON output.
cURL
This cURL request is equivalent to the JSON GET request above. (The documentation doesn't include a cURL example, so this one is built from the documented endpoint and parameters.)
curl --get "https://serpapi.com/search" \
--data-urlencode "engine=tiktok_discover" \
--data-urlencode "q=tiktok trends" \
--data-urlencode "gl=us" \
--data-urlencode "api_key=$SERPAPI_API_KEY"
--get with --data-urlencode takes care of encoding the space in tiktok trends for you.

Python
SerpApi has an official Python library. Check out the Python integration page for details. Install it with:
pip install serpapi
Then create a file named main.py:
import os
import serpapi
client = serpapi.Client(api_key=os.environ["SERPAPI_API_KEY"], timeout=60)
results = client.search({
"engine": "tiktok_discover",
"q": "tiktok trends",
"gl": "us",
})
if "error" in results:
raise SystemExit("The search failed. Check your API key and parameters.")
videos = results.get("video_results", [])
if not videos:
print("No videos found.")
for video in videos[:5]:
author = video.get("author", {})
print(f'#{video["position"]} @{author.get("username")} - {video.get("plays")} plays - {video["link"]}')
Run it with:
python main.py
Results should look like:

Here's what the script does:
- It reads your key from
SERPAPI_API_KEY, so the key stays out of your code. If the variable isn't set, the script stops with an error. - It sends one search for the keyword
tiktok trendsand gets the results back as a dictionary-like object, so there's no JSON to decode yourself. - If the response contains an
error, it stops. If the request worked butvideo_resultsis empty, it prints "No videos found." These are two different situations. - It prints the position, author username, play count, and link of the first five videos. We use
.get()for fields that might be missing.
Want to keep the results in a spreadsheet? A list of videos fits naturally into rows. This version uses the standard csv module and flattens the nested fields, taking author.username and music.title and joining the hashtag names with semicolons. Add it to the end of main.py:
import csv
with open("tiktok_videos.csv", "w", newline="", encoding="utf-8") as file:
writer = csv.writer(file)
writer.writerow(["position", "link", "plays", "likes", "comments", "shares", "author", "music", "hashtags"])
for video in videos:
writer.writerow([
video["position"],
video["link"],
video.get("plays"),
video.get("likes"),
video.get("comments"),
video.get("shares"),
video.get("author", {}).get("username"),
video.get("music", {}).get("title"),
";".join(tag["name"] for tag in video.get("hashtags", [])),
])
Optional: for production scripts, you may want to add retries and handle the library's HTTP and timeout exceptions. The example above is kept short so it's easy to start with.
JavaScript
SerpApi also has an official JavaScript library. Install it with:
npm install serpapi
Create a file named main.js:
async function main() {
const { getJson } = await import("serpapi");
const apiKey = process.env.SERPAPI_API_KEY;
if (!apiKey) {
console.error("Set the SERPAPI_API_KEY environment variable first.");
process.exit(1);
}
try {
const results = await getJson({
engine: "tiktok_discover",
q: "tiktok trends",
gl: "us",
api_key: apiKey,
});
if (results.error) {
console.error("The search failed. Check your API key and parameters.");
process.exit(1);
}
const videos = results.video_results ?? [];
if (videos.length === 0) {
console.log("No videos found.");
return;
}
for (const video of videos.slice(0, 5)) {
console.log(
`#${video.position} @${video.author?.username} - ${video.plays} plays - ${video.link}`
);
}
} catch (error) {
console.error("The request failed. Check your network connection and API key.");
process.exit(1);
}
}
main();
Run it with:
node main.js
The results should look like:

Other languages and no-code tools
SerpApi has libraries for other languages too. You can find them on the integrations page. If you prefer no-code automation, SerpApi announced a Make app and a verified n8n node.
Paginate through more videos
A TikTok Discover page holds about 100 videos in total. There are two ways to get them:
- Ask for them all at once. The
numparameter sets the maximum number of results, from1to100. The default is16, sonum=100returns the whole page in one request. - Go page by page. The
startparameter is the result offset. With the defaultnumof 16,start=0is the first page,start=16is the second,start=32is the third, and so on.
There's one catch with page-by-page requests. TikTok orders the videos differently for each session, so if you only change start, the next page can repeat videos from the previous one. To avoid that, pass the session_token from the first response. It's returned in serpapi_pagination.session_token. The previous and next links in serpapi_pagination already include it, and next is only present when TikTok has more videos for the keyword.
Here's a short extension of the Python script. It reuses the same client, collects up to three pages, and stops when there's no next link:
params = {"engine": "tiktok_discover", "q": "tiktok trends", "start": 0}
all_videos = []
for _ in range(3):
page = client.search(params)
if "error" in page:
raise SystemExit("The search failed. Check your API key and parameters.")
all_videos.extend(page.get("video_results", []))
pagination = page.get("serpapi_pagination", {})
if "next" not in pagination:
break
params["start"] += 16
params["session_token"] = pagination["session_token"]
print(f"Collected {len(all_videos)} videos")
This loop assumes the default page size of 16. If you change num, follow the next link from serpapi_pagination instead of guessing the offset.
Customize your requests
The documentation lists a few optional parameters that are handy for this API:
q: change the keyword to explore other Discover pages, such aswhats trending.gl: pick the country, using a two-letter code likeus(default),uk, orfr. See the Google countries page for the full list.num: control how many videos come back (1 to 100).no_cache: set totrueto force a fresh fetch. By default, SerpApi can serve a cached result if the query and parameters are exactly the same. The cache expires after 1 hour, and cached searches don't count toward your monthly searches.json_restrictor: return only the fields you need to reduce the payload size. See the JSON Restrictor documentation.
For example, to get the top 50 videos from the French Discover page, change the parameters in your Python script:
results = client.search({
"engine": "tiktok_discover",
"q": "tiktok trends",
"gl": "fr",
"num": 50,
})
The documentation doesn't list request filters like "only videos from this category." The categories and hashtags of each video come back as response data, so if you want to narrow things down, filter the video_results in your own code.
Conclusion
In this post, we looked at SerpApi's TikTok Discover API, including what's in video_results, how to make requests in the playground, with GET, cURL, Python, and JavaScript, how to get Markdown output, and how to paginate with start and session_token. From here, you could track how the videos on a keyword change over time, compare countries with gl, or send the Markdown output straight to an LLM.
For all the parameters and fields, see the TikTok Discover API documentation. SerpApi also lists a separate TikTok Shop API in its documentation, if you're interested in TikTok from a different angle.
If you would like to learn more about scraping short form video data on other platforms, like YouTube Shorts, check out this article:

