获取主页
简介
POST /v1/generations;请求头 Authorization: Bearer <ANYCAP_API_KEY>。固定 type=social,通过 model 选择平台、input.operation 选择查询内容,其余参数见下表及示例。
| 平台 | 查询内容 | model | input.operation |
|---|---|---|---|
| 用户资料 | instagram | profile | |
| 主页作品 | instagram | posts | |
| 小红书 | 用户信息 | xiaohongshu | user_info |
| 抖音 | 主页作品 | douyin | douyin_user_posts |
Instagram · 用户资料
按用户名读取 Instagram 公开达人资料。传 type: social、model: instagram,用户名放在 input。
1. 查询达人资料
curl -X POST https://api.anycap.io/v1/generations \ -H "Authorization: Bearer $ANYCAP_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: 6c3c1a5e-6f43-4b2f-9c1e-1c2b3a4d5e6f" \ -d '{ "type": "social", "model": "instagram", "input": { "operation": "profile", "username": "xuezhiqian" } }'input.operation 可省略,默认 profile。用户名仅支持字母、数字、句点和下划线,最长 64 个字符;不要带开头的 @。模型发现使用 GET /v1/generations/models?type=social。
2. 返回结果
查询成功返回 HTTP 200、type: social 与 call。call.profile 是有界快照:平台、账号 ID、用户名、昵称、头像、简介、认证与私密标记、可选外链/分类、上游提供的粉丝/关注/作品数,以及在数据源返回时最多 12 条近期公开帖子(封面与互动计数)。当前资料接口只返回计数,recent_posts 通常为空数组;上游未提供的计数保持缺省,帖子预览不是分页内容列表。
{ "type": "social", "call": { "id": "6c3c1a5e-6f43-4b2f-9c1e-1c2b3a4d5e6f", "state": "succeeded", "operation": "profile", "username": "xuezhiqian", "amount_microcredits": "9000000", "charged_microcredits": "9000000", "created_at": "2026-10-26T10:00:00Z", "profile": { "platform": "instagram", "id": "336339725", "username": "xuezhiqian", "nickname": "JOKER 薛之谦", "verified": true, "private": false, "follower_count": 571280, "content_count": 216, "recent_posts": [ { "id": "4010591197571821503", "cover_url": "https://...", "digg_count": 29648 } ] }, "completed_at": "2026-10-26T10:00:00Z", "media_downloads": [ { "field": "profile.recent_posts[0].cover_url", "source_url": "https://...", "download_url": "https://api.anycap.io/v1/social-media/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "expires_at": "2026-10-26T12:00:00Z", "status": "ready" } ] }}call.media_downloads 提供 Anycap 下载链接,原始第三方链接保留。仅 status=ready 时可免 API Key 下载;有效期为 call.completed_at 后 2 小时,以 expires_at 为准,重复查询不续期。
| 状态 | HTTP | 含义 | 处理 |
|---|---|---|---|
succeeded | 200 | 资料已归一化,客户费用已结算。 | 读取 call.profile。 |
started / unknown | 202 | 查询执行中或结果未确认;保留同一调用 ID。 | 保留 call.id,不要重新提交查询;可用原接入密钥读取 GET /v1/generations/{id}。 |
error.code | 404 / 502 / 503 | 明确的查询、上游或配置失败,不结算客户费用。 | 404 profile_not_found:检查用户名。503 capability_unavailable:能力已暂停或尚未配置。502 upstream_error:本次查询明确失败;同一键仍返回该失败,主动重新查询才使用新键。 |
同一幂等键复用原结果,来源停用后仍可读取;结果查询使用原接入密钥。
Instagram · 主页作品
按用户名获取一页 Instagram 公开帖子列表。传 type: social、model: instagram、input.operation: posts 和用户名。
请求
curl -X POST https://api.anycap.io/v1/generations \ -H "Authorization: Bearer $ANYCAP_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: 7a1e4c9d-3b62-4f80-a5d1-8c2e6b9f0a34" \ -d '{"type":"social","model":"instagram","input":{"operation":"posts","username":"instagram","count":12}}'type
socialmodel
instagraminput.operation
postsinput.username
@input.count
input.max_id
next_max_id 原样传入Idempotency-Key
接入密钥必须被授权使用 social.instagram.posts;未授权会在上游调用前返回 503 capability_unavailable,不会扣费。每页都是一次独立执行,分别计费。
返回
{ "type": "social", "call": { "id": "7a1e4c9d-3b62-4f80-a5d1-8c2e6b9f0a34", "state": "succeeded", "operation": "posts", "username": "instagram", "count": 12, "amount_microcredits": "11000000", "charged_microcredits": "11000000", "created_at": "2026-10-28T03:54:20Z", "posts": { "items": [ { "id": "4017275189435174347_25025320", "shortcode": "DfAOoAXRg3L", "media_type": "video", "description": "An original, straight from the studio 🎶", "cover_url": "https://instagram.fbne9-1.fna.fbcdn.net/v/...jpg", "play_url": "https://instagram.fbne9-1.fna.fbcdn.net/v/...mp4", "duration_ms": 22933, "width": 720, "height": 1280, "created_at": 1793116773, "author": { "id": "25025320", "username": "instagram", "nickname": "Instagram" }, "play_count": 36914700, "digg_count": 149208, "comment_count": 5178 } ], "next_max_id": "3997798548002238943_25025320", "has_more": true }, "completed_at": "2026-10-28T03:54:20Z", "media_downloads": [ { "field": "posts.items[0].cover_url", "source_url": "https://instagram.fbne9-1.fna.fbcdn.net/v/...jpg", "download_url": "https://api.anycap.io/v1/social-media/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "expires_at": "2026-10-28T05:54:20Z", "status": "ready" } ] }}call.posts.items 每条帖子包含 ID、shortcode、media_type(image、video 或 carousel)、文案、封面、轮播按序的 image_urls、视频的 play_url、尺寸、发布时间、作者及 Instagram 实际提供的互动计数;缺失的计数、尺寸和时长不返回。call.posts.next_max_id 是不透明游标,下一页原样作为 input.max_id 并换用新的幂等键;上游未报告更多帖子时 has_more 为 false。
call.media_downloads 提供 Anycap 下载链接,原始第三方链接保留。仅 status=ready 时可免 API Key 下载;有效期为 call.completed_at 后 2 小时,以 expires_at 为准,重复查询不续期。
错误
| HTTP | 响应 | 处理 |
|---|---|---|
| 200 | call.state=succeeded | 读取 call.posts;已结算费用。 |
| 202 | call.state=started / unknown | 保留 call.id,用原接入密钥读取 GET /v1/generations/{id};不要发起新获取。 |
| 402 | error.code=insufficient_credits | 积分不足;补充积分后重试,本次没有提交或扣费。 |
| 404 / 502 / 503 | error.code | 不扣客户费用;错误码为 profile_not_found、posts_not_found、upstream_error 或 capability_unavailable(能力暂停、未配置或密钥未授权)。 |
小红书 · 用户信息
按用户 ID 或分享链接,通过小红书 App 接口(app/v2/get_user_info)读取公开用户资料。返回昵称、头像、简介、小红书号(red_id)、IP 属地、认证文案、粉丝/关注/笔记数、获赞与收藏总数以及主页分享链接。同时传入 input.user_id 和链接时,优先使用用户 ID。
请求
curl -X POST https://api.anycap.io/v1/generations \ -H "Authorization: Bearer $ANYCAP_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: 2f9c5b1e-4d7a-4c2e-8b61-0a3d5e7f9c24" \ -d '{"type":"social","model":"xiaohongshu","input":{"operation":"user_info","user_id":"61b46d790000000010008153"}}'type
socialmodel
xiaohongshuinput.operation
user_infoinput.user_id
input.url
xiaohongshu.com/user/profile/...、xhslink.com、xhslink.cn 链接input.share_text
input.url 同义;两者只传一个Idempotency-Key
返回
{ "type": "social", "call": { "id": "2f9c5b1e-4d7a-4c2e-8b61-0a3d5e7f9c24", "state": "succeeded", "operation": "user_info", "user_id": "61b46d790000000010008153", "amount_microcredits": "2000000", "charged_microcredits": "2000000", "created_at": "2026-11-02T03:10:00Z", "user": { "id": "61b46d790000000010008153", "nickname": "JeremyLin林书豪", "avatar_url": "https://sns-avatar-qc.rednotecdn.com/avatar/example.jpg", "description": "职业篮球运动员", "red_id": "1429907658", "ip_location": "Beijing", "verify_content": "运动员", "follower_count": 194980, "following_count": 7, "note_count": 338, "liked_count": 548830, "collected_count": 48600, "share_link": "https://www.xiaohongshu.com/user/profile/61b46d790000000010008153" } }}平台未提供的计数会缺省;传用户 ID 时返回 call.user_id,传链接时返回 call.url。red_id 是小红书号;share_link 是数据源返回的主页链接。
错误
| HTTP | 响应 | 处理方式 |
|---|---|---|
| 200 | call.state=succeeded | 读取 call.user,扣费已结算。 |
| 202 | call.state=started / unknown | 保留 call.id,用原接入密钥查询 GET /v1/generations/{id};不要重新提交。 |
| 402 | error.code=insufficient_credits | 补充积分后重试;本次未提交、未扣费。 |
| 404 / 502 / 503 | error.code | 不扣客户费用。错误码:user_not_found、upstream_error、capability_unavailable。 |
抖音 · 主页作品
通过抖音 App 数据源(app/v3/fetch_user_post_videos;供应商标注 Web 接口不稳定,因此使用 App 接口)读取用户主页作品列表。传 input.sec_user_id,可选 input.count(1–20,默认 20)、input.filter_type(0 默认排序,3 热度排序);翻页时把上一页返回的 douyin_posts.max_cursor 作为 input.max_cursor 传入。每一页都是一次独立的同步执行,分别计费。
请求
curl -X POST https://api.anycap.io/v1/generations \ -H "Authorization: Bearer $ANYCAP_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: 3b7e9c1d-5f2a-4d8b-9c6e-1a4f7b2d8e35" \ -d '{"type":"social","model":"douyin","input":{"operation":"douyin_user_posts","sec_user_id":"MS4wLjABAAAANXSltcLCzDGmdNFI2Q_QixVTr67NiYzjKOIP5s03CAE","count":20,"filter_type":"0"}}'type
socialmodel
douyininput.operation
douyin_user_postsinput.sec_user_id
input.count
input.filter_type
0 或 3input.max_cursor
douyin_posts.max_cursorIdempotency-Key
返回
{ "type": "social", "call": { "id": "3b7e9c1d-5f2a-4d8b-9c6e-1a4f7b2d8e35", "state": "succeeded", "operation": "douyin_user_posts", "sec_user_id": "MS4wLjABAAAANXSltcLCzDGmdNFI2Q_QixVTr67NiYzjKOIP5s03CAE", "filter_type": "0", "amount_microcredits": "2000000", "charged_microcredits": "2000000", "created_at": "2026-11-02T07:30:00Z", "douyin_posts": { "items": [ { "id": "7372484719365098803", "description": "你对我的好我一直记得", "cover_url": "https://p3-pc-sign.douyinpic.com/example-cover.jpg", "play_url": "https://v3-web.douyinvod.com/example-video.mp4", "duration_ms": 8010, "width": 1920, "height": 1080, "created_at": 1716540374, "author": { "id": "95823111667", "username": "L99612", "nickname": "萧萧不吃辣", "avatar_url": "https://p3-pc.douyinpic.com/example-avatar.jpg" }, "digg_count": 312986, "comment_count": 4071, "share_count": 79966, "collect_count": 19911 } ], "max_cursor": "1773738949000", "has_more": true } }}call.douyin_posts.items 与单作品接口使用同一套归一化字段;max_cursor 为不透明游标,只对同一用户有效,has_more 为 false 表示没有更多。每页有独立的 call 与扣费;把游标传回即可读取下一页。
错误
| HTTP | 响应 | 处理方式 |
|---|---|---|
| 200 | call.state=succeeded | 读取 call.douyin_posts.items,扣费已结算。 |
| 202 | call.state=started / unknown | 保留 call.id,用原接入密钥查询 GET /v1/generations/{id};不要重新提交。 |
| 402 | error.code=insufficient_credits | 补充积分后重试;本次未提交、未扣费。 |
| 404 / 502 / 503 | error.code | 不扣客户费用。错误码:posts_not_found、upstream_error、capability_unavailable。 |