获取主页

简介

POST /v1/generations;请求头 Authorization: Bearer <ANYCAP_API_KEY>。固定 type=social,通过 model 选择平台、input.operation 选择查询内容,其余参数见下表及示例。

平台查询内容modelinput.operation
Instagram用户资料instagramprofile
Instagram主页作品instagramposts
小红书用户信息xiaohongshuuser_info
抖音主页作品douyindouyin_user_posts

Instagram · 用户资料

按用户名读取 Instagram 公开达人资料。传 type: social、model: instagram,用户名放在 input。

1. 查询达人资料

BASH
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 通常为空数组;上游未提供的计数保持缺省,帖子预览不是分页内容列表。

JSON
{  "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含义处理
succeeded200资料已归一化,客户费用已结算。读取 call.profile。
started / unknown202查询执行中或结果未确认;保留同一调用 ID。保留 call.id,不要重新提交查询;可用原接入密钥读取 GET /v1/generations/{id}。
error.code404 / 502 / 503明确的查询、上游或配置失败,不结算客户费用。404 profile_not_found:检查用户名。503 capability_unavailable:能力已暂停或尚未配置。502 upstream_error:本次查询明确失败;同一键仍返回该失败,主动重新查询才使用新键。

同一幂等键复用原结果,来源停用后仍可读取;结果查询使用原接入密钥。

Instagram · 主页作品

按用户名获取一页 Instagram 公开帖子列表。传 type: social、model: instagram、input.operation: posts 和用户名。

请求

BASH
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
填写social
说明必填
model
填写instagram
说明必填
input.operation
填写posts
说明必填;选择一页帖子列表
input.username
填写Instagram 用户名
说明必填;字母、数字、句点和下划线,最长 64 个字符;不要带开头的 @
input.count
填写1–20
说明可选;请求的每页数量。实际条数由数据源决定(当前为 12 条)
input.max_id
填写下一页游标
说明可选;把上一页返回的 next_max_id 原样传入
Idempotency-Key
填写唯一键
说明推荐;新获取用新键,重试沿用原键

接入密钥必须被授权使用 social.instagram.posts;未授权会在上游调用前返回 503 capability_unavailable,不会扣费。每页都是一次独立执行,分别计费。

返回

JSON
{  "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响应处理
200call.state=succeeded读取 call.posts;已结算费用。
202call.state=started / unknown保留 call.id,用原接入密钥读取 GET /v1/generations/{id};不要发起新获取。
402error.code=insufficient_credits积分不足;补充积分后重试,本次没有提交或扣费。
404 / 502 / 503error.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。

请求

BASH
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
取值social
说明必填
model
取值xiaohongshu
说明必填
input.operation
取值user_info
说明必填,选择用户资料接口
input.user_id
取值24 位用户 ID
说明可选;与链接同时传入时优先使用
input.url
取值主页或分享链接
说明xiaohongshu.com/user/profile/...、xhslink.com、xhslink.cn 链接
input.share_text
取值分享链接别名
说明与 input.url 同义;两者只传一个
Idempotency-Key
取值唯一键
说明建议每次新请求使用新键,重试沿用同一个键

返回

JSON
{  "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 是数据源返回的主页链接。

调用前请确认用户 ID 有效。数据源对不存在的用户 ID 会返回正常的 200 响应,但内容为“服务异常”,且这次查询仍会被上游计费——客户不会扣费,但会消耗一次上游调用。

错误

HTTP响应处理方式
200call.state=succeeded读取 call.user,扣费已结算。
202call.state=started / unknown保留 call.id,用原接入密钥查询 GET /v1/generations/{id};不要重新提交。
402error.code=insufficient_credits补充积分后重试;本次未提交、未扣费。
404 / 502 / 503error.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 传入。每一页都是一次独立的同步执行,分别计费。

请求

BASH
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
取值social
说明必填
model
取值douyin
说明必填
input.operation
取值douyin_user_posts
说明必填,选择用户主页作品接口
input.sec_user_id
取值sec_user_id
说明必填;抖音主页 URL 中的用户 ID
input.count
取值1–20
说明可选,默认 20
input.filter_type
取值0 或 3
说明可选,默认 0;3 为热度排序
input.max_cursor
取值翻页游标
说明可选;第一页传 0 或不传,之后传上一页的 douyin_posts.max_cursor
Idempotency-Key
取值唯一键
说明建议每页使用新键,重试沿用同一个键

返回

JSON
{  "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 与扣费;把游标传回即可读取下一页。

公开能力使用 App 接口而不是 Web 接口,因为供应商标注 Web 接口不稳定。如需 Web 接口特有的过滤字段,请直接调用供应商;Anycap 不会自动切换路由,因为每次尝试都会计费。

错误

HTTP响应处理方式
200call.state=succeeded读取 call.douyin_posts.items,扣费已结算。
202call.state=started / unknown保留 call.id,用原接入密钥查询 GET /v1/generations/{id};不要重新提交。
402error.code=insufficient_credits补充积分后重试;本次未提交、未扣费。
404 / 502 / 503error.code不扣客户费用。错误码:posts_not_found、upstream_error、capability_unavailable。
上一篇爆款复刻
下一篇获取详情