user_agentstring必填
User browser agent
https://api.sandbase.ai/v1/api/tiktok/web/web-guest-cookieReturns guest session cookies for TikTok Web based on a specified browser user agent string. Helps maintain session identity when querying web-based TikTok data.
[
{
"data": {
"Cookie": "tt_csrf_token=ywaXaQLU--rOjuZB_3jrby1Ny8QQ15htaWrs;ttwid=1%7CEApwHaHDTLZB5Jb-XinqPHzZUz6aisIjXuYSgXl2s9Q%7C1791290496%7C313236d0a37a07997f641229f2273ba668db80b177d347172150c5b6ec5771e5; reg-store-region=;store-idc=;msToken=HNusxz2W9Qlj49radrV_3MbrR7F5PjLkzQl4oY5DKOSfpfv6y2vhKOZDrRUJ1548XaENKger2VSh9wJoCHY9mttwrzL0BAwox8EhZxk1cIL_9CYbK830L4qx;msToken=gCpHPspChOEhH3ZdqJKWAkZFheaptYmuY9Wjw7feWCkpAMGzaoQRZSWPerUuqOM3lLvGuZz_giR3QPUh3X3Cy2N3wnUaqfMs0S1hHp2h5P67b70fRGIjGTOg; ttwid=1%7CVHzgS11G0NNfXOoqG8tjmMkOlAkEqKTsfi5zEm_Tv6o%7C1791290497%7Ccacf3a02092a62828cc19b9f7896edb7c86621506da2e79524a195163…",
"Referer": "https://www.tiktok.com/explore",
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:145.0) Gecko/20100101 Firefox/145.0"
}
}
]选择一个示例,将其输入和结果加载到 playground 中。
Returns a set of guest session headers for TikTok Web: a Cookie string, a Referer URL and the User-Agent you sent. It needs one input, a browser user_agent string.
user_agent so both headers match across requests.Referer and User-Agent into your own HTTP client along with the cookie.curl -X POST "https://api.sandbase.ai/v1/api/tiktok/web/web-guest-cookie" \
-H "Authorization: Bearer $SANDBASE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:145.0) Gecko/20100101 Firefox/145.0"}'
The result is returned in outputs[0].data.
| Name | Type | Required | Description |
|---|---|---|---|
user_agent | string | Yes | User browser agent |
Real response for the request above, trimmed: lists keep their first item and long strings are cut.
{
"Cookie": "tt_csrf_…",
"Referer": "https://www.tiktok.com/explore",
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:145.0) Gecko/20100101 Firefox/1…"
}
| Field | Meaning |
|---|---|
Cookie | Full cookie string for a guest session, ready to use as a Cookie header. It holds several name=value pairs separated by semicolons, including tt_csrf_token and ttwid. |
Referer | Referer URL to send with requests, here https://www.tiktok.com/explore. |
User-Agent | The browser user agent string the cookie was issued for. It matches the user_agent you sent. |
User-Agent value in your later requests that you passed in user_agent here.Cookie value is a single string. Use it as is in the Cookie header.ttwid value, call TikTok Web TTWID Identifier.$0.002 per successful call. Failed calls are not charged. It is included in the daily free quota of each organization.
开始构建
具备统一身份验证和使用情况跟踪的平台 API 端点。
curl -X POST "https://api.sandbase.ai/v1/api/tiktok/web/web-guest-cookie" \
-H "Authorization: Bearer $SANDBASE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:145.0) Gecko/20100101 Firefox/145.0"
}'将您的 SandBase API 密钥设置到服务器环境中。请求使用 Bearer 身份验证。
export SANDBASE_API_KEY="YOUR_API_KEY"请将密钥保存在服务器端。不要在浏览器代码中暴露它。
user_agentstring必填User browser agent
这是该 API 保存的示例响应;查看时不会发起实时请求。
[
{
"data": {
"Cookie": "tt_csrf_token=ywaXaQLU--rOjuZB_3jrby1Ny8QQ15htaWrs;ttwid=1%7CEApwHaHDTLZB5Jb-XinqPHzZUz6aisIjXuYSgXl2s9Q%7C1791290496%7C313236d0a37a07997f641229f2273ba668db80b177d347172150c5b6ec5771e5; reg-store-region=;store-idc=;msToken=HNusxz2W9Qlj49radrV_3MbrR7F5PjLkzQl4oY5DKOSfpfv6y2vhKOZDrRUJ1548XaENKger2VSh9wJoCHY9mttwrzL0BAwox8EhZxk1cIL_9CYbK830L4qx;msToken=gCpHPspChOEhH3ZdqJKWAkZFheaptYmuY9Wjw7feWCkpAMGzaoQRZSWPerUuqOM3lLvGuZz_giR3QPUh3X3Cy2N3wnUaqfMs0S1hHp2h5P67b70fRGIjGTOg; ttwid=1%7CVHzgS11G0NNfXOoqG8tjmMkOlAkEqKTsfi5zEm_Tv6o%7C1791290497%7Ccacf3a02092a62828cc19b9f7896edb7c86621506da2e79524a195163…",
"Referer": "https://www.tiktok.com/explore",
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:145.0) Gecko/20100101 Firefox/145.0"
}
}
]探索更多
| API | 价格 | 响应 |
|---|---|---|
TikTok | $0.002 每次调用 | JSON |
TikTok | $0.001 每次调用 | JSON |
TikTok | $0.001 每次调用 | JSON |
TikTok | $0.001 每次调用 | JSON |
TikTok | $0.001 每次调用 | JSON |
TikTok | $0.05 每次调用 | JSON |
指南:TikTok API pricing: official access vs per-call dataBest TikTok API in 2026: Pricing Compared
问题
向 https://api.sandbase.ai/v1/api/tiktok/web/web-guest-cookie 发送 POST 请求,在 Authorization 请求头中使用您的 SandBase API key(Bearer),并将参数作为 JSON 请求体传入。您也可以直接在本页的 Playground 中试用,无需编写代码。
每次调用 $0.002,从您的 SandBase 余额中扣费。您只需为实际调用付费;无需订阅。
必填:user_agent (string)。 Parameters 表和本页的 Playground 列出了每个字段。
在同一个 HTTP 请求中返回的 JSON 响应(同步)。 本页的 README 包含一个示例响应。
不需要。TikTok Web Guest Cookie 通过 SandBase 运行,因此一个 SandBase API key 即可覆盖此端点以及目录中的其他所有 API 和模型。您无需单独申请 TikTok API 访问权限。