xapi-to 0.1.18 → 0.1.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +258 -10
- package/dist/chunk-TYY6JR6O.js +870 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1256 -590
- package/dist/openai-sandbox-client.d.ts +85 -0
- package/dist/openai-sandbox-client.js +285 -0
- package/examples/openai-agents-sandbox-local.ts +131 -0
- package/examples/sandbox-api-cli-openai.mjs +450 -0
- package/package.json +33 -4
- package/scripts/openai-sandbox-agent-e2e.ts +219 -0
- package/scripts/sandbox-playground-e2e.mjs +463 -0
- package/skills/xapi/SKILL.md +498 -0
- package/skills/xapi/guides/ai.md +200 -0
- package/skills/xapi/guides/ai_gateway.md +263 -0
- package/skills/xapi/guides/crypto.md +197 -0
- package/skills/xapi/guides/douyin.md +297 -0
- package/skills/xapi/guides/google_search.md +194 -0
- package/skills/xapi/guides/linkedin.md +253 -0
- package/skills/xapi/guides/reddit.md +312 -0
- package/skills/xapi/guides/sandbox.md +466 -0
- package/skills/xapi/guides/serper.md +124 -0
- package/skills/xapi/guides/sms.md +186 -0
- package/skills/xapi/guides/tiktok.md +322 -0
- package/skills/xapi/guides/twitter.md +276 -0
- package/skills/xapi/guides/weibo.md +301 -0
- package/skills/xapi/guides/ws_gateway.md +206 -0
- package/skills/xapi/guides/xiaohongshu.md +315 -0
- package/skills/xapi/scripts/download_tweet_videos.sh +125 -0
- package/src/client.ts +664 -0
- package/src/config.ts +160 -0
- package/src/openai-sandbox-client.ts +349 -0
- package/src/sandbox-client.ts +289 -0
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
# Twitter / X Guide
|
|
2
|
+
|
|
3
|
+
Complete guide for Twitter operations via xAPI — reading data, downloading tweet videos, posting tweets, replying, and OAuth setup.
|
|
4
|
+
|
|
5
|
+
> **Upstream provider:** All `twitter.*` capabilities accept an optional `provider` — `"x"` (fapi.uk, the default) or `"twitter"` (legacy upstream). The response is normalized to an identical structure regardless of provider, so you normally omit it. Pass `"provider":"twitter"` only to force the legacy upstream, e.g. `--input '{"screen_name":"elonmusk","provider":"twitter"}'`.
|
|
6
|
+
|
|
7
|
+
## Contents
|
|
8
|
+
|
|
9
|
+
- [Read Twitter data](#reading-twitter-data-no-oauth-needed)
|
|
10
|
+
- [Download a tweet video](#download-a-tweet-video)
|
|
11
|
+
- [Post and mutate with OAuth](#posting-tweets-oauth-required)
|
|
12
|
+
- [Common workflows](#common-workflows)
|
|
13
|
+
- [Pagination reference](#pagination-reference)
|
|
14
|
+
- [API reference](#api-reference)
|
|
15
|
+
- [Error handling](#error-handling)
|
|
16
|
+
|
|
17
|
+
## Reading Twitter Data (no OAuth needed)
|
|
18
|
+
|
|
19
|
+
### Look up a user by @handle
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npx xapi-to call twitter.user_by_screen_name --input '{"screen_name":"elonmusk"}'
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Returns `rest_id` (numeric user ID), `name`, `screen_name`, `followers_count`, `statuses_count`, etc.
|
|
26
|
+
|
|
27
|
+
**Important:** Most Twitter actions require the numeric `user_id` (called `rest_id` in the response), not the @handle. Always look up the user first to get the ID.
|
|
28
|
+
|
|
29
|
+
### Get a user's recent tweets
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npx xapi-to call twitter.user_tweets --input '{"user_id":"44196397"}'
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Each tweet includes: `id`, `full_text`, `created_at`, `favorite_count`, `retweet_count`, `reply_count`, `views_count`, `media`, `author`, and `quoted_tweet` if applicable.
|
|
36
|
+
|
|
37
|
+
Paginate with the previous response's `data.cursors.bottom`:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npx xapi-to call twitter.user_tweets \
|
|
41
|
+
--input '{"user_id":"44196397","cursor":"<cursors.bottom>"}'
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Get a user's tweets and replies
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
npx xapi-to call twitter.user_tweets_and_replies --input '{"user_id":"44196397"}'
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Similar to `twitter.user_tweets`, but the timeline also includes the user's replies to other tweets and conversation threads they participate in. Each item includes the same fields: `id`, `full_text`, `created_at`, `favorite_count`, `retweet_count`, `reply_count`, `views_count`, `media`, `author`, and `quoted_tweet` if applicable.
|
|
51
|
+
|
|
52
|
+
**When to choose which:**
|
|
53
|
+
|
|
54
|
+
- `twitter.user_tweets` — only the user's own posts. Use for content/timeline of original tweets.
|
|
55
|
+
- `twitter.user_tweets_and_replies` — posts plus replies and conversation participants. Use to monitor a user's reply activity or full timeline.
|
|
56
|
+
|
|
57
|
+
**Filter tip:** because conversation entries can contain tweets from other authors, filter by `author.id === user_id` if you only want the monitored user's content.
|
|
58
|
+
|
|
59
|
+
Pagination uses the same `cursor` → `data.cursors.bottom` pattern as `twitter.user_tweets`.
|
|
60
|
+
|
|
61
|
+
For `twitter.user_tweets` and `twitter.user_tweets_and_replies`, set `"cache":true` to use the fast cache when available and skip the normal upstream call. Cached results can be less fresh; keep the default `false` when freshness matters.
|
|
62
|
+
|
|
63
|
+
### Get a specific tweet and its replies
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
npx xapi-to call twitter.tweet_detail --input '{"tweet_id":"2035526376468394305"}'
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
To load more replies, pass the previous response's `data.cursors.bottom` as `cursor`:
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
npx xapi-to call twitter.tweet_detail \
|
|
73
|
+
--input '{"tweet_id":"2035526376468394305","cursor":"<cursors.bottom>"}'
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Paginated pages commonly contain more `replies` but no main tweet, so `data.tweet` may be `null` when `cursor` is present.
|
|
77
|
+
|
|
78
|
+
### Download a tweet video
|
|
79
|
+
|
|
80
|
+
Use the bundled downloader with either a complete status URL or its numeric tweet ID. Resolve `<xapi-skill-directory>` to the directory containing this guide's parent `SKILL.md`:
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
bash <xapi-skill-directory>/scripts/download_tweet_videos.sh \
|
|
84
|
+
'https://x.com/NousResearch/status/2084325600643445095'
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Pass an optional existing output directory as the second argument; otherwise files are written to the current directory. A single video is named `tweet-<tweet-id>.mp4`; multiple videos are numbered `tweet-<tweet-id>-1.mp4`, `-2.mp4`, and so on. The script includes videos in the main, quoted, and retweeted tweets, deduplicates identical media URLs, and refuses to overwrite any existing output.
|
|
88
|
+
|
|
89
|
+
The script verifies that the deployed `twitter.tweet_detail` schema exposes `video_url` before making the paid call. It omits `provider` to retain automatic failover from the default `x` upstream to the legacy `twitter` upstream on transient failures. The response's `data.provider` identifies the upstream that served it; explicitly setting `provider` would pin that upstream and disable failover.
|
|
90
|
+
|
|
91
|
+
Each download is written to a same-directory temporary file, required to have MIME type `video/mp4`, optionally checked with `ffprobe`, and only renamed to its final path after every media file passes. Failures clean up temporary files, so a partial transfer is never published as the final MP4.
|
|
92
|
+
|
|
93
|
+
`data.tweet.media[].url` and `preview_url` are preview images; do not download them as MP4. The optional `video_info.variants` retains the original MP4 and HLS variants when a specific rendition is needed. `call --output` is not appropriate because the xAPI action returns JSON metadata rather than video bytes; the bundled script downloads each resolved `video_url` with `curl`.
|
|
94
|
+
|
|
95
|
+
### Read an X Article (long-form post)
|
|
96
|
+
|
|
97
|
+
Some tweets are long-form **X Articles**. `twitter.tweet_detail` detects them and returns the full normalized article directly in `data.tweet.article`; no raw GraphQL call or `fieldToggles` parameter is needed.
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
npx xapi-to call twitter.tweet_detail --input '{"tweet_id":"<tweet_id>"}'
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
The normalized `article` object contains:
|
|
104
|
+
|
|
105
|
+
- `id`, `title`, and `preview_text`
|
|
106
|
+
- `text` — full plain text
|
|
107
|
+
- `markdown` — full text with headings, lists, quotes, code blocks, and inline links preserved
|
|
108
|
+
- `cover_image` — URL and optional dimensions
|
|
109
|
+
- `links` — deduplicated external links in appearance order
|
|
110
|
+
- `first_published_at` and `modified_at` — ISO 8601 timestamps when available
|
|
111
|
+
|
|
112
|
+
Use the **tweet ID** from the share URL (`x.com/<user>/status/<tweet_id>` or `x.com/<user>/article/<tweet_id>`), not an internal article ID.
|
|
113
|
+
|
|
114
|
+
### Search tweets
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
npx xapi-to call twitter.search --input '{"raw_query":"AI agents","count":20}'
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
For `provider: "x"` (the default), structured advanced-search filters are also available:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
npx xapi-to call twitter.search --input '{
|
|
124
|
+
"raw_query":"AI",
|
|
125
|
+
"from":"OpenAI",
|
|
126
|
+
"mentioning":"AnthropicAI",
|
|
127
|
+
"phrase":"AI agents",
|
|
128
|
+
"since":"2026-08-01",
|
|
129
|
+
"until":"2026-08-05",
|
|
130
|
+
"min_likes":100,
|
|
131
|
+
"min_replies":10,
|
|
132
|
+
"min_retweets":20,
|
|
133
|
+
"count":20
|
|
134
|
+
}'
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Supported structured filters: `from`, `to`, `mentioning`, `phrase`, `any`, `none`, `tag`, `since`, `until`, `min_replies`, `min_likes`, `min_retweets`, and `count`. `sort_by` accepts `Top`, `Latest` (default), `People`, `Photos`, or `Videos`; the default `x` provider maps both media-specific values to its combined Media search. Dates use `YYYY-MM-DD`; `until` is exclusive. Paginate with `cursor` from `data.cursor_bottom`.
|
|
138
|
+
|
|
139
|
+
### Get user's media posts
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
npx xapi-to call twitter.user_media --input '{"user_id":"44196397"}'
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Paginate with `cursor` from the previous response's `data.cursor_bottom`. Both the default `x` provider and legacy `twitter` provider are supported.
|
|
146
|
+
|
|
147
|
+
### Get followers / following
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
npx xapi-to call twitter.followers --input '{"user_id":"44196397"}'
|
|
151
|
+
npx xapi-to call twitter.following --input '{"user_id":"44196397"}'
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### Get retweeters
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
npx xapi-to call twitter.retweeters --input '{"tweet_id":"1234567890"}'
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Posting Tweets (OAuth required)
|
|
161
|
+
|
|
162
|
+
Posting, replying, quoting, liking, retweeting, and deleting require OAuth. A saved binding provides technical authorization, not standing user consent: confirm the current content and target before a write, and obtain explicit confirmation before destructive or bulk actions.
|
|
163
|
+
|
|
164
|
+
### Step 1: Bind Twitter OAuth
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
npx xapi-to oauth bind --provider twitter
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
This opens a browser for the user to authorize. After authorization, the binding is saved to the API key.
|
|
171
|
+
|
|
172
|
+
Verify:
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
npx xapi-to oauth status
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Should show `tweet.write` in scopes.
|
|
179
|
+
|
|
180
|
+
### Step 2: Post a tweet
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
npx xapi-to call x-official.2_tweets --method POST \
|
|
184
|
+
--input '{"body":{"text":"Hello from my AI agent!"}}'
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
**Character limit:** 280 characters (140 CJK characters). Each CJK character counts as 2.
|
|
188
|
+
|
|
189
|
+
### Reply to a tweet
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
npx xapi-to call x-official.2_tweets --method POST \
|
|
193
|
+
--input '{"body":{"text":"Great point!","reply":{"in_reply_to_tweet_id":"2035526376468394305"}}}'
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Quote tweet
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
npx xapi-to call x-official.2_tweets --method POST \
|
|
200
|
+
--input '{"body":{"text":"Worth reading 👇","quote_tweet_id":"2035526376468394305"}}'
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### Delete a tweet
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
npx xapi-to call x-official.2_tweets_id --method DELETE \
|
|
207
|
+
--input '{"pathParams":{"id":"2036012345678901234"}}'
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### Like a tweet
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
npx xapi-to call x-official.2_users_id_likes --method POST \
|
|
214
|
+
--input '{"pathParams":{"id":"<your_user_id>"},"body":{"tweet_id":"2035526376468394305"}}'
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### Retweet
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
npx xapi-to call x-official.2_users_id_retweets --method POST \
|
|
221
|
+
--input '{"pathParams":{"id":"<your_user_id>"},"body":{"tweet_id":"2035526376468394305"}}'
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
## Common Workflows
|
|
225
|
+
|
|
226
|
+
### Research and tweet
|
|
227
|
+
|
|
228
|
+
1. Search the web: `web.search.realtime` → get latest news
|
|
229
|
+
2. Summarize: `ai.text.summarize` → create a concise summary
|
|
230
|
+
3. Post: `x-official.2_tweets` POST → tweet the summary
|
|
231
|
+
|
|
232
|
+
### Monitor and reply
|
|
233
|
+
|
|
234
|
+
1. Get user activity: `twitter.user_tweets` (originals only) or `twitter.user_tweets_and_replies` (includes replies) → check latest posts
|
|
235
|
+
2. Get tweet detail: `twitter.tweet_detail` → read the thread
|
|
236
|
+
3. Reply: `x-official.2_tweets` POST with `reply` → respond
|
|
237
|
+
|
|
238
|
+
## Pagination Reference
|
|
239
|
+
|
|
240
|
+
| Capability | Next cursor field | Next request input |
|
|
241
|
+
|---|---|---|
|
|
242
|
+
| `twitter.user_tweets` | `data.cursors.bottom` | `cursor` |
|
|
243
|
+
| `twitter.user_tweets_and_replies` | `data.cursors.bottom` | `cursor` |
|
|
244
|
+
| `twitter.tweet_detail` replies | `data.cursors.bottom` | `cursor` |
|
|
245
|
+
| `twitter.user_media` | `data.cursor_bottom` | `cursor` |
|
|
246
|
+
| `twitter.search` | `data.cursor_bottom` | `cursor` |
|
|
247
|
+
| `twitter.followers` | `data.cursor_bottom` | `cursor` |
|
|
248
|
+
| `twitter.following` | `data.cursor_bottom` | `cursor` |
|
|
249
|
+
| `twitter.retweeters` | `data.cursor_bottom` | `cursor` |
|
|
250
|
+
|
|
251
|
+
Omit `cursor` for the first page. Stop when the relevant bottom cursor is absent or empty.
|
|
252
|
+
|
|
253
|
+
## API Reference
|
|
254
|
+
|
|
255
|
+
| API | Method | Description |
|
|
256
|
+
|-----------|--------|-------------|
|
|
257
|
+
| `twitter.user_by_screen_name` | — | Look up user by @handle |
|
|
258
|
+
| `twitter.user_tweets` | — | Get and paginate user's recent tweets |
|
|
259
|
+
| `twitter.user_tweets_and_replies` | — | Get and paginate user's tweets and replies |
|
|
260
|
+
| `twitter.user_media` | — | Get and paginate user's media posts |
|
|
261
|
+
| `twitter.tweet_detail` | — | Get tweet, full X Article content, and paginated replies |
|
|
262
|
+
| `twitter.search` | — | Search tweets with cursor and advanced filters |
|
|
263
|
+
| `twitter.followers` | — | Get user's followers |
|
|
264
|
+
| `twitter.following` | — | Get user's following |
|
|
265
|
+
| `twitter.retweeters` | — | Get tweet retweeters |
|
|
266
|
+
| `x-official.2_tweets` | POST | Post a tweet |
|
|
267
|
+
| `x-official.2_tweets_id` | DELETE | Delete a tweet |
|
|
268
|
+
| `x-official.2_users_id_likes` | POST | Like a tweet |
|
|
269
|
+
| `x-official.2_users_id_retweets` | POST | Retweet |
|
|
270
|
+
|
|
271
|
+
## Error Handling
|
|
272
|
+
|
|
273
|
+
- **OAuth Required** → Run `npx xapi-to oauth bind --provider twitter`
|
|
274
|
+
- **403 Forbidden** → Twitter account may have restrictions; check account status
|
|
275
|
+
- **Tweet too long** → Shorten to 280 chars (140 CJK)
|
|
276
|
+
- **User not found** → Check the screen_name spelling
|
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
# Weibo Guide
|
|
2
|
+
|
|
3
|
+
Complete guide for Weibo operations via xAPI — hot search, content search, user profiles, posts, comments, and media.
|
|
4
|
+
|
|
5
|
+
> **Dynamic catalog:** These are database-registered third-party APIs under the `weibo-app` service. Exact action IDs, HTTP methods, parameters, and response fields can change. Run `search` and `get` before calling; the current schema wins. Examples below reflect one known GET-based version and keep `"method":"GET"` in the input for compatibility.
|
|
6
|
+
|
|
7
|
+
## Contents
|
|
8
|
+
|
|
9
|
+
- [Hot search](#hot-search-热搜)
|
|
10
|
+
- [Search](#search-搜索)
|
|
11
|
+
- [User data](#user-data-用户)
|
|
12
|
+
- [Post data](#post-data-博文)
|
|
13
|
+
- [Media](#media-多媒体)
|
|
14
|
+
- [Feed](#feed-信息流)
|
|
15
|
+
- [Common workflows](#common-workflows)
|
|
16
|
+
- [API reference](#api-reference)
|
|
17
|
+
- [Error handling](#error-handling)
|
|
18
|
+
|
|
19
|
+
## Hot Search (热搜)
|
|
20
|
+
|
|
21
|
+
### Get trending hot search
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npx xapi-to call weibo-app.api_v1_weibo_app_fetch__hot__search \
|
|
25
|
+
--input '{"method":"GET","params":{"category":"realtimehot"}}'
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
The `category` parameter selects which trending list to fetch:
|
|
29
|
+
|
|
30
|
+
| Value | Category |
|
|
31
|
+
|-------|----------|
|
|
32
|
+
| `realtimehot` | 热搜(default) |
|
|
33
|
+
| `social` | 社会 |
|
|
34
|
+
| `fun` | 文娱 |
|
|
35
|
+
| `technologynav` | 科技 |
|
|
36
|
+
| `lifenav` | 生活 |
|
|
37
|
+
| `region` | 同城 |
|
|
38
|
+
| `sportnav` | 体育 |
|
|
39
|
+
| `gamenav` | ACG |
|
|
40
|
+
|
|
41
|
+
Results are in `data.data.items[]`, which contains multiple groups. Filter for the group with `type: "vertical"` and ~50 sub-items — this is the main hot search list. Each entry has `data.desc` (topic title) and `data.scheme` (deep link). A separate "实时上升热点" group (preceded by a text label) lists ~20 rapidly rising topics.
|
|
42
|
+
|
|
43
|
+
**Note:** The `count` and `page` parameters are accepted (count max 50) but do not affect the number of results — the full list is always returned.
|
|
44
|
+
|
|
45
|
+
### Get hot search categories
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npx xapi-to call weibo-app.api_v1_weibo_app_fetch__hot__search__categories \
|
|
49
|
+
--input '{"method":"GET"}'
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
No parameters needed. Returns available trending category metadata.
|
|
53
|
+
|
|
54
|
+
## Search (搜索)
|
|
55
|
+
|
|
56
|
+
### Comprehensive search
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
npx xapi-to call weibo-app.api_v1_weibo_app_fetch__search__all \
|
|
60
|
+
--input '{"method":"GET","params":{"query":"AI","search_type":1,"page":1}}'
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Pagination: `page` is an integer.
|
|
64
|
+
|
|
65
|
+
The `search_type` parameter controls what to search for:
|
|
66
|
+
|
|
67
|
+
| Value | Type |
|
|
68
|
+
|-------|------|
|
|
69
|
+
| `1` | Comprehensive (综合) |
|
|
70
|
+
| `61` | Real-time (实时) |
|
|
71
|
+
| `3` | Users (用户) |
|
|
72
|
+
| `64` | Videos (视频) |
|
|
73
|
+
| `63` | Images (图片) |
|
|
74
|
+
| `62` | Followed (关注) |
|
|
75
|
+
| `60` | Trending (热门) |
|
|
76
|
+
| `21` | All platforms (全站) |
|
|
77
|
+
| `38` | Topics (话题) |
|
|
78
|
+
| `98` | Super topics (超话) |
|
|
79
|
+
| `92` | Locations (地点) |
|
|
80
|
+
| `97` | Products (商品) |
|
|
81
|
+
|
|
82
|
+
Results are in `data.data.items[]`, which mixes different `category` types. Filter for items with `category: "feed"` to get posts — their data is in the `.data` sub-object with fields: `text` (HTML), `user`, `created_at`, `reposts_count`, `comments_count`, `attitudes_count`. Items with `category: "group"` are UI elements (e.g. user cards, topic cards) and can be skipped.
|
|
83
|
+
|
|
84
|
+
### AI smart search
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
npx xapi-to call weibo-app.api_v1_weibo_app_fetch__ai__smart__search \
|
|
88
|
+
--input '{"method":"GET","params":{"query":"人工智能","page":1}}'
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
AI-powered search that returns curated results. Supports pagination via `page`.
|
|
92
|
+
|
|
93
|
+
## User Data (用户)
|
|
94
|
+
|
|
95
|
+
### Get user profile
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
npx xapi-to call weibo-app.api_v1_weibo_app_fetch__user__info \
|
|
99
|
+
--input '{"method":"GET","params":{"uid":"1669879400"}}'
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
The `uid` is the numeric Weibo user ID. Returns user info at `data.data.header.data.userInfo` with fields including `screen_name`, `description`, `domain`, `lang`, `status`, and more.
|
|
103
|
+
|
|
104
|
+
**How to find a uid:** Use `fetch_search_all` with `search_type: 3` (user search) to look up a user by name, then extract `uid` from the results.
|
|
105
|
+
|
|
106
|
+
### Get user detailed profile
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
npx xapi-to call weibo-app.api_v1_weibo_app_fetch__user__info__detail \
|
|
110
|
+
--input '{"method":"GET","params":{"uid":"1669879400"}}'
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Returns extended profile at `data.data.userInfo` with additional fields beyond `fetch_user_info`: verification details, badge info, credit score, `urank`, `mbrank`, etc. Also includes `items` sections with structured profile details (education, work history).
|
|
114
|
+
|
|
115
|
+
### Get user timeline (博文列表)
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
npx xapi-to call weibo-app.api_v1_weibo_app_fetch__user__timeline \
|
|
119
|
+
--input '{"method":"GET","params":{"uid":"1669879400","page":1}}'
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Results are in `data.data.items[]`, which mixes different `category` types. Filter for items with `category: "feed"` to get posts — their data is in the `.data` sub-object with fields: `mid` (post ID), `text` (HTML), `created_at`, `reposts_count`, `comments_count`, `attitudes_count`, `user`. Items with `category: "card"` are UI elements and can be skipped.
|
|
123
|
+
|
|
124
|
+
Optional parameters:
|
|
125
|
+
- `page` — page number, integer (default 1)
|
|
126
|
+
- `filter_type` — filter type, e.g. `"all"`
|
|
127
|
+
- `month` — time filter in YYYYMM format (e.g. `"202604"`)
|
|
128
|
+
|
|
129
|
+
### Get user articles (头条文章)
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
npx xapi-to call weibo-app.api_v1_weibo_app_fetch__user__articles \
|
|
133
|
+
--input '{"method":"GET","params":{"uid":"1669879400"}}'
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Paginate with `since_id` (cursor from previous response).
|
|
137
|
+
|
|
138
|
+
### Get user super topics (超话)
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
npx xapi-to call weibo-app.api_v1_weibo_app_fetch__user__super__topics \
|
|
142
|
+
--input '{"method":"GET","params":{"uid":"1669879400","page":1}}'
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## Post Data (博文)
|
|
146
|
+
|
|
147
|
+
### Get post detail
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
npx xapi-to call weibo-app.api_v1_weibo_app_fetch__status__detail \
|
|
151
|
+
--input '{"method":"GET","params":{"status_id":"5284850937629474"}}'
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
The `status_id` is the numeric post ID (same as `mid`). Returns post data at `data.data.detailInfo.status` with: `id`, `mid`, `text`, `created_at`, `source`, `reposts_count`, `comments_count`, `attitudes_count`, `user`.
|
|
155
|
+
|
|
156
|
+
### Get post comments (评论)
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
npx xapi-to call weibo-app.api_v1_weibo_app_fetch__status__comments \
|
|
160
|
+
--input '{"method":"GET","params":{"status_id":"5284850937629474","sort_type":"0"}}'
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
`sort_type`: `"0"` = sort by popularity, `"1"` = sort by time. Paginate with `max_id` cursor.
|
|
164
|
+
|
|
165
|
+
### Get post reposts (转发)
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
npx xapi-to call weibo-app.api_v1_weibo_app_fetch__status__reposts \
|
|
169
|
+
--input '{"method":"GET","params":{"status_id":"5284850937629474"}}'
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
Paginate with `max_id` cursor.
|
|
173
|
+
|
|
174
|
+
### Get post likes (点赞)
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
npx xapi-to call weibo-app.api_v1_weibo_app_fetch__status__likes \
|
|
178
|
+
--input '{"method":"GET","params":{"status_id":"5284850937629474","attitude_type":"0"}}'
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
`attitude_type` values: `"0"` = all, `"1"` = like, `"2"` = happy, `"3"` = surprised, `"4"` = sad, `"5"` = angry, `"6"` = tip, `"8"` = hug.
|
|
182
|
+
|
|
183
|
+
## Media (多媒体)
|
|
184
|
+
|
|
185
|
+
### Get user photos (相册)
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
npx xapi-to call weibo-app.api_v1_weibo_app_fetch__user__album \
|
|
189
|
+
--input '{"method":"GET","params":{"uid":"1669879400"}}'
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
Paginate with `since_id`.
|
|
193
|
+
|
|
194
|
+
### Get user videos
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
npx xapi-to call weibo-app.api_v1_weibo_app_fetch__user__videos \
|
|
198
|
+
--input '{"method":"GET","params":{"uid":"1669879400"}}'
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Paginate with `since_id`.
|
|
202
|
+
|
|
203
|
+
### Get user audio
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
npx xapi-to call weibo-app.api_v1_weibo_app_fetch__user__audios \
|
|
207
|
+
--input '{"method":"GET","params":{"uid":"1669879400"}}'
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
Paginate with `since_id`.
|
|
211
|
+
|
|
212
|
+
### Get video detail
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
npx xapi-to call weibo-app.api_v1_weibo_app_fetch__video__detail \
|
|
216
|
+
--input '{"method":"GET","params":{"mid":"5284850937629474"}}'
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
Returns video post data at `data.data.status`.
|
|
220
|
+
|
|
221
|
+
### Get featured video feed
|
|
222
|
+
|
|
223
|
+
```bash
|
|
224
|
+
npx xapi-to call weibo-app.api_v1_weibo_app_fetch__video__featured__feed \
|
|
225
|
+
--input '{"method":"GET","params":{}}'
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
For page 2+, pass `"page": "2"` (**string**, not integer). First page should omit the `page` param.
|
|
229
|
+
|
|
230
|
+
## Feed (信息流)
|
|
231
|
+
|
|
232
|
+
### Get home recommend feed
|
|
233
|
+
|
|
234
|
+
```bash
|
|
235
|
+
npx xapi-to call weibo-app.api_v1_weibo_app_fetch__home__recommend__feed \
|
|
236
|
+
--input '{"method":"GET","params":{"count":15}}'
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
Returns recommended posts from the Weibo homepage feed. For page 2+, pass `"page": "2"` (**string**, not integer). First page should omit `page`.
|
|
240
|
+
|
|
241
|
+
### Get user homepage feed
|
|
242
|
+
|
|
243
|
+
```bash
|
|
244
|
+
npx xapi-to call weibo-app.api_v1_weibo_app_fetch__user__profile__feed \
|
|
245
|
+
--input '{"method":"GET","params":{"uid":"1669879400"}}'
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
Returns the user's profile page feed (UI-oriented). For post data, prefer `fetch_user_timeline`. Paginate with `since_id`.
|
|
249
|
+
|
|
250
|
+
## Common Workflows
|
|
251
|
+
|
|
252
|
+
### Monitor trending topics
|
|
253
|
+
|
|
254
|
+
1. Fetch hot search: `weibo-app.api_v1_weibo_app_fetch__hot__search` with `category: "realtimehot"` → get top 50 topics
|
|
255
|
+
2. Search a topic: `weibo-app.api_v1_weibo_app_fetch__search__all` with `query: "<topic>"` → find relevant posts
|
|
256
|
+
3. Get post details: `weibo-app.api_v1_weibo_app_fetch__status__detail` → read full content and engagement
|
|
257
|
+
|
|
258
|
+
### Research a Weibo user
|
|
259
|
+
|
|
260
|
+
1. Search user: `weibo-app.api_v1_weibo_app_fetch__search__all` with `search_type: 3` and `query: "<name>"` → find uid
|
|
261
|
+
2. Get profile: `weibo-app.api_v1_weibo_app_fetch__user__info` → basic info (followers, bio, verification)
|
|
262
|
+
3. Get timeline: `weibo-app.api_v1_weibo_app_fetch__user__timeline` → recent posts with engagement stats
|
|
263
|
+
4. Get media: `weibo-app.api_v1_weibo_app_fetch__user__album` / `weibo-app.api_v1_weibo_app_fetch__user__videos` → photos and videos
|
|
264
|
+
|
|
265
|
+
### Analyze post engagement
|
|
266
|
+
|
|
267
|
+
1. Get post: `weibo-app.api_v1_weibo_app_fetch__status__detail` → reposts_count, comments_count, attitudes_count
|
|
268
|
+
2. Read comments: `weibo-app.api_v1_weibo_app_fetch__status__comments` with `sort_type: "0"` → top comments
|
|
269
|
+
3. Check reposts: `weibo-app.api_v1_weibo_app_fetch__status__reposts` → who reposted
|
|
270
|
+
4. Check likes: `weibo-app.api_v1_weibo_app_fetch__status__likes` → who liked
|
|
271
|
+
|
|
272
|
+
## API Reference
|
|
273
|
+
|
|
274
|
+
| API | Description | Key Params |
|
|
275
|
+
|-----|-------------|------------|
|
|
276
|
+
| `weibo-app.api_v1_weibo_app_fetch__hot__search` | Hot search trending list | `category` |
|
|
277
|
+
| `weibo-app.api_v1_weibo_app_fetch__hot__search__categories` | Hot search categories | — |
|
|
278
|
+
| `weibo-app.api_v1_weibo_app_fetch__search__all` | Comprehensive search | `query`, `search_type`, `page` |
|
|
279
|
+
| `weibo-app.api_v1_weibo_app_fetch__ai__smart__search` | AI smart search | `query`, `page` |
|
|
280
|
+
| `weibo-app.api_v1_weibo_app_fetch__user__info` | User basic profile | `uid` |
|
|
281
|
+
| `weibo-app.api_v1_weibo_app_fetch__user__info__detail` | User extended profile | `uid` |
|
|
282
|
+
| `weibo-app.api_v1_weibo_app_fetch__user__timeline` | User's posts | `uid`, `page` |
|
|
283
|
+
| `weibo-app.api_v1_weibo_app_fetch__user__profile__feed` | User homepage feed | `uid`, `since_id` |
|
|
284
|
+
| `weibo-app.api_v1_weibo_app_fetch__user__articles` | User's articles | `uid`, `since_id` |
|
|
285
|
+
| `weibo-app.api_v1_weibo_app_fetch__user__super__topics` | User's super topics | `uid`, `page` |
|
|
286
|
+
| `weibo-app.api_v1_weibo_app_fetch__status__detail` | Post detail | `status_id` |
|
|
287
|
+
| `weibo-app.api_v1_weibo_app_fetch__status__comments` | Post comments | `status_id`, `sort_type` |
|
|
288
|
+
| `weibo-app.api_v1_weibo_app_fetch__status__reposts` | Post reposts | `status_id`, `max_id` |
|
|
289
|
+
| `weibo-app.api_v1_weibo_app_fetch__status__likes` | Post likes | `status_id`, `attitude_type` |
|
|
290
|
+
| `weibo-app.api_v1_weibo_app_fetch__user__album` | User photos | `uid`, `since_id` |
|
|
291
|
+
| `weibo-app.api_v1_weibo_app_fetch__user__videos` | User videos | `uid`, `since_id` |
|
|
292
|
+
| `weibo-app.api_v1_weibo_app_fetch__user__audios` | User audio | `uid`, `since_id` |
|
|
293
|
+
| `weibo-app.api_v1_weibo_app_fetch__video__detail` | Video detail | `mid` |
|
|
294
|
+
| `weibo-app.api_v1_weibo_app_fetch__video__featured__feed` | Featured videos | `page` |
|
|
295
|
+
| `weibo-app.api_v1_weibo_app_fetch__home__recommend__feed` | Home recommend feed | `count`, `page` |
|
|
296
|
+
|
|
297
|
+
## Error Handling
|
|
298
|
+
|
|
299
|
+
- **422 Validation Error** → Check parameter types and ranges (e.g. `count` must be 1–50)
|
|
300
|
+
- **Empty results** → Verify `uid` or `status_id` is correct; use search to find valid IDs
|
|
301
|
+
- **Pagination** → Use `since_id` (cursor) or `page` depending on the endpoint; check response for next cursor value
|