This Python script is a valuable tool for content creators looking to broadcast on TikTok's live streaming platform using OBS Studio, an alternative to TikTok LIVE Studio. The script's standout feature is generating a stream key, a capability typically restricted and highly sought after. This stream key enables users to stream via OBS Studio, offering more control and flexibility over their live broadcasts. Additionally, the script provides the base stream URL and a shareable URL for the stream.
- Retrieve the base stream URL.
- Generate a TikTok stream key.
- Obtain a shareable URL for the TikTok live stream.
- Support for specifying different games by their game tag IDs.
- Python 3.6+
requests
library- TikTok
sid_guard
cookie - Game tag ID
- Logged into TikTok LIVE studio at least once
- Have TikTok LIVE studio access
To use this script, you need the sid_guard
cookie from TikTok. This can be obtained through:
- Open Chrome and navigate to TikTok's website.
- Right-click anywhere on the page and select "Inspect" to open the Developer Tools.
- Navigate to the "Application" tab.
- Under "Cookies" on the left, find the TikTok domain and locate the
sid_guard
cookie. Copy its value.
- Install EditThisCookie for Chrome.
- Visit TikTok's website and click the EditThisCookie extension icon.
- Locate and copy the value of the
sid_guard
cookie.
- Download and install this extension: JSON Formatter (optional but recommended).
- Visit this url to find TikTok Live API Game Tag List.
- Use the id from the list to specify the game tag ID.
Ensure you have Python and the requests
library installed.
pip install requests
Run the script with the necessary parameters from the command line.
python TikTokStreamKeyGenerator.py <sid_guard> <title> <game_tag_id> [gen_replay] [close_room_when_close_stream]
sid_guard_cookie
: Your TikTok SID guard cookie.title
: Title of your stream.game_tag_id
: Game tag ID from TikTok Live API Game Tag List.gen_replay
(optional):true
to enable replay generation.close_room_when_close_stream
(optional):true
to close the room when the stream ends.
python TikTokStreamKeyGenerator.py "your_sid_guard_cookie" "My Stream Title" "12345" true false
The script will output:
- Base stream URL: The URL needed to connect to the TikTok live stream.
- Stream key for OBS Studio integration: Stream key that that you can use in OBS Studio to stream to TikTok.
- Shareable URL for the live stream: A URL that can be shared for others to view the live stream.
Swap the url inside TikTokStreamKeyGenerator.py at the line 21.