指标)
后端【免费下载链接】instagram-private-apiNodeJS Instagram private API SDK. Written in TypeScript.项目地址https://gitcode.com/gh_mirrors/in/instagram-private-api点击查看免费下载导读在 instagram-private-apiNodeJS Instagram private API SDKTypeScript 编写中InsightsServicePostResponseReach是帖子数据分析链路中的核心接口之一承载着触达量Reach这一关键业务指标的结构化定义。本文将以该接口为主干结合 insights.service.post.response.ts、insights.service.ts 等源码完整讲解其字段语义、在整棵响应对象树中的位置、获取方式以及与reach_count、impressions等相邻指标的区别帮助你准确解析 Instagram 商业账号的单帖数据洞察Post Insights。一、接口定位帖子洞察响应树中的触达节点InsightsServicePostResponseReach位于帖子洞察响应的深层嵌套结构中。从 insights.service.post.response.ts 的源码可以看到一次帖子洞察请求的返回对象以InsightsServicePostResponseRootObject为根访问路径为InsightsServicePostResponseRootObject └── data InsightsServicePostResponseData └── media InsightsServicePostResponseMedia └── inline_insights_node InsightsServicePostResponseInline_insights_node └── metrics InsightsServicePostResponseMetrics └── reach InsightsServicePostResponseReach ← 本文主角从源码结构看reach与reach_count、impression_count、impressions、share_count、profile_actions、owner_account_follows_count、owner_profile_views_count、hashtags_impressions同属 InsightsServicePostResponseMetrics 下的平行指标字段定义于 insights.service.post.response.ts:36-45而reach是其中唯一一个以嵌套对象而非标量数字形式呈现的字段这一点决定了它在解析时需要额外一层结构处理。二、接口定义与字段详解InsightsServicePostResponseReach的定义位于 insights.service.post.response.ts:76-79全文如下export interface InsightsServicePostResponseReach { value: number; follow_status: InsightsServicePostResponseFollow_status; }2.1value: number—— 触达总量类型number。语义表示该帖子的触达量Reach即看过这条内容的去重后独立账号数。与展示次数Impressions会重复计数不同Reach 更贴近真实触达人数。来源依据定义于 insights.service.post.response.ts:77。2.2follow_status: InsightsServicePostResponseFollow_status—— 按关注关系拆解的触达构成类型InsightsServicePostResponseFollow_status其内部只有一个字段export interface InsightsServicePostResponseFollow_status { nodes: InsightsServicePostResponseNodesItem[]; }定义于 insights.service.post.response.ts:80-82。语义推断从字段命名和结构可以推断该字段将value这个触达总量按观看者与账号所有者之间的关注关系进一步拆解用于回答诸如有多少触达来自粉丝、多少来自非粉丝之类的归因问题。value与follow_status.nodes中各项的数值之间存在聚合与细分的关系。2.3nodes中每一项InsightsServicePostResponseNodesItem的结构follow_status.nodes数组的每个元素复用通用的节点结构 InsightsServicePostResponseNodesItem定义于 insights.service.post.response.ts:53-57export interface InsightsServicePostResponseNodesItem { __typename: string; value: number; name?: string; // 可选字段 }字段类型说明__typenamestringGraphQL 节点类型标识用于区分该节点属于哪一类数据点valuenumber该节点的数值如某类关注关系下的触达人数namestring可选节点名称标签通常标识该数据点的业务含义同样的NodesItem结构在Impressions.surfaces.nodes按展示位置/渠道拆解、Share_count、Profile_actions等指标中被反复复用是整套 Insights 响应体系中通用的数值标签数据点载体。三、如何获取该数据InsightsService.post()调用链要拿到包含reach的响应需要在已登录状态下调用InsightsService的post()方法服务类继承自Repository由 src/core/client.ts:84 通过public insights new InsightsService(this)挂载在IgApiClient实例上import { IgApiClient } from instagram-private-api; const ig new IgApiClient(); ig.state.generateDevice(你的用户名); // 登录后 const response await ig.insights.post(MEDIA_ID); // 取触达量 const reach response.data.media.inline_insights_node.metrics.reach; console.log(reach.value); console.log(reach.follow_status.nodes);3.1 底层 GraphQL 请求的实现post()方法本身只是参数封装真正的请求由 ads.repository.ts 的graphQL()方法发出定义于 insights.service.ts:27-41public post(mediaId: string): PromiseInsightsServicePostResponseRootObject { return this.client.ads.graphQLInsightsServicePostResponseRootObject({ surface: { name: post, friendlyName: IgInsightsPostInsightsQuery, }, documentId: 2009845309144121, variables: { query_params: { access_token: , id: mediaId, }, }, }); }对应的请求配置类型为 graphql-request.options.ts 中的GraphQLRequestOptions其关键字段含义如下字段说明surface.name数据面名称此处为post取值类型定义见InsightsSurfacesurface.friendlyNameGraphQL 操作的友好名称此处为IgInsightsPostInsightsQuerydocumentIdInstagram 服务端对应的 GraphQL 文档 ID帖子洞察固定为2009845309144121variables.query_params.id目标媒体 IDvariables.query_params.access_token商业数据接口的访问令牌此处 SDK 默认传空字符串3.2 请求的最终形态ads.graphQL()会把上述配置拼接成一次对POST /api/v1/ads/graphql/的请求query string 携带locale、vc_policy: insights_policy、surface表单中携带doc_id、fb_api_caller_class: RelayModern、fb_api_req_friendly_name以及 JSON 序列化后的variables见 ads.repository.ts:5-26。这意味着reach数据本质上来自 Instagram 的广告/数据洞察 GraphQL 端点而非普通的信息流接口。四、关键指标辨析reach与reach_count、impressions的差异在 InsightsServicePostResponseMetrics 中同时存在三个容易混淆的指标理解它们的区别是正确使用本文接口的前提指标类型语义reach.value嵌套对象触达量去重后的独立观看账号数并带follow_status关注关系拆解reach_countnumber触达量标量形式即与reach.value同值的简化数字定义于 insights.service.post.response.ts:38impressions嵌套对象展示次数含重复曝光带surfaces按展示位置拆解impression_countnumber展示次数的标量形式reach与impressions的典型关系是展示次数 ≥ 触达量因为同一账号可被多次曝光但只计一次触达。当只需要一个数字做聚合或落库时直接用metrics.reach_count即可当需要做归因分析如多少触达来自关注者时则必须解析metrics.reach.follow_status.nodes。五、实战解析follow_status做触达归因以下示例展示如何遍历follow_status.nodes输出触达构成const metrics response.data.media.inline_insights_node.metrics; const reach metrics.reach; // 1. 触达总量 console.log(总触达${reach.value}); // 2. 按关注状态拆解 for (const node of reach.follow_status.nodes) { console.log([${node.__typename}] ${node.name ?? (无标签)} ${node.value}); }对返回的nodes数组可结合__typename与name字段区分不同分类如关注者/非关注者等数据点由于name是可选的编写健壮代码时应使用node.name ?? 做兜底。六、使用前提与注意事项账号权限InsightsServicePostResponseRootObject来自商业/创作者数据洞察接口。从仓库多处响应类型可见can_see_organic_insights、show_insights_terms等权限相关字段如 media.repository.configure.response.ts:55-56说明这类数据通常面向可查看有机洞察的账号开放普通账号可能拿不到有效数据。媒体 ID 格式post()接收的是字符串形式的媒体 IDMEDIA_ID可通过media.info()等接口或帖子实体获得。登录态依赖请求链路依赖client.state中维护的 cookie 与设备信息调用前必须完成ig.account.login()登录。数据可用性inline_insights_node.error字段类型为null见 insights.service.post.response.ts:33即 SDK 当前版本约定正常响应中该节点不携带错误信息若未来服务端返回异常仍需做好运行时校验。七、关联能力延伸若想一次性获取多条帖子的洞察摘要含每条帖子的reach_count、impression_count等标量指标可改用 posts-insights.feed.ts 提供的PostsInsightsFeed分页流其响应中的PostsInsightsFeedResponseMetrics见 posts-insights.feed.response.ts:50-57同样包含触达相关字段。账号级整体洞察粉丝增长、内容表现等则对应InsightsService.account()其返回类型为 InsightsServiceAccountResponseRootObject。所有 Insights 响应类型均从 src/responses/index.ts 统一导出可在引入时直接使用InsightsServicePostResponseRootObject、InsightsServicePostResponseReach等类型获得编译期类型校验。总结InsightsServicePostResponseReach是 instagram-private-api 帖子洞察数据中触达量指标的类型契约value提供去重的触达总数follow_status.nodes提供按关注关系拆解的构成明细。配合InsightsService.post()→AdsRepository.graphQL()的调用链你可以在已登录商业账号的前提下用类型安全的方式完成从拉取帖子洞察到解析触达归因的完整数据流程。赞分享后端【免费下载链接】instagram-private-apiNodeJS Instagram private API SDK. Written in TypeScript.项目地址https://gitcode.com/gh_mirrors/in/instagram-private-api点击查看免费下载相关推荐instagram-private-api 帖子画像数据解析深入 InsightsServicePostResponseActions 接口与主页动作Profile Actions指标instagram private api 帖子画像数据解析深入 InsightsServicePostResponseActions 接口与主页动作Pro后端instagram-private-api MediaEntity 深度指南使用 oEmbed 接口获取 Instagram 帖子嵌入数据instagram private api MediaEntity 深度指南使用 oEmbed 接口获取 Instagram 帖子嵌入数据 导读 MediaE后端Azure SQL Database Always Encrypted with VBS Enclaves 实战指南Contoso HR 演示环境的部署、就地加密与富查询Azure SQL Database Always Encrypted with VBS Enclaves 实战指南Contoso HR 演示环境的部署、就地后端上一篇【免费下载】 Mac环境下Go语言开发环境配置指南基于sb2nov/mac-setup下一篇深入理解unjs/nitro中的任务系统创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考