Skip to main content

Overview

WebDefaults is a global configuration object that controls default parameters used when creating the TikTokWebClient. It allows you to customize HTTP headers, URL parameters, cookies, and server endpoints.

Accessing WebDefaults

from TikTokLive.client.web.web_settings import WebDefaults

# Modify settings before creating a client
WebDefaults.tiktok_sign_api_key = "your_api_key"
WebDefaults.web_client_headers["Custom-Header"] = "value"

Configuration Parameters

Base URLs

tiktok_app_url

Type: str
Default: "https://www.tiktok.com"
The TikTok app URL used to scrape room information.
WebDefaults.tiktok_app_url = "https://www.tiktok.com"

tiktok_sign_url

Type: str
Default: "https://tiktok.eulerstream.com"
The signature server URL used to generate tokens for connecting to TikTokLive. By default, this points to Euler Stream, but you can swap in your own signature server.
WebDefaults.tiktok_sign_url = "https://your-sign-server.com"

tiktok_webcast_url

Type: str
Default: "https://webcast.tiktok.com/webcast"
The TikTok livestream URL where webcast API endpoints are accessed.
WebDefaults.tiktok_webcast_url = "https://webcast.tiktok.com/webcast"

HTTP Client Configuration

web_client_params

Type: dict
Default: See DEFAULT_WEB_CLIENT_PARAMS
URL parameters added to TikTok HTTP requests. These include browser information, language settings, screen dimensions, and more.
# Add custom parameter
WebDefaults.web_client_params["custom_param"] = "value"

# Modify existing parameter
WebDefaults.web_client_params["aid"] = 1988

web_client_headers

Type: dict
Default: See DEFAULT_REQUEST_HEADERS
HTTP headers added to TikTok requests.
WebDefaults.web_client_headers["User-Agent"] = "Custom User Agent"
WebDefaults.web_client_headers["Custom-Header"] = "value"

web_client_cookies

Type: dict
Default: {"tt-target-idc": "useast1a"}
Default cookies to initialize the HTTP client with.
WebDefaults.web_client_cookies["sessionid"] = "your_session_id"
WebDefaults.web_client_cookies["tt-target-idc"] = "useast1a"

WebSocket Configuration

ws_client_params

Type: dict
Default: See DEFAULT_WS_CLIENT_PARAMS
URL parameters added to the WebSocket connection URI.
WebDefaults.ws_client_params["custom_ws_param"] = "value"

ws_client_params_append_str

Type: str
Default: "&version_code=270000"
Extra string data appended to the WebSocket connection URI. This exists because Python dicts cannot handle duplicate keys, and TikTok’s WebSocket URL requires duplicate version_code parameters.
WebDefaults.ws_client_params_append_str = "&version_code=270000&extra=value"

Authentication & Security

tiktok_sign_api_key

Type: Optional[str]
Default: None
An Euler Stream API key used to increase rate limits when connecting to TikTok LIVE.
WebDefaults.tiktok_sign_api_key = "your_euler_stream_api_key"

ja3_impersonate

Type: str
Default: "chrome131"
The JA3 fingerprint to impersonate when making requests. This should match the current version on the Sign Server, or “privileged” methods (like sending gifts) will fail.
WebDefaults.ja3_impersonate = "chrome131"

Default Parameters

DEFAULT_WEB_CLIENT_PARAMS

The following parameters are included by default in HTTP requests:
{
    "aid": 1988,
    "app_language": "en",  # Random location-based
    "app_name": "tiktok_web",
    "browser_language": "en-US",  # Random location-based
    "browser_name": "Mozilla",  # Random device-based
    "browser_online": "true",
    "browser_platform": "Win32",  # Random device-based
    "browser_version": "5.0",  # Random device-based
    "cookie_enabled": "true",
    "device_platform": "web_pc",
    "focus_state": "true",
    "from_page": "",
    "history_len": 8,  # Random 4-14
    "is_fullscreen": "false",
    "is_page_visible": "true",
    "screen_height": 1080,  # Random screen preset
    "screen_width": 1920,  # Random screen preset
    "tz_name": "America/New_York",  # Random location-based
    "channel": "tiktok_web",
    "data_collection_enabled": "true",
    "os": "Windows",  # Random device-based
    "priority_region": "US",  # Random location-based
    "region": "US",  # Random location-based
    "user_is_login": "false",
    "webcast_language": "en",  # Random location-based
    "msToken": ""
}
Location, Device, and Screen parameters are randomly selected from presets on startup to help with fingerprint diversity.

DEFAULT_REQUEST_HEADERS

The following headers are included by default:
{
    "Connection": "keep-alive",
    "Cache-Control": "max-age=0",
    "User-Agent": "Mozilla/5.0...",  # Random device-based
    "Accept": "text/html,application/json,application/protobuf",
    "Referer": "https://www.tiktok.com/",
    "Origin": "https://www.tiktok.com",
    "Accept-Language": "en-US,en;q=0.9",
    "Accept-Encoding": "gzip, deflate",
    "Sec-Fetch-Site": "same-site",
    "Sec-Fetch-Mode": "cors",
    "Sec-Fetch-Dest": "empty",
    "Sec-Fetch-Ua-Mobile": "?0"
}

WebSocket Parameters

The following parameters are used for WebSocket connections:
{
    "aid": 1988,
    "app_language": "en",
    "app_name": "tiktok_web",
    "browser_platform": "Win32",
    "browser_language": "en-US",
    "browser_name": "Mozilla",
    "browser_version": "5.0",
    "browser_online": "true",
    "cookie_enabled": "true",
    "tz_name": "America/New_York",
    "device_platform": "web",
    "debug": "false",
    "host": "https://webcast.tiktok.com",
    "identity": "audience",
    "live_id": "12",
    "sup_ws_ds_opt": "1",
    "update_version_code": "2.0.0",
    "version_code": "180800",
    "did_rule": "3",
    "screen_height": 1080,
    "screen_width": 1920,
    "heartbeat_duration": "0",
    "resp_content_type": "protobuf",
    "history_comment_count": "6",
    "last_rtt": "150"  # Random 100-200ms
}

Example: Custom Configuration

from TikTokLive import TikTokLiveClient
from TikTokLive.client.web.web_settings import WebDefaults

# Configure before creating client
WebDefaults.tiktok_sign_api_key = "your_api_key"
WebDefaults.web_client_headers["Custom-Header"] = "CustomValue"
WebDefaults.web_client_params["custom_param"] = "value"
WebDefaults.web_client_cookies["sessionid"] = "your_session_cookie"

# Create client with custom settings
client = TikTokLiveClient(unique_id="@username")

See Also

Build docs developers (and LLMs) love