用户ID
解析与今日头条个人主页URL关联的用户ID。用于将已知的个人主页链接转换为后续用户资料查询所需的标识符。
参数
| 参数 | 必填 | 类型 | 说明 | 示例 | 可选值 |
|---|---|---|---|---|---|
user_profile_url |
必填 | string | 用于解析用户ID的今日头条用户资料URL。 | https://www.toutiao.com/c/user/token/MS4wLjABAAAAt8SwvrFR9DtRuKnJXUMvrQ7AR6CXH2xE9sCHnJyDMH8/ |
— |
代码示例
curl -G "https://api.mofa-ai.com/v1/toutiao/get_user_id_v1" \
-H "Authorization: Bearer $MOFA_API_KEY" \
--data-urlencode 'user_profile_url=https://www.toutiao.com/c/user/token/MS4wLjABAAAAt8SwvrFR9DtRuKnJXUMvrQ7AR6CXH2xE9sCHnJyDMH8/'
import os
import requests
resp = requests.get(
"https://api.mofa-ai.com/v1/toutiao/get_user_id_v1",
headers={"Authorization": f"Bearer {os.environ['MOFA_API_KEY']}"},
params={
"user_profile_url": "https://www.toutiao.com/c/user/token/MS4wLjABAAAAt8SwvrFR9DtRuKnJXUMvrQ7AR6CXH2xE9sCHnJyDMH8/",
},
timeout=60,
)
body = resp.json()
if body["success"]:
print(body["cost_usd"], body["data"])
else:
print(body["error"], body["message"])
const url = new URL("https://api.mofa-ai.com/v1/toutiao/get_user_id_v1");
url.search = new URLSearchParams({
user_profile_url: "https://www.toutiao.com/c/user/token/MS4wLjABAAAAt8SwvrFR9DtRuKnJXUMvrQ7AR6CXH2xE9sCHnJyDMH8/",
});
const resp = await fetch(url, {
headers: { Authorization: `Bearer ${process.env.MOFA_API_KEY}` },
});
const body = await resp.json();
if (body.success) console.log(body.cost_usd, body.data);
else console.error(body.error, body.message);
在线试用
登录后可以在这里直接调用此接口,按价格从余额扣费,失败不收费。新账户赠送 $0.50 试用额度。
响应示例
采集于 2026-11-07,耗时 1344 ms · 请求参数 {"user_profile_url": "https://www.toutiao.com/c/user/token/MS4wLjABAAAAt8SwvrFR9DtRuKnJXUMvrQ7AR6CXH2xE9sCHnJyDMH8/"}
JSON
{
"success": true,
"code": 0,
"message": "success",
"request_id": "req_5f1c2a9be04d7c3a81f6e2d0",
"endpoint": "toutiao.get_user_id_v1",
"cost_usd": 0.02,
"data": {
"code": 0,
"data": null,
"message": null,
"requestId": "4e758976330048d290f1ca7009b296ed",
"recordTime": "2026-11-08T07:58:42.612239668",
"requestParams": {
"body": null,
"query": {
"userProfileUrl": "https://www.toutiao.com/c/user/token/MS4wLjABAAAAt8SwvrFR9DtRuKnJXUMvrQ7AR6CXH2xE9sCHnJyDMH8/"
}
}
}
}