Skip to content
theqiyas.cc
Problem Solver
cc · project · Open source

TikSocket

The Baileys alternative for TikTok. Scan a QR code once, and your code can post videos and photo carousels, read and send direct messages, follow, like, comment and listen to new messages as events. Python library, CLI, web UI and REST API.

Docker Playwright Python aiohttp

WhatsApp has Baileys: you scan a QR code once, the session is saved, and from then on your code can send and receive messages like a phone. TikTok had nothing like it. TikSocket is that, for TikTok.

There is no developer account, no app review and no API key. TikSocket drives a real Chromium in the background through Playwright and uses the same TikTok website a person uses.

Three ways to use it

  • A Python library with a Baileys style socket and events such as messages.upsert and connection.update.
  • A CLI with 50 commands. tiksocket login prints the QR code right in the terminal.
  • A web UI and REST API on port 8787, with token auth and a live event stream over Server Sent Events and WebSocket.

What it can do

  • Login. QR code in the terminal or the web UI, with live status (scanned, confirmed, expired), or login with cookies. When TikTok asks “verify it’s you”, the prompt, its buttons and code fields come back to your app so you answer it from there.
  • Sessions. Encrypted on disk, one folder per account, like Baileys’ useMultiFileAuthState. Many accounts run side by side.
  • Posting. A video with caption, hashtags and music, or 1 to 35 photos as a swipeable carousel.
  • Direct messages. List chats, read messages, send text, start new chats and message requests, react and reply, and listen for new messages.
  • People and content. Profiles, search, followers, follow and unfollow, block, likes, reposts, comments and replies, video downloads.
  • Your account. Delete, pin and hide your posts, turn comments off, change name, username, bio and photo, switch between private and public.
  • Discover. Search, hashtags, the For You and Explore feeds, notifications.

The README has an honest table of what TikTok’s website allows. Stories, duets, LIVE and sending images in chats only exist in the phone app, so TikSocket marks them as app only instead of pretending.

Built to survive TikTok

TikTok changes its web app all the time, so every important control has several selectors, in several languages. Popups are closed before acting. Every click is checked by waiting for the change it should cause: a message only counts as sent when its bubble shows up with a TikTok message id, and a message is only typed again if no bubble appeared, so a retry never sends it twice. Follows, likes and comments wait for TikTok’s own confirmation. Logouts, captchas and “too fast” limits raise typed errors, and every failure saves a screenshot.

It ships with a Dockerfile and docker compose, runs headless by default and supports proxies. 72 tests, MIT licensed.

TikSocket is not affiliated with TikTok or ByteDance. It automates the public website with your own logged in account, and automated use can break TikTok’s terms and get an account limited, so use it with care.