TikTok Scraper: Download Watermark-Free Videos Without Login

7月13日 Published inData Scraping Tools

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

  • Metadata Extraction: Retrieve extensive post metadata from users, hashtags, trends, or specific music IDs.
  • Data Export: Save post metadata in JSON or CSV format.
  • Media Archiving: Bundle downloaded media (with or without watermarks) into ZIP archives.
  • Watermark Removal: Fetch individual watermark-free videos directly through the command line.
  • Signed URLs: Generate signed URLs to route custom requests to the TikTok API.
  • Flexible Parsing: Extract metadata from user profiles, hashtag feeds, and individual video pages.
  • Incremental Downloads: Track progress to ensure only new content is downloaded (CLI exclusive, requires download flag).
  • History Management: Review and manage past download activity via the CLI.
  • Batch Processing: Scrape and download users, hashtags, music feeds, and single videos in bulk from a plain text file.

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

Command Line Interface

Run tiktok-scraper --help to view all available options.

Commands

  • 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).

CLI Examples

# 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

Module Usage

Available Methods

  • .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.

Options Object

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
};

Promise Example

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);
    }
})();

Event Example

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.

How to Retrieve Your Session Cookie

  1. Log in to tiktok.com in your browser.
  2. Open the browser's developer tools (F12 or Right-click → Inspect) and go to the Network tab.
  3. Refresh the page and select any request directed to tiktok.com.
  4. Under Request Headers, look for the Cookie field.
  5. Copy the sid_tt value (e.g., sid_tt=521kkadkasdaskdj4j213j12j312;).

Implementing the Session

  • CLI: Use the --session flag for one-off commands or --session-file for bulk processing.
  • Module: Include the cookie in the 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.

  • Option 1 (Automatic Headers): The object returned by the scraper includes a headers property. Use this object when making your download request.
  • Option 2 (Manual Headers): If you define custom headers in the 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.