Instagram API:按话题找帖子并读评论
要按话题看 Instagram 上的内容,分三步:先按话题标签找最新帖子,拿到帖子的 shortcode 或链接;再读这条帖子的详情;最后读它的一级评论。下面每一步都是真实的接口和参数。
新账号有 50 次试用调用,之后按成功调用从预充值余额扣费,详见 定价。
三步从话题读到评论
示例里的 travel 换成你要查的话题标签(不带 #)。第二、三步里的 shortcode 是占位符,要换成第一步结果中的 shortcode,或 Instagram 分享链接里的 shortcode。需要 API Key,新账号有 50 次试用调用;试用调用用完后,Instagram 接口按余额计费。
按话题标签找最新帖子
hashtag 不带 #。返回带该标签的最新帖子,每页约 30 条,每条的 extra.shortcode 和 extra.url 用于后面的步骤。翻页时把上一页返回的 cursor 原样传回,has_more 为 false 时停止;没有人用过的标签返回空结果。
Instagram 话题帖子
GET /v1/raw/instagram/hashtag_postscurl 'https://api.qovia.ai/v1/raw/instagram/hashtag_posts?hashtag=travel' \ -H "Authorization: Bearer $QOVIA_KEY"
import os import requests resp = requests.get( "https://api.qovia.ai/v1/raw/instagram/hashtag_posts", params={"hashtag": "travel"}, headers={"Authorization": f"Bearer {os.environ['QOVIA_KEY']}"}, timeout=30, ) resp.raise_for_status() body = resp.json() print(body["meta"]["charged_usd"], body["data"])
返回的 data 部分。示例取自接口目录,不是实时数据;列表只保留前两条,图片链接省略:
{ "data": { "items": [ { "id": "soc_ins_e553866650de", "src": "social", "platform": "instagram", "lang": null, "text": "A operação começará em 15 de dezembro de 2027, com três voos semanais ✨. Confira mais no link da bio 🔗. #qatarairways✈️ #travel #explorepage #viagens #informaçao", "author": { "uid_hash": "b0d64510d3d2", "followers": null, "nickname": null, "uid": "70000000003", "username": null }, "metrics": { "likes": 0, "comments": 0 }, "extra": { "source_id": "4013029541808673639", "shortcode": "DexJRs4p5Nn", "published_at": "2026-10-21T19:22:27+00:00", "content_type": "image_post", "topic": "#qatarairways", "topics": [ "qatarairways", "travel", "explorepage", "viagens", "informaçao" ], "images": [ "https://scontent-cdg4-3.cdninstagram.com/v/t51.82787-15/862325060_17969227299194626_1865856716945445925_n.jpg?stp=dst-jpg_e35_p1080x1080_sh2.08_tt6&_nc_ht=scontent-cdg4-3.cdninstagram.com&_nc_cat=110&_nc_oc=Q6cZ2gFu66BjcgkXs06g_kLZSs1VgZr9JgkAe58tT7iSkO83az2T6VlkE9mvU1e4irp8-eY&_nc_ohc=pVziCq2jNiYQ7kNvwGHAGs9&_nc_gid=NpyjTo1tYiCXYX7t_Ah8HQ&edm=AA0rjkIBAAAA&ccb=7-5&ig_cache_key=NDAxMzAyOTU0MTgwODY3MzYzOQ%3D%3D.3-ccb7-5&oh=00_AQMFcTm3HBQhDIK992wWP88uVgF9WF7n3W1qBSoOqCCrjA&oe=6ADEEB6C&_nc_sid=49ed71" ], "video_dur_s": null, "location": null, "url": "https://www.instagram.com/p/DexJRs4p5Nn/" }, "prov": { "hash": "0x69439966f886432e", "ts": "2026-10-22T03:30:00+08:00", "source": "live" } }, { "id": "soc_ins_9e233058428f", "src": "social", "platform": "instagram", "lang": null, "text": "Ho Chi Minh City 🇻🇳\n\n#vietnam #travel #travelgram #traveling #asia", "author": { "uid_hash": "48f38f8bd1b9", "followers": null, "nickname": null, "uid": "70000000004", "username": null }, "metrics": { "likes": 0, "comments": 0 }, "extra": { "source_id": "4013029633108641592", "shortcode": "DexJTB6joc4", "published_at": "2026-10-21T19:20:33+00:00", "content_type": "carousel", "topic": "#vietnam", "topics": [ "vietnam", "travel", "travelgram", "traveling", "asia" ], "images": [], "video_dur_s": null, "location": null, "url": "https://www.instagram.com/p/DexJTB6joc4/" }, "prov": { "hash": "0xa5fd1bf8ffbdf901", "ts": "2026-10-22T03:30:00+08:00", "source": "live" } } ], "cursor": "QVFDOFBiU2ptS3k0bUVqMy1WR29XWjkxbzlpemx3ZjBtMjdF", "has_more": true, "total": 798248141, "prov": { "hash": "0x63da10b488f692b2", "ts": "2026-10-22T03:30:00+08:00", "source": "live" } } }读帖子详情
post 传帖子链接(instagram.com/p/、/reel/ 或 /tv/ 开头)或链接里的 shortcode,可以取自上一步的结果。返回文案、作者、点赞数、评论数、视频播放量等。示例里的 EXAMPLE_shortcode 是占位符;帖子不存在或已删除时返回 404。
Instagram 帖子详情
GET /v1/raw/instagram/postcurl 'https://api.qovia.ai/v1/raw/instagram/post?post=EXAMPLE_shortcode' \ -H "Authorization: Bearer $QOVIA_KEY"
读帖子的一级评论
参数同样是 post,示例里的 shortcode 仍是占位符。评论按 Instagram 的排序返回,每页约 15 条;翻页时把上一页的 cursor 原样传回,has_more 为 false 时停止。没有评论的帖子返回空结果。评论的回复用 raw.instagram.comment_replies 取。
Instagram 帖子评论
GET /v1/raw/instagram/commentscurl 'https://api.qovia.ai/v1/raw/instagram/comments?post=EXAMPLE_shortcode' \ -H "Authorization: Bearer $QOVIA_KEY"
更多相关接口
常见问题
shortcode 从哪里来?
来自话题帖子(raw.instagram.hashtag_posts)结果里的 extra.shortcode,也就是帖子链接 instagram.com/p/<shortcode>/ 里的那一段。Instagram 分享链接可以直接作为 post 传入。
怎么读评论的回复?
评论接口只返回一级评论。取某条评论的 cid,连同帖子的 post 一起传给 raw.instagram.comment_replies,每页约 8 条,同样用 cursor 翻页。
能从用户主页开始吗?
可以。raw.instagram.user 按用户名读主页资料,raw.instagram.user_posts 列出该用户的帖子(传 username 或 user_id 之一),拿到 shortcode 后再读详情和评论。
怎么计费?
新账号有 50 次试用调用,之后从预充值余额按次扣费,只对返回了数据的成功调用收费;空结果和报错不扣费,每次返回的 meta.charged_usd 写着这次扣了多少。各接口单价见 API 参考,套餐见定价页。