ScavioScavio
ProductPricingDocs
Sign InGet Started
  1. Home
  2. Tutorials
  3. How to Get TikTok User Posts via API
Tutorial

How to Get TikTok User Posts via API

Fetch a TikTok user's recent videos with engagement data using Scavio API. Python and JavaScript examples with pagination.

Get Free API KeyAPI Docs

Fetch a TikTok user's recent posts including play count, like count, comment count, share count, and video description via Scavio API at $0.005/page of results. Uses max_cursor pagination for fetching beyond the first page.

Prerequisites

  • Scavio API key
  • Target user's sec_uid (from profile endpoint)
  • Python 3.8+ or Node.js 18+

Walkthrough

Step 1: Get the user sec_uid

First call the profile endpoint to get the sec_uid needed for posts.

Python
import requests, os

HEADERS = {'Authorization': f'Bearer {os.environ["SCAVIO_API_KEY"]}',
           'Content-Type': 'application/json'}

profile = requests.post('https://api.scavio.dev/api/v1/tiktok/profile',
    headers=HEADERS, json={'username': 'target_user'}).json()
sec_uid = profile['data']['user']['sec_uid']

Step 2: Fetch first page of posts

Call the user/posts endpoint with sec_user_id and count.

Python
resp = requests.post('https://api.scavio.dev/api/v1/tiktok/user/posts',
    headers=HEADERS,
    json={'sec_user_id': sec_uid, 'count': 20})

data = resp.json()['data']
for video in data.get('videos', []):
    print(f"{video['desc'][:50]} | {video['stats']['playCount']:,} plays")

Step 3: Paginate with max_cursor

Use max_cursor from the response to fetch the next page.

Python
if data.get('has_more'):
    next_page = requests.post(
        'https://api.scavio.dev/api/v1/tiktok/user/posts',
        headers=HEADERS,
        json={'sec_user_id': sec_uid, 'count': 20,
              'max_cursor': data['max_cursor']})
    page2 = next_page.json()['data']
    print(f'Page 2: {len(page2.get("videos", []))} videos')

Python Example

Python
import requests, os

HEADERS = {'Authorization': f'Bearer {os.environ["SCAVIO_API_KEY"]}',
           'Content-Type': 'application/json'}

def get_all_posts(username, max_pages=5):
    profile = requests.post('https://api.scavio.dev/api/v1/tiktok/profile',
        headers=HEADERS, json={'username': username}).json()
    sec_uid = profile['data']['user']['sec_uid']
    videos = []
    params = {'sec_user_id': sec_uid, 'count': 20}
    for _ in range(max_pages):
        resp = requests.post('https://api.scavio.dev/api/v1/tiktok/user/posts',
            headers=HEADERS, json=params).json()['data']
        videos.extend(resp.get('videos', []))
        if not resp.get('has_more'):
            break
        params['max_cursor'] = resp['max_cursor']
    return videos

videos = get_all_posts('target_user')
print(f'Fetched {len(videos)} videos')

JavaScript Example

JavaScript
const H = {'Authorization': `Bearer ${process.env.SCAVIO_API_KEY}`, 'Content-Type': 'application/json'};
async function getPosts(username, maxPages = 5) {
  const profile = await fetch('https://api.scavio.dev/api/v1/tiktok/profile', {
    method: 'POST', headers: H, body: JSON.stringify({username})
  }).then(r => r.json());
  const secUid = profile.data.user.sec_uid;
  const videos = [];
  let params = {sec_user_id: secUid, count: 20};
  for (let i = 0; i < maxPages; i++) {
    const r = await fetch('https://api.scavio.dev/api/v1/tiktok/user/posts', {
      method: 'POST', headers: H, body: JSON.stringify(params)
    }).then(r => r.json());
    videos.push(...(r.data.videos || []));
    if (!r.data.has_more) break;
    params.max_cursor = r.data.max_cursor;
  }
  return videos;
}
getPosts('target_user').then(v => console.log(`${v.length} videos`));

Expected Output

JSON
Array of video objects with description, play count, like count, comment count, share count, and video metadata for each post.

Related Tutorials

  • How to Get TikTok Profile Data via API
  • How to Get TikTok Video Comments via API

Frequently Asked Questions

Most developers complete this tutorial in 15 to 30 minutes. You will need a Scavio API key (free tier works) and a working Python or JavaScript environment.

Scavio API key. Target user's sec_uid (from profile endpoint). Python 3.8+ or Node.js 18+. A Scavio API key gives you 50 free credits on signup.

Yes. The free tier includes 50 credits on signup, which is more than enough to complete this tutorial and prototype a working solution.

Scavio has a native LangChain package (langchain-scavio), an MCP server, and a plain REST API that works with any HTTP client. This tutorial uses the raw REST API, but you can adapt to your framework of choice.

Related Resources

Best Of

Best TikTok Hashtag Analytics APIs (2026)

Read more
Best Of

Best TikTok UGC Campaign Tracking APIs (May 2026)

Read more
Use Case

TikTok Brand Safety Creator Vetting

Read more
Glossary

TikTok max_cursor Pagination

Read more
Glossary

TikTok Unofficial API

Read more
Comparison

TikTok Proxy Scraping vs TikTok Third-Party API (Scavio, TikAPI)

Read more

Start Building

Fetch a TikTok user's recent videos with engagement data using Scavio API. Python and JavaScript examples with pagination.

Get Free API KeyRead the Docs
ScavioScavio

Real-time search API for AI agents. Search every platform, not just Google.

Product

  • Features
  • Pricing
  • Dashboard
  • Affiliates

Developers

  • Documentation
  • API Reference
  • Quickstart
  • MCP Integration
  • Python SDK

Alternatives

  • Tavily Alternative
  • SerpAPI Alternative
  • Firecrawl Alternative
  • Exa Alternative

Tools

  • JSON Formatter
  • cURL to Code
  • Token Counter
  • All Tools

© 2026 Scavio. All rights reserved.

Featured on TAAFT
Terms of ServicePrivacy Policy