Skip to main content

Unofficial TikTok API library: scrape video/user metadata and optionally download media (no API key required)

Project description

tiktok-api

Unofficial TikTok API library: scrape video and user profile metadata, and optionally download videos, slides, and audio. No official API key required.

Install

pip install -e .

Or install dependencies only:

pip install requests beautifulsoup4 browser_cookie3

Then use the single module tiktok_api.py from this directory (e.g. add the directory to PYTHONPATH or copy the file).

Usage

from tiktok_api import TT_Content_Scraper

scraper = TT_Content_Scraper(
    wait_time=0.35,
    output_files_fp="data/",
    progress_file_fn="progress_tracking/scraping_progress.db",
    clear_console=False,
)

# Add video IDs (from TikTok URL) and/or usernames
scraper.add_objects(ids=["7398323154424171806"], title="batch1", type="content")
scraper.add_objects(ids=["tagesschau", "tiktok"], title="users", type="user")

# Scrape: metadata only, or with media (mp4/jpeg/mp3)
scraper.scrape_pending(scrape_files=False)   # metadata only
# scraper.scrape_pending(scrape_files=True)  # also download videos/slides/audio
  • Content: use type="content" and video IDs from the video URL.
  • Users: use type="user" and usernames (with or without @).

Output is written under output_files_fp:

  • content_metadata/<video_id>.json – video/post metadata
  • user_metadata/<username>.json – user profile metadata
  • content_files/ – mp4, jpeg, mp3 when scrape_files=True

Progress is stored in the SQLite database at progress_file_fn (pending/completed/error per ID).

Run as script

python tiktok_api.py

Runs a one-off example: one video ID, metadata only, output in data/.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tiktok_api_unofficial-0.1.0.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tiktok_api_unofficial-0.1.0-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file tiktok_api_unofficial-0.1.0.tar.gz.

File metadata

  • Download URL: tiktok_api_unofficial-0.1.0.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for tiktok_api_unofficial-0.1.0.tar.gz
Algorithm Hash digest
SHA256 642e7880a0222b8efe0b989614e39eeae2c96baed7ee549bf2681ef8ab5d7902
MD5 d6f40a6209af6652297d5a85105b5c23
BLAKE2b-256 2632e65ac854b0e72e12101394e4b13c55f11ec15b3bf83c097a698564c26be4

See more details on using hashes here.

File details

Details for the file tiktok_api_unofficial-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for tiktok_api_unofficial-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 59024864b131a020b1b93f3a177b480f67ffadc166defdaa2880ee17ab64bf03
MD5 b47e2dd080a6fcac4728e0b271224fb2
BLAKE2b-256 258f4ded7dc1743117549413be10b67ae2556457dec47b10412995967c584c1f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page