TikTok Scraper is a tool designed to extract media and post metadata from TikTok without requiring a password or a login session. It does not utilize an official API; instead, it interfaces with TikTok's web endpoints to return public data in a structured and exportable format.
Core Features
Installation
This tool requires Node.js v10 or newer.
Via NPM:
npm i -g tiktok-scraper
Via YARN:
yarn global add tiktok-scraper
How to Use It
Run tiktok-scraper --help to view all available options.
tiktok-scraper user [id] — Scrapes a user's feed using their username.tiktok-scraper hashtag [id] — Scrapes a specific hashtag. Exclude the '#' symbol.tiktok-scraper trend — Retrieves posts from the current trending feed.tiktok-scraper music [id] — Fetches posts associated with a specific music ID.tiktok-scraper video [id] — Downloads a single video without the watermark.tiktok-scraper history — Displays a log of previous download activity.tiktok-scraper from-file [file] [async] — Batch processes users, hashtags, music, or video URLs from a text file (one entry per line).# Extract and download 100 videos from a user using a session cookie
tiktok-scraper user USERNAME -d -n 100 --session sid_tt=dae32131231
# Extract and download 100 trending videos
tiktok-scraper trend -d -n 100 --session sid_tt=dae32131231
# Download a specific video by URL
tiktok-scraper video https://www.tiktok.com/@tiktok/video/6807491984882765062 -d
# View download history
tiktok-scraper history
# Remove history for a specific user
tiktok-scraper history -r user:bob
# Execute batch scraping from a file
tiktok-scraper from-file BATCH_FILE ASYNC_TASKS -d
.user(id, options) — Scrapes a user feed (Returns a Promise)..hashtag(id, options) — Scrapes a hashtag feed (Returns a Promise)..trend('', options) — Scrapes trending posts (Returns a Promise)..music(id, options) — Scrapes posts by music ID (Returns a Promise)..userEvent(id, options) — Streams user feed data via EventEmitter..hashtagEvent(id, options) — Streams hashtag feed data via EventEmitter..trendEvent('', options) — Streams trending feed data via EventEmitter..musicEvent(id, options) — Streams music feed data via EventEmitter..getUserProfileInfo('USERNAME', options) — Retrieves specific profile data..getHashtagInfo('HASHTAG', options) — Retrieves hashtag metadata..signUrl('URL', options) — Generates signed request URLs for API calls..getVideoMeta('WEB_VIDEO_URL', options) — Retrieves video metadata, including watermark-free URLs..getMusicInfo('MUSIC_URL', options) — Retrieves music metadata.const options = {
// Number of posts to scrape (default: 20)
number: 50,
// Start scraping from this specific timestamp (default: 0)
since: 0,
// Session strings for accessing restricted feeds (default: [''])
sessionList: ['sid_tt=21312213'],
// HTTP/SOCKS proxy (accepts a string or an array for rotation)
proxy: '',
// If true, searches by numeric user ID rather than username
by_user_id: false,
// Number of concurrent downloads (default: 5)
asyncDownload: 5,
// Number of concurrent scrapers for music and hashtags (default: 3)
asyncScraping: 3,
// Output directory
filepath: `CURRENT_DIR`,
// Custom name for the output file
fileName: `OUTPUT_NAME`,
// Output format: csv, json, all, or na (default: 'na')
filetype: `na`,
// Custom request headers (essential for fetching video URLs)
headers: {
'user-agent': "CUSTOM_USER_AGENT",
referer: 'https://www.tiktok.com/',
cookie: `tt_webid_v2=68dssds`,
},
// Set to true to download videos without watermarks
noWaterMark: false,
// Set to true for HD video (requires noWaterMark: true)
hdVideo: false,
// verifyFp string for request validation
verifyFp: '',
// Use TikTok test endpoints if encountering CAPTCHAs
useTestEndpoints: false
};
const TikTokScraper = require('tiktok-scraper');
(async () => {
try {
const posts = await TikTokScraper.user('USERNAME', {
number: 100,
sessionList: ['sid_tt=58ba9e34431774703d3c34e60d584475;']
});
console.log(posts);
} catch (error) {
console.error(error);
}
})();
const TikTokScraper = require('tiktok-scraper');
const users = TikTokScraper.userEvent("tiktok", { number: 30 });
users.on('data', json => {
// Handle individual post data
console.log(json);
});
users.on('done', () => {
console.log('Scraping completed');
});
users.on('error', error => {
console.error('Scraping error:', error);
});
users.scrape();
Docker Support
Note that CLI flags like --filepath and --historypath do not function as expected within a Docker container. You must use volume mounts to persist data.
Build the image:
docker build -t tiktok-scraper .
Run the container:
# Save output to the current host directory
docker run -v $(pwd):/usr/app/files tiktok-scraper user tiktok -d -n 5 -s
# Save output to a specific host path
docker run -v /User/custom/downloads:/usr/app/files tiktok-scraper user tiktok -d -n 5 -s
Managing Sessions
While sessions are not always mandatory, they are highly recommended. If TikTok flags your IP or proxy, providing a valid session cookie can often bypass these restrictions.
tiktok.com.Cookie field.sid_tt value (e.g., sid_tt=521kkadkasdaskdj4j213j12j312;).--session flag for one-off commands or --session-file for bulk processing.sessionList array (e.g., sessionList: ["sid_tt=xxx;"]).Downloading Videos via the Module
The videoUrl generated by the scraper is cryptographically tied to the tt_webid_v2 cookie. To successfully download the video, you must use the exact same headers utilized during the initial scrape.
headers property. Use this object when making your download request.options object, ensure that same headers object is reused when fetching the videoUrl.Sample Output
The tool generates structured JSON responses for video feeds, user profiles, hashtag details, and music info. For the comprehensive data schema, please refer to the project's core documentation.
ClipSketch AI: Frame-Accurate Video Tagging & AI Storyboard Generation
Prompt Optimizer: Write Better AI Prompts in Seconds
FossFLOW: Offline-Ready Isometric Diagram Builder for the Browser
NetBird Setup Guide: Building a WireGuard Mesh VPN
Firecrawl API: Converting Any Website Into Clean Markdown for LLMs
Twenty CRM Local Setup and Docker Deployment Guide for Developers
Memvid: Store Millions of Text Chunks in a Single MP4 File
Fay: Build and Deploy Your Own Talking Digital Human for Free
AingDesk: Run Local AI Models and Build a Private Knowledge Base
n8n Automation: Over 400 AI Integrations in a Single Workflow
Add Area Fill to Line Charts in Excel: Step-by-Step
Shendeng VPN: Two Modes to Speed Up Games and Chinese Apps