尧图网络 高端网站定制 · 原创设计
免费咨询热线
400-888-6620
免费获取方案
instagram-private-api 响应类型解析:TopicalExploreFeedResponseFriendship_status 友谊状态结构详解
后端【免费下载链接】instagram-private-apiNodeJS Instagram private API SDK. Written in TypeScript.项目地址https://gitcode.com/gh_mirrors/in/instagram-private-api点击查看免费下载TopicalExploreFeedResponseFriendship_status 是 instagram-private-apiNodeJS Instagram 私有 API SDKTypeScript 编写中主题探索流Topical Explore Feed响应里描述当前登录用户与某位内容作者之间关系状态的核心数据结构。本指南将完整解析该接口的 4 个布尔字段following、outgoing_request、is_bestie、is_restricted的语义、取值来源并结合仓库源码响应定义、Feed 请求实现、FriendshipRepository说明其在实际抓取与好友关系判断场景中的用法。读完本文你将掌握如何在探索流数据中读取用户关系状态、如何区分已关注/待对方同意/密友/受限四种状态以及这些状态字段在 SDK 其他响应类型中的共性与差异。一、接口概览定义位置与数据结构该接口由 TypeDoc 从源码自动生成完整的 TypeScript 定义位于仓库 src/responses/topical-explore.feed.response.ts#L130-L135export interface TopicalExploreFeedResponseFriendship_status { following: boolean; outgoing_request: boolean; is_bestie: boolean; is_restricted: boolean; }这是一个全布尔字段的扁平结构全部属性均为必填非可选共 4 个字段没有嵌套对象或数组属性名类型语义从字段名与 SDK 用法推断followingboolean当前登录用户是否已关注该作者outgoing_requestboolean当前用户是否已发出关注请求且尚未被对方接受对方为私密账号is_bestieboolean该作者是否在当前用户的密友Close Friends / Besties名单中is_restrictedboolean该作者是否处于当前用户的受限Restrict状态在 docs/modules/responses.md 的响应类型索引中该接口被列为TopicalExploreFeedResponseFriendship_status是 responses 模块对外暴露的类型之一。二、字段出现的位置User 对象的可选嵌套该结构并不是顶层响应而是嵌套在探索流中的用户对象内部。在 src/responses/topical-explore.feed.response.ts#L110-L129 中可以看到宿主接口export interface TopicalExploreFeedResponseUser { pk: number; username: string; full_name: string; is_private: boolean; profile_pic_url: string; profile_pic_id?: string; friendship_status?: TopicalExploreFeedResponseFriendship_status; is_verified: boolean; has_anonymous_profile_picture?: boolean; // ... 其他字段 }需要注意的关键点friendship_status在 User 对象中是可选字段以?标记也就是说 Instagram 服务端并非每条探索流媒体都会返回该结构。读取时必须做空值防护例如user.friendship_status?.following。完整响应链路是TopicalExploreFeedResponseRootObject → sectional_items[] → layout_content.medias[] / fill_items[] → media.user → friendship_status。从 响应根对象定义 可以看到探索流响应按sectional_items分区条目组织每个分区内以layout_content承载媒体列表媒体对象TopicalExploreFeedResponseMedia中又包含user: TopicalExploreFeedResponseUser见 L46。三、四个布尔字段的语义逐一解析1. following是否已关注following表示当前登录用户是否已经关注该作者是整个结构中最核心的关系标志true已关注后续交互如取消关注、查看私密内容都有前提false未关注。SDK 在 ProfileEntity 中直接依赖该字段实现幂等的关注/取关逻辑public async checkFollow() { const friendshipStatus await this.client.friendship.show(this.pk); if (friendshipStatus.following true) return friendshipStatus; return await this.client.friendship.create(this.pk); }即先通过friendship.show()查询关系若following已为true则直接返回否则才发起关注请求——这是避免重复关注、降低接口滥用风险的标准做法同样适用于探索流中判断某个作者是否已关注后再决定操作。2. outgoing_request待处理的外发请求outgoing_request为true表示当前用户已经发出关注请求但对方尚未接受。该字段通常与作者的is_private私密账号同时出现关注私密账号时请求进入待审核状态following为false、outgoing_request为true对方通过请求后following翻转为true、outgoing_request回落为false。从 FriendshipRepository 的change私有方法可以看到SDK 正是通过向/api/v1/friendships/{action}/{id}/发送签名表单来执行create关注、destroy取关、approve接受等操作操作完成后服务端返回的关系状态中同样包含outgoing_request。因此该字段适合用来判断我的请求是否还在对方那里挂着避免重复发请求。3. is_bestie是否密友is_bestie为true表示该作者位于当前用户的密友名单中。Instagram 的密友Besties / Close Friends是仅向指定用户展示 Story 等内容的私密圈子。SDK 提供了完整的密友管理能力FriendshipRepository.setBesties() 通过 POST/api/v1/friendships/set_besties/并携带add/remove的用户 ID 数组来增删密友返回friendship_statuses映射表即每个目标用户对应的关系状态对象。在探索流中is_bestie可以用来做内容过滤——例如只统计密友发布的内容或在渲染界面时对密友作者做特殊标识。4. is_restricted是否受限is_restricted为true表示该作者被当前用户设置为受限状态。Instagram 的限制Restrict功能介于拉黑与普通之间受限用户的评论只对其本人可见其消息会进入请求列表且对方看不到你在线状态。SDK 在 RestrictActionRepository 中提供了对应的设置与解除能力public async restrict(targetUserId: number | string) { const { body } await this.client.request.send({ url: /api/v1/restrict_action/restrict/, method: POST, form: { _csrftoken: this.client.state.cookieCsrfToken, _uuid: this.client.state.uuid, target_user_id: targetUserId, }, }); return body; }以及对称的unrestrict()POST/api/v1/restrict_action/unrestrict/。在探索流数据中is_restricted是识别受限关系的唯一信号可用于自动屏蔽受限作者的推荐内容或互动提醒。四、在 TopicalExploreFeed 中的实际使用该响应类型对应 TopicalExploreFeed 的返回数据。该 Feed 向/api/v1/discover/topical_explore/发起 GET 请求通过items()返回sectional_items分区数组。一个典型的使用场景如下import { IgApiClient } from ../src; const ig new IgApiClient(); ig.state.generateDevice(your_username); await ig.account.login(your_username, your_password); const feed ig.feed.topicalExplore(); // 可选设置地理位置与分类 feed.lat 31.2304; feed.lng 121.4737; feed.clusterId explore_all:0; const items await feed.items(); for (const section of items) { const medias section.layout_content.medias ?? []; for (const { media } of medias) { const user media.user; const fs user.friendship_status; // TopicalExploreFeedResponseFriendship_status | undefined if (!fs) continue; // 服务端未返回关系状态必须判空 if (fs.is_restricted) continue; // 跳过受限作者的推荐 if (fs.is_bestie) console.log(密友:, user.username); if (fs.following) console.log(已关注:, user.username); if (fs.outgoing_request) console.log(待对方通过:, user.username); } }配合 Feed 提供的分页能力响应中的next_max_id、more_available会通过statesetter 写入 TopicalExploreFeed由基类Feed驱动翻页你可以持续遍历整个探索流并基于每个作者的关系状态做聚合统计或自动化决策。五、同 SDK 中 friendship_status 的各版本对比该接口并非 SDK 中唯一的关系状态结构。从源码检索可以看到friendship_status结构在 20 个响应类型中反复出现但字段集合各不相同。这与 Instagram 不同接口返回的字段粒度不一致直接相关属于服务端返回差异在类型层的如实映射。几个典型对比接口字段差异点TopicalExploreFeedResponseFriendship_status本文following、outgoing_request、is_bestie、is_restricted探索流专属含is_restricted但无followed_byTimelineFeedResponseFriendship_statusfollowing、outgoing_request、is_muting_reel、is_bestie时间线流含is_muting_reel是否静音快拍UserRepositorySearchResponseFriendship_statusfollowing、is_private、incoming_request、outgoing_request、is_bestie搜索结果含incoming_request对方是否请求关注我、is_privateFriendshipRepositoryChangeResponseFriendship_statusfollowing、followed_by、blocking、muting、is_private、incoming_request、outgoing_request、is_bestie关注/取关操作后返回字段最全可以观察到两个规律following与outgoing_request是所有版本共有的最小公共集——任何场景下判断我是否关注了对方 / 是否在等对方通过都依赖这两个字段is_restricted只出现在探索流及部分媒体/私信类响应中而操作类响应如friendship.change用blocking、muting等表达更细粒度的管控状态。这提示开发者不同接口返回的friendship_status不能混用应以当前响应对应的 TypeScript 接口为准。六、实战要点小结围绕TopicalExploreFeedResponseFriendship_status开发与使用中有四条关键经验空值防护优先由于 User 对象中的friendship_status是可选字段访问前务必判空user.friendship_status?.following否则可能触发运行时错误。按需组合判断关系阶段结合is_private与outgoing_request可以准确判断作者账号是公开、私密待审核还是已互相关注从而决定是否展示关注/等待/已关注三类 UI 状态。状态是快照而非实时该结构是探索流接口返回时点的关系快照若要获取最新状态应通过ig.friendship.show(id)对应 FriendshipRepository.show主动查询。以接口定义为准勿跨类型假设字段存在不同接口返回的friendship_status字段集合不同见第五节对比表严格使用 TypeScript 类型可以避免在编译期无法察觉的字段访问错误。七、进一步阅读接口完整源码定义src/responses/topical-explore.feed.response.ts主题探索流 Feed 实现src/feeds/topical-explore.feed.ts关系操作仓储关注/取关/密友src/repositories/friendship.repository.ts受限关系操作src/repositories/restrict-action.repository.ts幂等关注逻辑示例src/entities/profile.entity.ts响应类型模块索引docs/modules/responses.md赞分享后端【免费下载链接】instagram-private-apiNodeJS Instagram private API SDK. Written in TypeScript.项目地址https://gitcode.com/gh_mirrors/in/instagram-private-api点击查看免费下载相关推荐instagram-private-api 中 IGTV 频道流响应的友谊状态结构IgtvChannelFeedResponseFriendship_status 接口完全解析instagram private api 中 IGTV 频道流响应的友谊状态结构IgtvChannelFeedResponseFriendship_stat后端Warp 桌面端 Orchestration 自定义 Worker Host 选择器Host Picker实现解析Warp 桌面端 Orchestration 自定义 Worker Host 选择器Host Picker实现解析 导读 Warp 的编排Orchestr后端instagram-private-api 响应类型详解MediaUpdatedMediaResponseUpdated_media 接口结构与实战解析instagram private api 响应类型详解MediaUpdatedMediaResponseUpdated_media 接口结构与实战解析 本文后端上一篇告别蜗牛速度macOS百度网盘优化指南下一篇告别复杂动画代码Spring让iOS动效开发效率提升10倍的实战指南创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考
RELATED

