Skip to content
qiyas.cc
Problem Solver
cc · blog · Engineering 2026-11-16 · 9 min

What is TikSocket, and is there anything like it?

TikSocket is the Baileys-style TikTok library I wrote. Here is how it works, what it can and cannot do, and an honest comparison with every alternative I could verify, official APIs included.


Short version: TikSocket is an open source Python library that does for TikTok what Baileys does for WhatsApp. You scan a QR code once, the session is saved, and from then on your code can post videos and photo carousels, read and answer direct messages, follow, like and comment, all from your own account, with events you can listen to.

Is there anything like it? Pieces of it, yes. One library reads LIVE streams, another uploads videos, the official APIs cover a slice each. Nothing I found does the whole set in one socket. Below is the full picture, with the trade-offs.

The code is on GitHub at github.com/qiyascc/tiksocket, and the project page is at qiyas.cc/projects/tiksocket.

Why “Baileys for TikTok”

Baileys is a WebSockets-based TypeScript library for the WhatsApp Web API. You scan a QR, it keeps the session in a folder with useMultiFileAuthState, and you write sock.ev.on("messages.upsert", ...) to catch incoming messages. Anyone who has built a WhatsApp bot knows that shape.

TikTok had nothing with that shape. So I took the model and moved it over, names included:

Baileys TikSocket
makeWASocket({ auth }) make_tiktok_socket(auth)
useMultiFileAuthState("auth_info") use_multi_file_auth_state("auth_info")
sock.ev.on("messages.upsert", ...) sock.on("messages.upsert", ...)
sock.sendMessage(jid, { text }) await sock.send_message(chat_id, text)

If you know Baileys, you know TikSocket. That was the whole point.

How it works

One difference matters more than the rest, so it goes first. Baileys speaks WhatsApp’s protocol directly. TikSocket drives a real Chromium in the background through Playwright and uses the same TikTok website you use. It can do what a logged in person can do on tiktok.com, and nothing more.

What follows from that:

  • No developer account, no app review, no API keys. You log in with your own account by QR.
  • The session is encrypted. The browser state is stored with Fernet encryption. The key comes from an argument, the TIKSOCKET_KEY environment variable, or a .key file with 0600 permissions.
  • One persistent Chromium profile per account, reused by every operation.
  • Every action is confirmed by TikTok’s own response. A follow, like, comment or profile edit only counts once TikTok’s JSON says so. If nothing needed to change, ActionResult.changed is False.
  • Messages are never sent twice. Pass a client_id and a retry with the same id is skipped.
  • Captchas wait for a human. When TikTok shows a puzzle, the operation pauses (10 minutes by default) and a person solves it in the web UI, then the work continues.
  • Listening is polling. TikSocket does not hold TikTok’s internal socket open. It checks the inbox every 25 seconds by default and emits new messages as messages.upsert.

What it can do

Each feature in the README has a status. live means it was checked on tiktok.com with a real account. ready means it is built on TikTok’s web controls and its own responses, covered by offline tests, and waiting for wider live use. I deliberately did not run account-changing actions against a real account during development.

Area What you get Status
Login QR in the terminal or the web UI, cookie login, answering the “verify it’s you” step with a code live
Video posts Caption, hashtags, sound search live
Photo posts 1 to 35 photos as a swipeable carousel with title and music live
Direct messages List chats, read messages, listen, send text live
New chats, message requests, reactions, replies Start a chat from a username, accept or delete requests ready
People Profile lookup, user search, followers and following, relationship check live
Follow and block Follow, unfollow, block, remove a follower ready
Content Post stats, a user’s posts, comments, video download live
Likes, comments, reposts Like, favorite, repost, comment and reply ready
Your own posts Delete, pin, who can see it, comments on or off ready
Profile Name, username, bio, photo, private or public ready
Discover Search videos and hashtags, For You and Explore feeds, notifications live

You can use it three ways:

  • a Python library with a Baileys style socket and events,
  • a CLI with 50 commands that prints the login QR right in your terminal,
  • a web UI and REST API on port 8787, token protected, with events over SSE and WebSocket.

The REST API means you can drive it from Node.js, PHP or anything else. There is no native Node version yet.

What the code looks like

import asyncio
from tiksocket import make_tiktok_socket, use_multi_file_auth_state
from tiksocket.terminal import show_qr

async def main():
    sock = make_tiktok_socket(use_multi_file_auth_state("auth_info"))
    sock.on("qr", show_qr)

    @sock.on("messages.upsert")
    async def on_messages(event):
        for message in event["messages"]:
            if not message.from_me and message.kind == "text":
                await sock.send_message(message.chat_id, "Thanks, we will answer soon",
                                        client_id=f"auto-{message.id}")

    if await sock.connect() is None:
        await sock.wait_for_login(timeout=300)

    await sock.post_photos(["1.jpg", "2.jpg", "3.jpg"], "New listing #baku", title="3 bedroom flat", auto_sound=True)
    await sock.start_listening(interval=20)

asyncio.run(main())

And from the terminal:

pip install git+https://github.com/qiyascc/tiksocket
playwright install chromium
tiksocket login
tiksocket post photos a.jpg b.jpg --title "3 bedroom flat" -c "#baku" --auto-sound
tiksocket listen

--dry-run fills in everything on TikTok’s upload page and stops right before pressing Post. That is the safest way to try it.

