Skip to main content

tiktok-forge

PyPI Python Node License Tests webmssdk app

GitHub Telegram

TikTok request signing for web and app — one import, real values on the wire.

from tiktokforge import WebClient, TikTokSigner

with WebClient() as c:
    c.get("/api/challenge/detail/", params={"challengeName": "fyp"}).json()

TikTokSigner.generate_headers(params="aid=1233&device_id=7171234567890123456")

Install

pip install tiktok-forge
Requirement Why
Python 3.10+ dataclasses, typing
Node 16+ executes the vendored web bundle
pycryptodome, requests pulled in automatically

Node is resolved from TIKTOKFORGE_NODE, then PATH, then the usual install directories. If it isn't found the bridge raises NodeUnavailable and lists every path it tried. App signing works with no node installed.


Why this exists

Signatures rot. Every app release re-rolls the identity, every web build re-rolls the bundle, and most packages on this shelf are a frozen table someone scraped in 2023. They keep returning strings. The strings stop working.

The split here is boring on purpose:

  • Web — X-Bogus is produced by TikTok's own bundle, running. We ship webmssdk.js, boot it in a browser shim, and call the same entry point the site calls. No hand-ported cipher, no table guessing.
  • App — x-argus, x-gorgon, x-ladon are arithmetic, so they live in Python. The identity they're keyed with (version_name, version_code, sdk_ver, device profile) sits in one place instead of being sprinkled through crypto code.

Rules that came from things breaking:

  1. If it isn't running their code, it isn't a signature. A string that looks right and 403s is worse than nothing — you build a pipeline on top of it first.
  2. No invented headers. If the bundle doesn't emit X-Gnarly, we don't emit X-Gnarly.
  3. Version identity is config, not code. Moving to a new app build is editing a dataclass.
  4. Prove it, then ship it. The updater boots a candidate bundle, signs a real URL, prints the result, and only then replaces the file.
  5. Fuck is what you get when you reimplement a rotating cipher from a blog post. Read the tables once and stop guessing where the salt goes.
  6. Docs lie, tests don't. 40 offline tests, plus a CLI that hits the real edge.

Web

from tiktokforge import WebClient

with WebClient(retries=2, timeout=25) as client:
    r = client.get("/api/challenge/detail/", params={"challengeName": "fyp"})
    print(r.status_code, r.json()["challengeInfo"]["challenge"]["id"])

WebClient is a requests session that signs every call fresh, merges the standard aid=1988 parameter set, and retries when the edge answers 200 with an empty body — that's what a stale signature looks like from outside.

Lower level:

from tiktokforge import sign_web, with_signature, generate_web_headers

sign_web("https://www.tiktok.com/api/post/item_list/?aid=1988&count=20")
# {'X-Bogus': 'WMu77aEMZKcMsdoF'}

with_signature("https://www.tiktok.com/api/post/item_list/?aid=1988")
# '...&X-Bogus=WMu77aEMZKcMsdoF'

generate_web_headers("https://www.tiktok.com/api/challenge/detail/?aid=1988")
# User-Agent, Referer, X-Bogus, Cookie(msToken + tt_webid + s_v_web_id)

One long-lived engine, if you're signing in a loop:

from tiktokforge import get_bridge

engine = get_bridge()      # boots once
engine.sign("https://www.tiktok.com/api/post/item_list/?aid=1988")
engine.close()

Measured here: 100 signatures in 108 ms — 1.08 ms each after boot. Spawning node per signature costs ~250 ms.

Produced values:

Value Source
X-Bogus vendored bundle, 16 chars, time-seeded
msToken 107-char urlsafe base64
ttwid ttwid.bytedance.com/ttwid/union/register/
verifyFp / s_v_web_id device fingerprint
tt_webid / webId 19-digit id

No X-Gnarly — the current bundle has no such output.


App

from tiktokforge import APP_DEFAULTS, TikTokSigner

params = (
    "aid=1233&app_name=musical_ly&device_platform=android"
    "&device_id=7171234567890123456&version_name=47.5.3&os_version=15"
)
headers = TikTokSigner.generate_headers(params=params, data="username=demo")

# x-ss-req-ticket  x-ss-stub  x-tt-trace-id
# x-khronos        x-ladon    x-gorgon      x-argus

Send with your own client:

import requests

