# 今日头条 API | Toutiao Search, Comments & User Posts (`socialdatax/socialdatax-toutiao-data-api`) Actor

社媒数据助手 SocialDataX 提供只读今日头条数据：内容与用户搜索、详情、评论与回复、资料、作品、热榜和搜索建议。 Search Toutiao content and users; get details, comments, replies, profiles, creator posts, trending topics and search suggestions. 导出 JSON、CSV、Excel；无需配置 SocialDataX API Key。

- **URL**: https://apify.com/socialdatax/socialdatax-toutiao-data-api.md
- **Developed by:** [SocialDataX](https://apify.com/socialdatax) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.99 / 1,000 dataset items

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## 今日头条数据 API | SocialDataX Toutiao

社媒数据助手 SocialDataX 提供只读今日头条 / Toutiao 数据：内容搜索、内容详情、评论与回复、用户搜索、用户资料、用户作品、热榜和搜索建议。结果写入 Apify Dataset，可导出 JSON、CSV、Excel；无需填写 SocialDataX API Key。

Search Toutiao content and users; get details, comments, replies, profiles, creator posts, trending topics and search suggestions.

### 价格

每 1,000 条 Dataset 结果 **$3.99**，即每条 $0.00399，所有操作统一计价。每个启动事件另收 $0.00005，按 Apify 的内存计费规则计算；运行中的平台费用包含在上述价格中。仅成功写入 Dataset 的结果按条计费；空结果不产生结果费用，启动事件仍可能收费。

持续使用需要 Apify 付费计划；免费计划有 5 次 SocialDataX API 请求试用额度，一次自动翻页或重试也会消耗请求额度。Apify 的免费赠送额度与本 Actor 的试用请求限制分别计算。

### 选择能力

| operation | 必填字段 | 可选字段 |
| --- | --- | --- |
| `search_posts` | `keyword` | `page_token`, `max_items`, `auto_paginate` |
| `search_users` | `keyword` | `page_token`, `max_items`, `auto_paginate` |
| `search_suggestions` | `keyword` | `max_items` |
| `get_hot_search_list` | 无 | `max_items` |
| `get_post_detail` | `post_id` | 无 |
| `get_post_comments` | `post_id` | `page_token`, `max_items`, `auto_paginate` |
| `get_comment_replies` | `comment_id` | `page_token`, `max_items`, `auto_paginate` |
| `get_user_info` | `user_id` | 无 |
| `list_user_posts` | `user_id` | `content_type`, `page_token`, `max_items`, `auto_paginate` |

- 内容搜索使用“只看头条”范围；搜索摘要不代表完整正文。已有 ID 或链接时，直接查询详情。
- `post_id` 支持内容 ID、完整内容链接或包含链接的分享文案。请从搜索或用户作品结果复制 ID。
- `user_id` 支持数字用户 ID、用户主页链接或包含主页链接的分享文案；不接受内容链接。
- 评论回复的 `comment_id` 取自一级评论结果。选择 `has_replies=true` 的评论，不要传内容 ID 或回复项自身的 ID。
- 通过 JSON 提交 ID 时请使用字符串，例如 `"7666443607460676134"`，以保留完整数值。数字输入只兼容安全整数，超出范围或带小数时会直接报错。
- 用户作品 `content_type` 支持 `all`、`article`、`video`、`micro_post`。`is_pinned` 保留主页置顶状态，不重新排序。

### 示例

```json
{
  "operation": "search_posts",
  "keyword": "美食",
  "max_items": 20,
  "auto_paginate": true
}
```

用户作品：

```json
{
  "operation": "list_user_posts",
  "user_id": "https://www.toutiao.com/c/user/5003463346/",
  "content_type": "all",
  "max_items": 20,
  "auto_paginate": false
}
```

### 分页和输出

默认最多导出 20 条，最大 1,000 条。开启自动翻页后，按 `next_page_token` 继续请求；空页有下一页令牌时也会继续，空页不写入 Dataset。热榜、搜索建议、详情和资料只请求一次。热榜将普通热点与平台置顶内容分别导出为行，通过 `is_pinned` 区分，二者共同计入结果上限。

Dataset 中作者和视频对象展开为 `author_*`、`video_*` 字段，图片数组保留；每行包含查询条件、页序号与 `page_next_page_token`。手工续页需要复制完整令牌，保持操作及搜索词、内容、用户和作品类型一致。令牌对应下一整页；如果结果上限截断了当前页，使用该令牌将跳过当前页未导出的结果，`OUTPUT.warnings` 会说明此情况。

默认 Dataset 结果链接导出完整字段，包含后续查询所需的 ID、链接和分页令牌；Console 中的分类表格用于预览。一级评论行的 `comment_id` 可用于查询回复；回复行的 `comment_id` 标识回复自身，查询所属评论的回复时使用 `parent_comment_id`。

`OUTPUT` 包含 `operation`、`itemCount`、`requestCount`、每页摘要和警告。每个 `pages` 项保存该页完整的 `next_page_token`；关闭自动翻页且当前页为空时，也可从这里复制令牌继续查询。令牌为空表示没有下一页，续页仍须保持原查询条件；当前页被截断时，续页同样会跳过未导出的条目。`requestCount` 包含重试；失败时保留已完成请求次数和已确认写入的结果数，不将失败视为正常空结果。

支持与接入：[SocialDataX](https://socialdatax.com/ai?from=apify)。

# Actor input Schema

## `operation` (type: `string`):

先选择能力，只填写该操作需要的字段。

## `keyword` (type: `string`):

内容搜索、用户搜索、搜索建议必填；例如美食、NBA。不要填内容链接或用户主页。

## `post_id` (type: `string`):

内容详情和一级评论必填。支持内容 ID、完整头条内容链接或包含链接的分享文案；可从搜索结果复制 post_id。

## `comment_id` (type: `string`):

评论回复必填。先查询一级评论，复制 has_replies=true 的评论行 comment_id；不要填内容 ID 或回复项自身的 ID。

## `user_id` (type: `string`):

用户资料和用户作品必填。支持数字用户 ID、用户主页链接或包含主页链接的分享文案；不要填内容链接。

## `content_type` (type: `string`):

仅用于用户作品：all=全部、article=文章、video=视频、micro_post=微头条。

## `page_token` (type: `string`):

第一页留空；续页原样传入同一操作上一页返回的完整 next_page_token。保持搜索词、内容、用户和作品类型不变。热榜与搜索建议不分页。

## `max_items` (type: `integer`):

搜索、列表、评论、热榜和搜索建议的总导出上限；详情和资料每次最多1条。每条实际写入 Dataset 的结果按 $0.00399 计费，另有启动费。

## `auto_paginate` (type: `boolean`):

开启后按 next_page_token 继续请求，直到达到结果上限或没有下一页；空页有令牌时仍会继续。关闭时只取当前页。热榜和搜索建议只请求一次。

## Actor input object example

```json
{
  "operation": "search_posts",
  "keyword": "美食",
  "content_type": "all",
  "max_items": 20,
  "auto_paginate": true
}
```

# Actor output Schema

## `dataset` (type: `string`):

Open flat result rows written to the default Apify Dataset. Export as JSON, CSV, Excel / XLSX, or JSONL.

## `keyValueStore` (type: `string`):

Open the default key-value store. The OUTPUT record contains operation, item count, request count, page-level response summaries, non-fatal warnings, and lightweight failure details when a run fails.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {};

// Run the Actor and wait for it to finish
const run = await client.actor("socialdatax/socialdatax-toutiao-data-api").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {}

# Run the Actor and wait for it to finish
run = client.actor("socialdatax/socialdatax-toutiao-data-api").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{}' |
apify call socialdatax/socialdatax-toutiao-data-api --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,socialdatax/socialdatax-toutiao-data-api"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/kUwWABVcez4CQ5Wzt/builds/25TQ8agNCvzDD33bX/openapi.json