What it can’t do

Better you hear it from me than find out on day two.

  • No stories. TikTok’s website has no story upload. Phone app only.
  • No images, voice notes or files in DMs. The web chat only has a text box and emoji, so TikSocket sends text.
  • No website link in your bio. The web profile editor does not have that field.
  • No duets, stitches or LIVE. App only.
  • Message requests. Until the other person accepts, TikTok allows one message. After that you get RequestPending.
  • Old chat history is read from the visible window only.
  • Speed. A real browser is slower and heavier than a direct HTTP call. That is the price of not breaking every week.
  • TikTok redesigns can break selectors. Every important control has several fallbacks, but there is no guarantee.
  • Not on PyPI yet. You install it from GitHub. It is version 0.2.0, so it is young.

Is there anything like it?

I checked each of these against its own README or official documentation.

Project What it does How it works Language Official
TikSocket Posting, reading and sending DMs, follows, likes, comments, profile, search, events Real Chromium, QR login Python, CLI, REST No
Baileys The same model, for WhatsApp WebSocket, WhatsApp Web protocol TypeScript No, and it is WhatsApp
TikTokLive Reads LIVE streams: comments, gifts, likes, follows TikTok’s Webcast WebSocket, Euler Stream signing server Python No
TikTok-Live-Connector LIVE events, plus sending chat messages to a LIVE room with a session and a signing key Webcast, Euler Stream signing server Node.js No
TikTok-Api Reads trending, users and videos. Cannot post Playwright, logged out Python No
tiktok-uploader Uploads and schedules videos Playwright Python No
autotok Uploads and schedules videos, a proxy per account Browser for login and signing Python, TypeScript, Go No
ReLttk DM bot with plugins, group chats, media downloads No browser, TikTok’s internal endpoints and WebSocket Python No
Content Posting API Video and photo posting OAuth, developer app Any Yes
Display API A user’s profile and recent videos OAuth, user.info.basic, video.list Any Yes
Business Messaging API DMs for business accounts Reviewed app, eligible business account Any Yes

A few notes:

  • ReLttk is not mine. There is a fork of it on my GitHub profile, but the author is Linkmail16. It takes the opposite approach to TikSocket: no browser, TikTok’s internal endpoints and WebSocket through reverse engineering. That makes it faster and lets it handle media in DMs, but it breaks sooner when TikTok changes its request signing. Its own README calls it early stage.
  • TikTokLive and TikTok-Live-Connector are the right tools for LIVE. My TikTok LIVE games are driven by stream events too. But neither posts from your account or handles your inbox, and both READMEs say plainly that they are reverse engineering projects, not production-ready APIs.
  • TikTok-Api only reads. Its README says it cannot post or upload and has no support for user-authenticated routes.
  • The uploaders do one job, video upload. If that is your only job, they are enough.

What the official APIs give you

The official route should always be the first thing you check. It just comes with conditions.

Content Posting API. TikTok’s own guidelines say unaudited clients can only post with SELF_ONLY visibility, can allow up to 5 users to post in a 24 hour window, and every posting account must be private at the time of posting. To lift that, your app has to pass TikTok’s audit. So an agency cannot switch it on tomorrow and start publishing for clients.

Display API. user.info.basic returns basic profile info, video.list returns metadata for the user’s recent videos. Read only. No posting, no messages.

Business Messaging API. This is the official DM API for business accounts: send messages, list conversations and messages, webhooks. Developers have to pass data compliance reviews, only certain business accounts are supported, and accounts registered in some regions cannot use it. For a regular personal account there is no official DM API at all.

So the answer to “why not just use the official API” is simple. If it covers what you need, use it. If it doesn’t, the unofficial route is what is left, with its own risks.

The risk, before you start

TikTok’s privacy blog states that its Terms of Service prohibit using automated scripts to collect information from or otherwise interact with its services. TikSocket, TikTokLive, the uploaders and ReLttk can all fall under that. Baileys is in the same position with WhatsApp and says so in its README.

In practice:

  • Accounts can be limited or banned. Don’t test on an account you can’t afford to lose.
  • Don’t spam. Mass messages, mass follows and mass comments break the rules and are the fastest way to get blocked. TikSocket’s README says it too: respect people’s inboxes.
  • Keep the session folder private. It is a logged in TikTok account.
  • If the server is reachable from the internet, set TIKSOCKET_TOKEN and TIKSOCKET_KEY and put it behind HTTPS.

TikSocket is not affiliated with TikTok or ByteDance. You automate your own account at your own risk.

Which one to pick

  • Reacting to gifts and comments during a LIVE: TikTokLive (Python) or TikTok-Live-Connector (Node.js).
  • Reading public data only: TikTok-Api or the official Display API.
  • Only uploading and scheduling videos: the official Content Posting API if you can pass the audit, the uploaders if you can’t.
  • Answering customers from a business account: look at the Business Messaging API first, and use it if your account and region qualify.
  • All of it in one place: posting, DMs, follows, comments and profile edits on one account, with Baileys style events. That is exactly what TikSocket is for.

The code is open and MIT licensed. If you find a bug, or TikTok changed something and broke it, open an issue on GitHub.

If you need TikTok, WhatsApp or another platform wired into your business systems, see API integrations and automation or get in touch.

Sources

related