相关推荐

易语言数组操作实战:重定义数组与复制数组的用法、避坑与案例

易语言数组操作实战:重定义数组与复制数组的用法、避坑与案例

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

📅 2026/10/16 1:51:30
markdownlint 规则实战:用 MD044/proper-names 强制统一专有名词大小写

markdownlint 规则实战:用 MD044/proper-names 强制统一专有名词大小写

开发工具代码质量Lint静态分析 【免费下载链接】markdownlint A Node.js style checker and lint tool for Markdown/CommonMark files. 项目地址: https://gitcode.com/gh_mirrors/ma/markdownlint 点击查看 免费下载 本篇文章围绕 markdownlint 仓库中的测试用例…

📅 2026/10/16 1:51:30
GLSL 精度限定符 lowp 完全指南:The Book of Shaders 中的精度体系与实践

GLSL 精度限定符 lowp 完全指南:The Book of Shaders 中的精度体系与实践

【免费下载链接】thebookofshaders Step-by-step guide through the abstract and complex universe of Fragment Shaders. 项目地址: https://gitcode.com/gh_mirrors/th/thebookofshaders 点击查看 免费下载 导读 lowp 是 GLSL ES(嵌入式系统着色语言…

📅 2026/10/16 1:51:30
MORE NEWS

更多资讯