url = f"https://api.tiktokv.com/aweme/v1/feed/?{params}"
r = requests.get(url, headers={"User-Agent": APP_DEFAULTS.user_agent(), **headers})

Pinned device identity

from tiktokforge import AppDefaults, DeviceProfile, TikTokSigner

profile = AppDefaults(device=DeviceProfile(
    device_id="7171234567890123456",
    install_id="7171234567890123457",
    device_type="SM-S928B",
    device_brand="samsung",
    os_version="15",
    os_api=35,
))
profile.user_agent()
# com.zhiliaoapp.musically/2023705030 (Linux; U; Android 15; en_US; SM-S928B; ...)

TikTokSigner.generate_headers(params=params, profile=profile)

The UA and the signatures come from the same profile, so they can't disagree.

Version handling

from tiktokforge import version_code_for

version_code_for("47.5.3")   # 2023705030

Derivation: 2023 + major%10 + minor:02 + patch:02 + 0. Deviating releases go in VERSION_CODE_OVERRIDES inside tiktokforge/config.py. Per-call override: TikTokSigner.generate_headers(..., version_code=2023705030).

Current defaults: app 47.5.3, sdk v05.01.03-ov-android, aid 1233.

TTEncrypt

The app gzips the protobuf body, then encrypts it. Same here by default:

blob = TikTokSigner.encrypt({"device_id": "7171234567890123456", "aid": 1233})
TikTokSigner.decrypt(blob)   # -> '{"device_id":"7171234567890123456","aid":1233}'

encrypt(..., compress=False) for raw blobs.


Verify the install

tiktokforge-verify
library      1.1.0
node         C:\Program Files\nodejs\node.exe
bundle       webmssdk.js
X-Bogus      WDAK7QqovEy/i+Zg
cookies      msToken, s_v_web_id, tt_webid, tt_webid_v2
status       200  (727 bytes)
result       OK

Flags: --json, --no-net, --path, --params.


API surface

Call Returns
TikTokSigner.generate_headers(params, data=..., profile=...) dict of x-* headers
TikTokSigner.encrypt(obj) / .decrypt(blob) TTEncrypt round-trip
sign_web(url) {'X-Bogus': ...}
with_signature(url) URL with X-Bogus appended
generate_web_headers(url) full header set with cookies
WebClient().get/post(...) signed response
generate_ms_token() / generate_verify_fp() / generate_web_id() tokens
get_bridge() long-lived signing engine
version_code_for("47.5.3") 2023705030

tiktokforge.algorithms exposes the primitives: Simon, SM3, Argus, Gorgon, Ladon, TTEncrypt, ProtoBuf.


Notes

  • The web signer needs node; the app signer does not.
  • The vendored bundle is refreshed from a source checkout with python tools/update_bundle.py — the wheel ships the one it was built with.
  • Tests: 40 offline. Live checks go through tiktokforge-verify, so a network hiccup never shows up as a red test.

License

MIT.

Built by MERO — Telegram @QP4RM · source github.com/6x-u/tiktok-forge

Metadata

Release files for tiktok-forge 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tiktok-forge 1.1.0
File Size Uploaded Provenance Actions
tiktok_forge-1.1.0.tar.gz 178.2 kB Without provenance Details for tiktok_forge-1.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tiktok-forge 1.1.0
File Interpreter ABI Platform Actions
tiktok_forge-1.1.0-py3-none-any.whl Python 3 none any Details for tiktok_forge-1.1.0-py3-none-any.whl

Total release size: 351.7 kB

Release files / tiktok_forge-1.1.0.tar.gz

Download URL tiktok_forge-1.1.0.tar.gz
Size 178.2 kB
Tags Source
SHA-256 checksum
How to use checksums
5ce35c0484fbff06858d461c17485a343d3e6062dff4f95420f8d08d0b5dea45
BLAKE2b-256 checksum
How to use checksums
a98f8dd7d1206a498bac5f98ab41fe0a48669d5e2cc80566a27bfbda6f6fcd10
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.0

Release files / tiktok_forge-1.1.0-py3-none-any.whl

Download URL tiktok_forge-1.1.0-py3-none-any.whl
Size 173.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4da7656dd50c93cd7cb0bc7daf27acf86834d61271dc8996f3761346868a8bfd
BLAKE2b-256 checksum
How to use checksums
e4898e905f3380b2bd98759db04951e9406cb40cd41a815ec5cba0ba7825f86e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.0

Security for tiktok-forge 1.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page