API 接口参考
本文档用于逐接口核对参数和响应。第一次接入或执行多步任务时,请先阅读
模块与任务指南,再回到这里查看字段类型、参数来源和业务成功判定。
内容由 Proto、Python 公共门面和接口语义元数据生成,禁止手工修改。
调用约定
- 共 9 个 Service、17 个 RPC。
- 每个请求字段的“参数来源”说明它应由用户输入、账号/设备配置、运行时生成还是上一步响应提供。
- 除
AuthService/Login 外,请求 metadata 必须包含 x-ig-token: IGT:2:<token>。
- 可选 metadata
x-threads-proxy-url 用于当前账号请求级代理;认证信息不得写入日志。
OK 只表示 gRPC 调用完成,业务成功必须核对各接口列出的实体、字段和副作用。
- 写接口不可盲目重试;超时后先通过读取接口确认是否已经产生副作用。
接口总览
| 接口 |
模块 |
状态 |
操作 |
幂等 |
副作用 |
Python 方法 |
账号登录
threads.auth.v1.AuthService/Login |
登录与当前账号 |
experimental |
create |
否 |
有 |
AuthClient.login |
读取当前账号
threads.auth.v1.AuthService/GetCurrentUser |
登录与当前账号 |
available |
read |
是 |
无 |
AuthClient.get_current_user |
读取推荐用户
threads.feed.v1.FeedService/ListRecommendedUsers |
推荐用户 |
available |
read |
是 |
无 |
FeedClient.list_recommended_users |
读取关系状态
threads.friendships.v1.FriendshipsService/GetFriendshipStatus |
关系状态 |
available |
read |
是 |
无 |
FriendshipsClient.get_friendship_status |
读取账号洞察
threads.insights.v1.InsightsService/GetAccountInsights |
账号洞察 |
unimplemented |
read |
是 |
无 |
InsightsClient.get_account_insights |
获取提及建议
threads.mentions.v1.MentionsService/GetMentionSuggestions |
提及建议 |
unimplemented |
read |
是 |
无 |
MentionsClient.get_mention_suggestions |
检查冒犯文本
threads.posts.v1.PostsService/CheckOffensiveText |
帖子发布与删除 |
known-upstream-error |
read |
是 |
无 |
PostsClient.check_offensive_text |
创建文本帖
threads.posts.v1.PostsService/CreateTextPost |
帖子发布与删除 |
available |
create |
否 |
有 |
PostsClient.create_text_post |
上传图片
threads.posts.v1.PostsService/UploadImage |
帖子发布与删除 |
available |
create |
否 |
有 |
PostsClient.upload_image |
创建单图帖
threads.posts.v1.PostsService/CreateImagePost |
帖子发布与删除 |
available |
create |
否 |
有 |
PostsClient.create_image_post |
删除帖子
threads.posts.v1.PostsService/DeletePost |
帖子发布与删除 |
available |
delete |
否 |
有 |
PostsClient.delete_post |
读取指定用户资料
threads.profile.v1.ProfileService/GetUserInfo |
资料与主页帖子 |
available |
read |
是 |
无 |
ProfileClient.get_user_info |
分页读取主页帖子
threads.profile.v1.ProfileService/ListProfileThreads |
资料与主页帖子 |
available |
read |
是 |
无 |
ProfileClient.list_profile_threads |
保存当前账号资料
threads.profile.v1.ProfileService/EditProfile |
资料与主页帖子 |
available |
update |
否 |
有 |
ProfileClient.edit_profile |
分页读取账号回复
threads.replies.v1.RepliesService/ListProfileReplies |
回复采集 |
available |
read |
是 |
无 |
RepliesClient.list_profile_replies |
关键词搜索
threads.search.v1.SearchService/KeywordSearch |
搜索与主题校验 |
available |
read |
是 |
无 |
SearchClient.keyword_search |
校验发帖主题
threads.search.v1.SearchService/ValidateTag |
搜索与主题校验 |
available |
read |
是 |
无 |
SearchClient.validate_tag |
接口详情
账号登录
- RPC:
threads.auth.v1.AuthService/Login
- gRPC 方法:
/threads.auth.v1.AuthService/Login
- Python 门面:
AuthClient.login
- 所属模块:登录与当前账号(
auth)
- 何时调用:没有可用 IGT:2,并且需要通过账密建立新会话时。
- 前置条件:持久 LoginDevice;生产环境通过 THREADS_KEYBOX_FILE 加载与设备匹配的 keybox signer。
- Metadata:
x-ig-token 不需要;x-threads-proxy-url 可选
- 类型:
create
- 状态:
experimental
- 幂等:否
- 副作用:有
- 业务成功:success=true、session.token 为 IGT:2,且 verified_user.username 与请求账号一致;stable_for_automation 仍必须为 false,直到硬件证明和长期存活观测另行通过。
- 响应用途:提取 session.token,核对 verified_user.username 和 assurance;stable_for_automation 不能由即时成功推断。
- 后续接口:threads.auth.v1.AuthService/GetCurrentUser
- 所属工作流:login
- 说明:默认要求服务端硬件 attestation signer;Go server 通过 THREADS_KEYBOX_FILE 加载 keybox,生产镜像把仓库根目录版本化 keybox.xml 以 0400 固化为 /run/secrets/threads-keybox.xml。无 signer 时返回 FAILED_PRECONDITION;文件配置后缺失、不可读或 XML 无效则 Server 启动失败。allow_unattested_login=true 会真实提交账密且可能触发 logout_reason:33/封号,只能在明确授权的高风险测试中使用。
请求 threads.auth.v1.LoginRequest
| 字段 |
类型 |
字段号 |
规则 |
参数来源 |
说明 |
username |
string |
1 |
单值 |
用户输入:Threads/Instagram 登录账号。 |
- |
password |
string |
2 |
单值 |
受保护账号配置:禁止写入源码和日志。 |
- |
two_factor_seed |
string |
3 |
可选 |
受保护账号配置:启用 TOTP 时提供。 |
- |
device |
LoginDevice |
4 |
单值 |
持久设备身份:同一账号长期复用,不能每次随机生成。 |
- |
app_version |
string |
5 |
可选 |
运行配置:通常省略并使用服务端支持版本。 |
当前只支持 421;空值也使用 421。 |
allow_unattested_login |
bool |
6 |
单值 |
固定安全开关:默认 false;仅经明确高风险授权后设为 true。 |
高风险开关。false(默认)时,服务端未配置硬件 signer 或签名失败都会阻止发送登录凭据。 true 只表示调用方接受软件登录尝试,不表示返回 session 可长期用于自动化。 |
响应 threads.auth.v1.LoginResponse
| 字段 |
类型 |
字段号 |
规则 |
说明 |
success |
bool |
1 |
单值 |
success 只有在取到 IGT:2 且用同一代理、设备完成 whoami 身份校验后才为 true。 |
session |
LoginSession |
2 |
可选 |
- |
steps |
LoginStep |
3 |
数组 |
- |
device |
LoginDevice |
4 |
单值 |
含登录期间服务端下发并回填的 machine_id。 |
verified_user |
CurrentUser |
5 |
可选 |
- |
assurance |
LoginAssurance |
6 |
单值 |
- |
stable_for_automation |
bool |
7 |
单值 |
当前实现永不把即时登录成功等价为长期稳定;必须由真实硬件证明和存活观测另行确认。 |
stability_warning |
string |
8 |
单值 |
- |
Python 调用签名
async def login(*, username: str, password: str, device, two_factor_seed: str | None=None, app_version: str | None=None, allow_unattested_login: bool=False)
读取当前账号
- RPC:
threads.auth.v1.AuthService/GetCurrentUser
- gRPC 方法:
/threads.auth.v1.AuthService/GetCurrentUser
- Python 门面:
AuthClient.get_current_user
- 所属模块:登录与当前账号(
auth)
- 何时调用:校验 token 身份、取得当前 uid,或在资料编辑前读取完整原值时。
- 前置条件:ThreadsClient 已注入有效 IGT:2 token。
- Metadata:
x-ig-token 必填;x-threads-proxy-url 可选
- 类型:
read
- 状态:
available
- 幂等:是
- 副作用:无
- 业务成功:响应 pk 与注入 token 所属账号一致。
- 响应用途:pk 是发帖 uid 和当前账号 user_id;edit=true 时使用完整资料字段回填 EditProfile。
- 后续接口:threads.profile.v1.ProfileService/EditProfile;threads.posts.v1.PostsService/CreateTextPost;threads.posts.v1.PostsService/CreateImagePost
- 所属工作流:verify_session;login;edit_profile;create_text_post;create_image_post
- 说明:读取当前账号;edit=true 时返回更完整的资料字段。
请求 threads.auth.v1.GetCurrentUserRequest
| 字段 |
类型 |
字段号 |
规则 |
参数来源 |
说明 |
edit |
bool |
1 |
可选 |
调用场景:普通身份校验传 false;资料编辑前传 true。 |
edit=true:编辑资料页的读取场景(字段更全)。 |
响应 threads.auth.v1.CurrentUser
| 字段 |
类型 |
字段号 |
规则 |
说明 |
pk |
string |
1 |
单值 |
- |
username |
string |
2 |
单值 |
- |
full_name |
string |
3 |
可选 |
- |
biography |
string |
4 |
可选 |
- |
profile_pic_url |
string |
5 |
可选 |
- |
email |
string |
6 |
可选 |
- |
text_app_biography |
string |
7 |
可选 |
- |
external_url |
string |
8 |
可选 |
- |
bio_links |
BioLink |
9 |
数组 |
- |
text_app_cover_photo_url |
string |
10 |
可选 |
- |
is_private |
bool |
11 |
可选 |
- |
is_verified |
bool |
12 |
可选 |
- |
Python 调用签名
async def get_current_user(edit=None)
读取推荐用户
- RPC:
threads.feed.v1.FeedService/ListRecommendedUsers
- gRPC 方法:
/threads.feed.v1.FeedService/ListRecommendedUsers
- Python 门面:
FeedClient.list_recommended_users
- 所属模块:推荐用户(
feed)
- 何时调用:需要获取 Threads 推荐账号或继续推荐流分页时。
- 前置条件:已有有效 IGT:2 token。
- Metadata:
x-ig-token 必填;x-threads-proxy-url 可选
- 类型:
read
- 状态:
available
- 幂等:是
- 副作用:无
- 业务成功:RawList.raw_json 可解析,且分页游标来自同一次真实响应。
- 响应用途:解析 raw_json 获取推荐对象;next_cursor 用于下一页 paging_token。
- 后续接口:threads.feed.v1.FeedService/ListRecommendedUsers
- 所属工作流:无
- 说明:响应结构尚未强类型化,以 RawList 透传。
请求 threads.feed.v1.ListRecommendedUsersRequest
| 字段 |
类型 |
字段号 |
规则 |
参数来源 |
说明 |
paging_token |
string |
1 |
可选 |
上一页响应:使用 RawList.next_cursor;首次调用省略。 |
分页游标(对应 paging_token)。 |
recommendation_type |
string |
2 |
可选 |
产品场景配置:按上游支持的推荐类型填写,未知时省略。 |
推荐类型(recommended_users / great_accounts / ...,见报告 §5.1)。 |
响应 threads.common.v1.RawList
| 字段 |
类型 |
字段号 |
规则 |
说明 |
raw_json |
string |
1 |
单值 |
- |
next_cursor |
string |
2 |
可选 |
- |
Python 调用签名
async def list_recommended_users(paging_token=None, recommendation_type=None)
读取关系状态
- RPC:
threads.friendships.v1.FriendshipsService/GetFriendshipStatus
- gRPC 方法:
/threads.friendships.v1.FriendshipsService/GetFriendshipStatus
- Python 门面:
FriendshipsClient.get_friendship_status
- 所属模块:关系状态(
friendships)
- 何时调用:需要确认当前账号是否关注、被关注、拉黑或静音目标账号时。
- 前置条件:已有有效 IGT:2 token。
- Metadata:
x-ig-token 必填;x-threads-proxy-url 可选
- 类型:
read
- 状态:
available
- 幂等:是
- 副作用:无
- 业务成功:返回关系状态属于请求 user_id 对应的目标账号。
- 响应用途:直接读取 following、followed_by、blocking、muting 等强类型字段。
- 后续接口:无
- 所属工作流:无
- 说明:读取关注、拉黑、静音等关系状态。
请求 threads.friendships.v1.GetFriendshipStatusRequest
| 字段 |
类型 |
字段号 |
规则 |
参数来源 |
说明 |
user_id |
string |
1 |
单值 |
目标对象:来自 GetUserInfo.pk、搜索结果或业务数据库。 |
目标用户数字 id。 |
is_external_deeplink_profile_view |
bool |
2 |
可选 |
调用场景:普通 API 调用使用 false。 |
对应请求参数 is_external_deeplink_profile_view(默认 false)。 |
响应 threads.friendships.v1.FriendshipStatus
| 字段 |
类型 |
字段号 |
规则 |
说明 |
following |
bool |
1 |
可选 |
- |
followed_by |
bool |
2 |
可选 |
- |
outgoing_request |
bool |
3 |
可选 |
- |
incoming_request |
bool |
4 |
可选 |
- |
blocking |
bool |
5 |
可选 |
- |
is_blocking_reel |
bool |
6 |
可选 |
- |
muting |
bool |
7 |
可选 |
- |
is_muting_reel |
bool |
8 |
可选 |
- |
is_muting_notes |
bool |
9 |
可选 |
- |
is_muting_media_notes |
bool |
10 |
可选 |
- |
is_muting_media_reposts |
bool |
11 |
可选 |
- |
is_private |
bool |
12 |
可选 |
- |
subscribed |
bool |
13 |
可选 |
- |
is_eligible_to_subscribe |
bool |
14 |
可选 |
- |
is_viewer_unconnected |
bool |
15 |
可选 |
- |
should_show_profile_upsell |
bool |
16 |
可选 |
- |
is_banner_profile_upsell |
bool |
17 |
可选 |
- |
reachability_status |
int64 |
18 |
可选 |
int 枚举(apis/friendships/关注关系.md) |
Python 调用签名
async def get_friendship_status(user_id: str, is_external_deeplink_profile_view: bool=False) -> 'friendships_pb2.FriendshipStatus'
读取账号洞察
- RPC:
threads.insights.v1.InsightsService/GetAccountInsights
- gRPC 方法:
/threads.insights.v1.InsightsService/GetAccountInsights
- Python 门面:
InsightsClient.get_account_insights
- 所属模块:账号洞察(
insights)
- 何时调用:需要账号洞察数据时;当前接口尚不可用。
- 前置条件:当前缺少真实 GraphQL doc_id。
- Metadata:
x-ig-token 必填;x-threads-proxy-url 可选
- 类型:
read
- 状态:
unimplemented
- 幂等:是
- 副作用:无
- 业务成功:当前固定返回 gRPC UNIMPLEMENTED。
- 响应用途:当前固定得到 UNIMPLEMENTED,不能解析为真实洞察。
- 后续接口:无
- 所属工作流:无
- 说明:缺少真实 GraphQL doc_id,禁止宣称可用。
请求 threads.insights.v1.GetAccountInsightsRequest
| 字段 |
类型 |
字段号 |
规则 |
参数来源 |
说明 |
user_id |
string |
1 |
可选 |
目标对象:省略表示当前账号,或传目标账号 ID。 |
- |
响应 threads.common.v1.RawList
| 字段 |
类型 |
字段号 |
规则 |
说明 |
raw_json |
string |
1 |
单值 |
- |
next_cursor |
string |
2 |
可选 |
- |
Python 调用签名
async def get_account_insights(user_id=None)
获取提及建议
- RPC:
threads.mentions.v1.MentionsService/GetMentionSuggestions
- gRPC 方法:
/threads.mentions.v1.MentionsService/GetMentionSuggestions
- Python 门面:
MentionsClient.get_mention_suggestions
- 所属模块:提及建议(
mentions)
- 何时调用:输入 @ 用户名时需要候选建议;当前接口尚不可用。
- 前置条件:当前缺少真实 GraphQL doc_id。
- Metadata:
x-ig-token 必填;x-threads-proxy-url 可选
- 类型:
read
- 状态:
unimplemented
- 幂等:是
- 副作用:无
- 业务成功:当前固定返回 gRPC UNIMPLEMENTED。
- 响应用途:当前固定得到 UNIMPLEMENTED,不能作为发帖候选。
- 后续接口:无
- 所属工作流:无
- 说明:缺少真实 GraphQL doc_id,禁止宣称可用。
请求 threads.mentions.v1.GetMentionSuggestionsRequest
| 字段 |
类型 |
字段号 |
规则 |
参数来源 |
说明 |
query |
string |
1 |
单值 |
用户输入:@ 后正在输入的用户名片段。 |
- |
响应 threads.common.v1.RawList
| 字段 |
类型 |
字段号 |
规则 |
说明 |
raw_json |
string |
1 |
单值 |
- |
next_cursor |
string |
2 |
可选 |
- |
Python 调用签名
async def get_mention_suggestions(query)
检查冒犯文本
- RPC:
threads.posts.v1.PostsService/CheckOffensiveText
- gRPC 方法:
/threads.posts.v1.PostsService/CheckOffensiveText
- Python 门面:
PostsClient.check_offensive_text
- 所属模块:帖子发布与删除(
posts)
- 何时调用:发帖前希望执行上游文本风险检查时;当前真实上游返回 404。
- 前置条件:已有有效 IGT:2 token。
- Metadata:
x-ig-token 必填;x-threads-proxy-url 可选
- 类型:
read
- 状态:
known-upstream-error
- 幂等:是
- 副作用:无
- 业务成功:当前真实上游返回 HTTP 404,测试以真实错误映射为验收结果。
- 响应用途:当前以 gRPC 错误路径处理,不能把未返回结果视为安全。
- 后续接口:无
- 所属工作流:无
- 说明:请求结构与真实 App 抓包一致,但当前线上端点不可用。
请求 threads.posts.v1.CheckOffensiveTextRequest
| 字段 |
类型 |
字段号 |
规则 |
参数来源 |
说明 |
text_list |
string |
1 |
数组 |
用户内容:待检查的一段或多段文本。 |
待检测文本(对应 form text_list,JSON 数组)。 |
media_id |
string |
2 |
可选 |
已有媒体上下文:编辑或关联媒体时提供,否则省略。 |
可选关联 media_id。 |
响应 threads.posts.v1.OffensiveCheck
| 字段 |
类型 |
字段号 |
规则 |
说明 |
is_offensive |
bool |
1 |
单值 |
- |
minimum_next_timestamp |
int64 |
2 |
可选 |
- |
text_language |
string |
3 |
可选 |
- |
Python 调用签名
async def check_offensive_text(text_list, media_id: str | None=None)
创建文本帖
- RPC:
threads.posts.v1.PostsService/CreateTextPost
- gRPC 方法:
/threads.posts.v1.PostsService/CreateTextPost
- Python 门面:
PostsClient.create_text_post
- 所属模块:帖子发布与删除(
posts)
- 何时调用:发布不带图片或视频的 Threads 文本帖子时。
- 前置条件:有效 token、当前账号 uid、持久 device_id/uuid、写操作授权。
- Metadata:
x-ig-token 必填;x-threads-proxy-url 可选
- 类型:
create
- 状态:
available
- 幂等:否
- 副作用:有
- 业务成功:返回帖子属于请求 uid,caption 与请求一致,并能从账号主页重新读取。
- 响应用途:保存 id/code/permalink,并核对 caption、user 和主页重新读取结果。
- 后续接口:threads.profile.v1.ProfileService/ListProfileThreads
- 所属工作流:create_text_post
- 说明:真实发帖操作;必须显式授权,调用方不得自动重试。
请求 threads.posts.v1.CreateTextPostRequest
| 字段 |
类型 |
字段号 |
规则 |
参数来源 |
说明 |
caption |
string |
1 |
单值 |
用户输入:帖子正文。 |
正文(对应 caption)。 |
uid |
string |
2 |
单值 |
前置响应:GetCurrentUser.pk。 |
发布主体与设备三件套(对应 _uid / device_id / _uuid),须由调用方提供。 |
device_id |
string |
3 |
单值 |
持久设备身份:账号绑定的 Android device_id。 |
- |
uuid |
string |
4 |
单值 |
持久设备身份:账号绑定的 uuid。 |
- |
upload_id |
string |
5 |
可选 |
运行时生成:可省略,由 Go SDK 生成;重试时不得随意复用。 |
幂等批次 id(缺省由 SDK 生成 upload_id、publish_id 固定 "1")。 |
reply_control |
int32 |
6 |
可选 |
产品设置:回复权限枚举,默认 0。 |
回复权限:0=everyone(对应 text_post_app_info.reply_control)。 |
device |
Device |
7 |
单值 |
持久设备身份:与 device_id/uuid 属于同一设备。 |
device 对象(必填,apis/post-media/发帖.md)。 |
camera_session_id |
string |
8 |
可选 |
运行时生成:模拟发布会话时提供,否则省略。 |
埋点/会话(必填,缺省由 SDK 生成/留空)。 |
nav_chain |
string |
9 |
可选 |
运行时上下文:导航链,普通调用可省略。 |
- |
timezone_offset |
string |
10 |
可选 |
运行环境:账号所在地时区偏移。 |
- |
tag_header |
string |
11 |
可选 |
主题功能:先用 ValidateTag 校验后按上游格式提供。 |
可选功能:主题 / 位置 / 投票(勾选才传)。 主题 display_text |
location |
Location |
12 |
可选 |
用户选择:posts_pb2.Location,未选择位置时省略。 |
- |
poll |
Poll |
13 |
可选 |
用户输入:posts_pb2.Poll,未创建投票时省略。 |
- |
响应 threads.posts.v1.Media
| 字段 |
类型 |
字段号 |
规则 |
说明 |
id |
string |
1 |
单值 |
- |
pk |
int64 |
2 |
单值 |
- |
fbid |
int64 |
3 |
单值 |
- |
taken_at |
int64 |
4 |
单值 |
- |
media_type |
int32 |
5 |
单值 |
19 = text_post |
code |
string |
6 |
单值 |
短代码 |
product_type |
string |
7 |
单值 |
text_post |
permalink |
string |
8 |
单值 |
- |
integrity_review_decision |
string |
9 |
单值 |
pending 表示异步审核中 |
caption |
Caption |
10 |
单值 |
- |
text_post_app_info |
TextPostAppInfo |
11 |
单值 |
- |
has_liked |
bool |
12 |
单值 |
- |
like_count |
int64 |
13 |
单值 |
- |
meta_place |
MetaPlace |
14 |
可选 |
位置回显(带位置发帖时) |
image_versions2 |
ImageVersions2 |
15 |
可选 |
- |
original_width |
int32 |
16 |
单值 |
- |
original_height |
int32 |
17 |
单值 |
- |
user |
MediaUser |
18 |
可选 |
列表端点的顶层作者 |
Python 调用签名
async def create_text_post(caption, uid, device_id, uuid, upload_id=None, reply_control=0, device=None, camera_session_id=None, nav_chain=None, timezone_offset=None, tag_header=None, location=None, poll=None)
上传图片
- RPC:
threads.posts.v1.PostsService/UploadImage
- gRPC 方法:
/threads.posts.v1.PostsService/UploadImage
- Python 门面:
PostsClient.upload_image
- 所属模块:帖子发布与删除(
posts)
- 何时调用:创建单图帖前上传 WebP 图片二进制时。
- 前置条件:有效 token、WebP 图片字节、真实宽高、写操作授权。
- Metadata:
x-ig-token 必填;x-threads-proxy-url 可选
- 类型:
create
- 状态:
available
- 幂等:否
- 副作用:有
- 业务成功:响应 status=ok 且 upload_id 非空;该 upload_id 可被 CreateImagePost 接受。
- 响应用途:status 必须为 ok;将 upload_id 原样传给 CreateImagePost。
- 后续接口:threads.posts.v1.PostsService/CreateImagePost
- 所属工作流:create_image_post
- 说明:真实图片二进制上传;当前抓包确认 image/webp,视频上传仍缺少抓包来源。
请求 threads.posts.v1.UploadImageRequest
| 字段 |
类型 |
字段号 |
规则 |
参数来源 |
说明 |
image_data |
bytes |
1 |
单值 |
本地文件或内存:WebP 原始 bytes。 |
原始图片字节;当前已确认样本为 image/webp。 |
original_width |
int32 |
2 |
单值 |
图片元数据:解码后的真实像素宽度。 |
- |
original_height |
int32 |
3 |
单值 |
图片元数据:解码后的真实像素高度。 |
- |
upload_id |
string |
4 |
可选 |
运行时生成:通常省略并由 Go SDK 生成。 |
缺省由 SDK 生成;后续 CreateImagePost 必须使用响应中的 upload_id。 |
mime_type |
string |
5 |
可选 |
固定协议值:当前确认 image/webp。 |
缺省 image/webp;当前仅确认 image/webp。 |
is_optimistic_upload |
bool |
6 |
可选 |
上传策略:通常省略使用 SDK 默认值。 |
App 抓包存在乐观预上传与正式上传两种模式;缺省为正式上传。 |
msssim |
double |
7 |
可选 |
图片质量计算:调用方实际计算时提供,否则省略。 |
图片压缩质量指标;调用方掌握真实编码结果时再传。 |
ssim |
double |
8 |
可选 |
图片质量计算:调用方实际计算时提供,否则省略。 |
- |
waterfall_id |
string |
9 |
可选 |
运行时生成:上传链路追踪 ID,通常省略。 |
缺省由 SDK 生成。 |
响应 threads.posts.v1.UploadImageResult
| 字段 |
类型 |
字段号 |
规则 |
说明 |
upload_id |
string |
1 |
单值 |
- |
status |
string |
2 |
单值 |
- |
Python 调用签名
async def upload_image(image_data: bytes, original_width: int, original_height: int, upload_id: str | None=None, mime_type: str | None=None, is_optimistic_upload: bool | None=None, msssim: float | None=None, ssim: float | None=None, waterfall_id: str | None=None) -> 'posts_pb2.UploadImageResult'
创建单图帖
- RPC:
threads.posts.v1.PostsService/CreateImagePost
- gRPC 方法:
/threads.posts.v1.PostsService/CreateImagePost
- Python 门面:
PostsClient.create_image_post
- 所属模块:帖子发布与删除(
posts)
- 何时调用:UploadImage 成功后,把已上传图片发布为单图帖子时。
- 前置条件:UploadImageResult.status=ok、当前账号 uid、持久设备身份、写操作授权。
- Metadata:
x-ig-token 必填;x-threads-proxy-url 可选
- 类型:
create
- 状态:
available
- 幂等:否
- 副作用:有
- 业务成功:返回 media_type=1,正文与请求一致,image_versions2 非空,并能从账号主页重新读取。
- 响应用途:核对 media_type=1、image_versions2、caption 和 user,并保存 id/code/permalink。
- 后续接口:threads.profile.v1.ProfileService/ListProfileThreads
- 所属工作流:create_image_post
- 说明:单图帖 configure;调用前必须先用 UploadImage 获取 upload_id,调用方不得自动重试。
请求 threads.posts.v1.CreateImagePostRequest
| 字段 |
类型 |
字段号 |
规则 |
参数来源 |
说明 |
caption |
string |
1 |
单值 |
用户输入:帖子正文。 |
图片帖允许空正文。 |
uid |
string |
2 |
单值 |
前置响应:GetCurrentUser.pk。 |
- |
device_id |
string |
3 |
单值 |
持久设备身份:账号绑定的 Android device_id。 |
- |
uuid |
string |
4 |
单值 |
持久设备身份:账号绑定的 uuid。 |
- |
upload_id |
string |
5 |
单值 |
前置响应:UploadImageResult.upload_id。 |
必须使用 UploadImage 返回的 upload_id。 |
reply_control |
int32 |
6 |
可选 |
产品设置:回复权限枚举,默认 0。 |
- |
device |
Device |
7 |
单值 |
持久设备身份:与 device_id/uuid 属于同一设备。 |
- |
camera_session_id |
string |
8 |
可选 |
运行时生成:模拟发布会话时提供,否则省略。 |
- |
nav_chain |
string |
9 |
可选 |
运行时上下文:导航链,普通调用可省略。 |
- |
timezone_offset |
string |
10 |
可选 |
运行环境:账号所在地时区偏移。 |
- |
tag_header |
string |
11 |
可选 |
主题功能:先用 ValidateTag 校验后按上游格式提供。 |
- |
location |
Location |
12 |
可选 |
用户选择:posts_pb2.Location,未选择位置时省略。 |
- |
poll |
Poll |
13 |
可选 |
用户输入:posts_pb2.Poll,未创建投票时省略。 |
- |
original_width |
int32 |
14 |
单值 |
前置请求:与 UploadImage.original_width 保持一致。 |
- |
original_height |
int32 |
15 |
单值 |
前置请求:与 UploadImage.original_height 保持一致。 |
- |
custom_accessibility_caption |
string |
16 |
可选 |
用户输入:图片无障碍说明,可省略。 |
- |
响应 threads.posts.v1.Media
| 字段 |
类型 |
字段号 |
规则 |
说明 |
id |
string |
1 |
单值 |
- |
pk |
int64 |
2 |
单值 |
- |
fbid |
int64 |
3 |
单值 |
- |
taken_at |
int64 |
4 |
单值 |
- |
media_type |
int32 |
5 |
单值 |
19 = text_post |
code |
string |
6 |
单值 |
短代码 |
product_type |
string |
7 |
单值 |
text_post |
permalink |
string |
8 |
单值 |
- |
integrity_review_decision |
string |
9 |
单值 |
pending 表示异步审核中 |
caption |
Caption |
10 |
单值 |
- |
text_post_app_info |
TextPostAppInfo |
11 |
单值 |
- |
has_liked |
bool |
12 |
单值 |
- |
like_count |
int64 |
13 |
单值 |
- |
meta_place |
MetaPlace |
14 |
可选 |
位置回显(带位置发帖时) |
image_versions2 |
ImageVersions2 |
15 |
可选 |
- |
original_width |
int32 |
16 |
单值 |
- |
original_height |
int32 |
17 |
单值 |
- |
user |
MediaUser |
18 |
可选 |
列表端点的顶层作者 |
Python 调用签名
async def create_image_post(caption: str, uid: str, device_id: str, uuid: str, upload_id: str, original_width: int, original_height: int, reply_control: int=0, device: 'posts_pb2.Device | None'=None, camera_session_id: str | None=None, nav_chain: str | None=None, timezone_offset: str | None=None, tag_header: str | None=None, location: 'posts_pb2.Location | None'=None, poll: 'posts_pb2.Poll | None'=None, custom_accessibility_caption: str | None=None) -> 'posts_pb2.Media'
删除帖子
- RPC:
threads.posts.v1.PostsService/DeletePost
- gRPC 方法:
/threads.posts.v1.PostsService/DeletePost
- Python 门面:
PostsClient.delete_post
- 所属模块:帖子发布与删除(
posts)
- 何时调用:删除当前账号已有帖子或清理测试帖子时。
- 前置条件:有效 token、目标 media_id、当前账号 uid/uuid、写操作授权。
- Metadata:
x-ig-token 必填;x-threads-proxy-url 可选
- 类型:
delete
- 状态:
available
- 幂等:否
- 副作用:有
- 业务成功:did_delete=true,且重新读取主页确认目标帖子已经消失。
- 响应用途:did_delete 必须为 true,并通过 ListProfileThreads 确认目标帖子消失。
- 后续接口:threads.profile.v1.ProfileService/ListProfileThreads
- 所属工作流:无
- 说明:真实删除操作;必须显式授权,调用方不得自动重试。
请求 threads.posts.v1.DeletePostRequest
| 字段 |
类型 |
字段号 |
规则 |
参数来源 |
说明 |
media_id |
string |
1 |
单值 |
前置响应:创建接口返回的 Media.id,或主页帖子中的 post.id。 |
= URL 中的 media_id(pk_uid) |
uid |
string |
2 |
单值 |
前置响应:GetCurrentUser.pk。 |
_uid |
uuid |
string |
3 |
单值 |
持久设备身份:当前账号绑定的 uuid。 |
_uuid |
响应 threads.posts.v1.DeletePostResult
| 字段 |
类型 |
字段号 |
规则 |
说明 |
did_delete |
bool |
1 |
单值 |
- |
cxp_deep_deletion_waterfall_id |
string |
2 |
可选 |
- |
Python 调用签名
async def delete_post(media_id, uid, uuid)
读取指定用户资料
- RPC:
threads.profile.v1.ProfileService/GetUserInfo
- gRPC 方法:
/threads.profile.v1.ProfileService/GetUserInfo
- Python 门面:
ProfileClient.get_user_info
- 所属模块:资料与主页帖子(
profile)
- 何时调用:已知用户 ID,需要读取公开资料和账号统计时。
- 前置条件:已有有效 IGT:2 token。
- Metadata:
x-ig-token 必填;x-threads-proxy-url 可选
- 类型:
read
- 状态:
available
- 幂等:是
- 副作用:无
- 业务成功:响应 pk 与请求 user_id 一致。
- 响应用途:核对 pk 等于请求 user_id,再使用 username、计数和隐私状态。
- 后续接口:threads.profile.v1.ProfileService/ListProfileThreads;threads.friendships.v1.FriendshipsService/GetFriendshipStatus
- 所属工作流:无
- 说明:读取指定用户资料。
请求 threads.profile.v1.GetUserInfoRequest
| 字段 |
类型 |
字段号 |
规则 |
参数来源 |
说明 |
user_id |
string |
1 |
单值 |
目标对象:来自搜索结果、帖子作者 pk 或业务数据库。 |
Threads/IG 用户数字 id(pk)。 |
响应 threads.profile.v1.User
| 字段 |
类型 |
字段号 |
规则 |
说明 |
pk |
string |
1 |
单值 |
用户数字 id |
username |
string |
2 |
单值 |
- |
full_name |
string |
3 |
可选 |
- |
biography |
string |
4 |
可选 |
- |
profile_pic_url |
string |
5 |
可选 |
- |
follower_count |
int64 |
6 |
可选 |
- |
following_count |
int64 |
7 |
可选 |
- |
media_count |
int64 |
8 |
可选 |
- |
is_private |
bool |
9 |
可选 |
- |
is_verified |
bool |
10 |
可选 |
- |
Python 调用签名
async def get_user_info(user_id: str) -> 'profile_pb2.User'
分页读取主页帖子
- RPC:
threads.profile.v1.ProfileService/ListProfileThreads
- gRPC 方法:
/threads.profile.v1.ProfileService/ListProfileThreads
- Python 门面:
ProfileClient.list_profile_threads
- 所属模块:资料与主页帖子(
profile)
- 何时调用:采集指定账号主页帖子、验证发帖或验证删除结果时。
- 前置条件:已有有效 token 和目标 user_id。
- Metadata:
x-ig-token 必填;x-threads-proxy-url 可选
- 类型:
read
- 状态:
available
- 幂等:是
- 副作用:无
- 业务成功:status=ok,threads[].items[].post 可直接读取,帖子作者与请求 user_id 的业务语义一致。
- 响应用途:优先消费 threads[].items[].post;next_cursor 传给下一页 max_id;raw_json 仅用于兼容排错。
- 后续接口:threads.profile.v1.ProfileService/ListProfileThreads
- 所属工作流:create_text_post;create_image_post;collect_profile_threads
- 说明:主页帖子已强类型化;raw_json 仅为旧客户端线级兼容和未建模字段排错保留。
请求 threads.profile.v1.ListProfileThreadsRequest
| 字段 |
类型 |
字段号 |
规则 |
参数来源 |
说明 |
user_id |
string |
1 |
单值 |
目标对象:当前账号用 GetCurrentUser.pk,其他账号来自搜索或资料接口。 |
- |
max_id |
string |
2 |
可选 |
上一页响应:使用 ProfileThreadsPage.next_cursor;首次调用省略。 |
分页 |
exclude_reposts |
bool |
3 |
可选 |
采集策略:是否排除转发,可省略使用上游默认。 |
- |
响应 threads.profile.v1.ProfileThreadsPage
| 字段 |
类型 |
字段号 |
规则 |
说明 |
raw_json |
string |
1 |
单值 |
- |
next_cursor |
string |
2 |
可选 |
- |
threads |
ProfileThread |
3 |
数组 |
- |
status |
string |
4 |
单值 |
- |
Python 调用签名
async def list_profile_threads(user_id: str, max_id: str | None=None, exclude_reposts: bool | None=None) -> 'profile_pb2.ProfileThreadsPage'
保存当前账号资料
- RPC:
threads.profile.v1.ProfileService/EditProfile
- gRPC 方法:
/threads.profile.v1.ProfileService/EditProfile
- Python 门面:
ProfileClient.edit_profile
- 所属模块:资料与主页帖子(
profile)
- 何时调用:修改用户名、显示名、简介、隐私状态或外部链接时。
- 前置条件:先调用 GetCurrentUser(edit=true) 读取完整原值。
- Metadata:
x-ig-token 必填;x-threads-proxy-url 可选
- 类型:
update
- 状态:
available
- 幂等:否
- 副作用:有
- 业务成功:保存后重新读取当前账号,资料字段与请求值一致。
- 响应用途:核对返回资料,并再次 GetCurrentUser(edit=true) 验证真实保存结果。
- 后续接口:threads.auth.v1.AuthService/GetCurrentUser
- 所属工作流:edit_profile
- 说明:整表回传接口;支持 username/first_name/biography/is_private/external_url/url_title/uuid。调用前应读取当前值;头像和封面属于尚未抓包的独立上传端点,location 不是该端点字段。
请求 threads.profile.v1.EditProfileRequest
| 字段 |
类型 |
字段号 |
规则 |
参数来源 |
说明 |
username |
string |
1 |
单值 |
前置响应或用户修改:未修改时回填 CurrentUser.username。 |
必填 |
first_name |
string |
2 |
单值 |
前置响应或用户修改:未修改时回填 CurrentUser.full_name。 |
必填,显示名(= full_name) |
biography |
string |
3 |
单值 |
前置响应或用户修改:未修改时回填 CurrentUser.biography。 |
必填,个性签名(无签名传空串) |
is_private |
bool |
4 |
单值 |
前置响应或用户修改:未修改时回填 CurrentUser.is_private。 |
必填 |
uuid |
string |
5 |
单值 |
持久设备身份:当前账号绑定的 uuid。 |
必填,客户端 UUID(_uuid) |
external_url |
string |
6 |
可选 |
前置响应或用户修改:未修改时回填 CurrentUser.external_url。 |
可选,链接 URL;服务端写入 bio_links[] |
url_title |
string |
7 |
可选 |
前置响应或用户修改:从 CurrentUser.bio_links 对应链接标题回填。 |
可选,链接标题,配合 external_url |
响应 threads.auth.v1.CurrentUser
| 字段 |
类型 |
字段号 |
规则 |
说明 |
pk |
string |
1 |
单值 |
- |
username |
string |
2 |
单值 |
- |
full_name |
string |
3 |
可选 |
- |
biography |
string |
4 |
可选 |
- |
profile_pic_url |
string |
5 |
可选 |
- |
email |
string |
6 |
可选 |
- |
text_app_biography |
string |
7 |
可选 |
- |
external_url |
string |
8 |
可选 |
- |
bio_links |
BioLink |
9 |
数组 |
- |
text_app_cover_photo_url |
string |
10 |
可选 |
- |
is_private |
bool |
11 |
可选 |
- |
is_verified |
bool |
12 |
可选 |
- |
Python 调用签名
async def edit_profile(username, first_name, biography, is_private, uuid, external_url=None, url_title=None)
分页读取账号回复
- RPC:
threads.replies.v1.RepliesService/ListProfileReplies
- gRPC 方法:
/threads.replies.v1.RepliesService/ListProfileReplies
- Python 门面:
RepliesClient.list_profile_replies
- 所属模块:回复采集(
replies)
- 何时调用:采集指定账号发布的回复时。
- 前置条件:已有有效 token 和目标 user_id。
- Metadata:
x-ig-token 必填;x-threads-proxy-url 可选
- 类型:
read
- 状态:
available
- 幂等:是
- 副作用:无
- 业务成功:RawList.raw_json 可解析,响应属于请求 user_id 的回复列表。
- 响应用途:解析 raw_json 获取回复对象;next_cursor 用于下一页 max_id。
- 后续接口:threads.replies.v1.RepliesService/ListProfileReplies
- 所属工作流:无
- 说明:响应结构尚未强类型化,以 RawList 透传。
请求 threads.replies.v1.ListProfileRepliesRequest
| 字段 |
类型 |
字段号 |
规则 |
参数来源 |
说明 |
user_id |
string |
1 |
单值 |
目标对象:来自当前账号 pk、搜索结果或资料接口。 |
- |
max_id |
string |
2 |
可选 |
上一页响应:使用 RawList.next_cursor;首次调用省略。 |
分页 |
响应 threads.common.v1.RawList
| 字段 |
类型 |
字段号 |
规则 |
说明 |
raw_json |
string |
1 |
单值 |
- |
next_cursor |
string |
2 |
可选 |
- |
Python 调用签名
async def list_profile_replies(user_id, max_id=None)
关键词搜索
- RPC:
threads.search.v1.SearchService/KeywordSearch
- gRPC 方法:
/threads.search.v1.SearchService/KeywordSearch
- Python 门面:
SearchClient.keyword_search
- 所属模块:搜索与主题校验(
search)
- 何时调用:按关键词查找 Threads 账号或内容时。
- 前置条件:已有有效 IGT:2 token。
- Metadata:
x-ig-token 必填;x-threads-proxy-url 可选
- 类型:
read
- 状态:
available
- 幂等:是
- 副作用:无
- 业务成功:RawList.raw_json 可解析,结果与请求 query 相关。
- 响应用途:解析 raw_json,保留未知字段;分页参数必须来自同一轮搜索响应和会话。
- 后续接口:threads.search.v1.SearchService/KeywordSearch
- 所属工作流:无
- 说明:响应结构尚未强类型化,以 RawList 透传。
请求 threads.search.v1.KeywordSearchRequest
| 字段 |
类型 |
字段号 |
规则 |
参数来源 |
说明 |
query |
string |
1 |
单值 |
用户输入:搜索关键词。 |
- |
page_token |
string |
2 |
可选 |
上一页响应或 raw_json:按上游分页字段传递;首次调用省略。 |
- |
rank_token |
string |
3 |
可选 |
首次响应或搜索会话上下文:后续页保持同一值。 |
- |
search_session_id |
string |
4 |
可选 |
运行时生成:同一轮搜索分页复用同一个会话 ID。 |
- |
响应 threads.common.v1.RawList
| 字段 |
类型 |
字段号 |
规则 |
说明 |
raw_json |
string |
1 |
单值 |
- |
next_cursor |
string |
2 |
可选 |
- |
Python 调用签名
async def keyword_search(query, page_token=None, rank_token=None, search_session_id=None)
校验发帖主题
- RPC:
threads.search.v1.SearchService/ValidateTag
- gRPC 方法:
/threads.search.v1.SearchService/ValidateTag
- Python 门面:
SearchClient.validate_tag
- 所属模块:搜索与主题校验(
search)
- 何时调用:发帖前需要确认主题标签是否有效或敏感时。
- 前置条件:已有有效 IGT:2 token。
- Metadata:
x-ig-token 必填;x-threads-proxy-url 可选
- 类型:
read
- 状态:
available
- 幂等:是
- 副作用:无
- 业务成功:返回 is_valid/is_sensitive 对应请求 tag_name。
- 响应用途:is_valid=true 且业务允许时,才构造发帖 tag_header;is_sensitive 需触发产品确认。
- 后续接口:threads.posts.v1.PostsService/CreateTextPost;threads.posts.v1.PostsService/CreateImagePost
- 所属工作流:无
- 说明:发帖主题的前置校验。
请求 threads.search.v1.ValidateTagRequest
| 字段 |
类型 |
字段号 |
规则 |
参数来源 |
说明 |
tag_name |
string |
1 |
单值 |
用户输入:不含 # 的主题名称。 |
- |
响应 threads.search.v1.TagValidation
| 字段 |
类型 |
字段号 |
规则 |
说明 |
is_valid |
bool |
1 |
单值 |
- |
is_sensitive |
bool |
2 |
单值 |
- |
Python 调用签名
async def validate_tag(tag_name)
通用 gRPC 状态
UNAUTHENTICATED:业务接口缺少或提供了无效的 x-ig-token。
INVALID_ARGUMENT:必填字段为空、字段组合冲突或参数格式错误。
FAILED_PRECONDITION:调用条件未满足,例如登录缺少要求的硬件 signer。
UNIMPLEMENTED:契约已保留,但当前没有可靠上游实现。
INTERNAL:上游拒绝、协议异常或服务端转换失败;以 details() 为准。