📰

SAP Fiori Elements实战:从CDS注解到RAP应用开发全解析

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

📰

实训5指纹设置全解析:从传感器原理到实操与安全

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

📰

语音特征提取全流程:从原始波形到MFCC特征向量

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

📰

Java线程start()方法原理与线程生命周期解析

1. 线程生命周期与start()方法本质当面试官抛出"为什么线程start()不能重复调用"这个问题时,实际上是在考察你对Java线程生命周期的理解深度。让我们先看一个典型的错误示例:Thread thread new Thread(() -> System.out.println("Run…

📰

Spring Cloud Gateway GatewayFilter 源码解析与责任链机制

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

📰

粒子群算法优化LQR的二级倒立摆控制设计与避坑实践

/* MD / 富文本中的 .toc(含博客园搬家等嵌套结构);.toc-box 在侧栏,不受影响 */#content_views .toc,/* 编辑器常在目录前后插入空 p(:empty 仍占 20px),一并去掉避免顶空隙 */#content_views.markdown_views > p:empty:has(+ .toc),#content_views.markdown_views …

TODAY

今日更新

THIS WEEK

本周精选

THIS MONTH

本月热门

读完文章,想聊聊您的网站?

告诉我们您的行业与需求,资深顾问一对一梳理方案与报价,全程免费。

📞 💬