# X (Twitter) 社群资料 API (twitter.community_info)

- Canonical page: https://everyinfra.com/twitter-api/community_info
- Endpoint: POST /api/v1/social with {"platform": "twitter", "action": "community_info", "params": {...}}
- Price: $0.000806 per call ($0.81 per 1,000 requests); failed and empty results are not charged
- Returns: single object
- Mode: sync; add "mode": "async" for slow tasks

社群资料按 `community_id` 读取一个 X 社群的档案，返回单个对象：名称、简介 `description`、主话题 `topic`、成员数 `member_count`、创建时间 `created_at`、是否标为成人内容 `is_nsfw`、横幅图 `banner_url`，还有 `rules`，也就是社群规则（每条的标题）。它回答「这个社群是做什么的、规矩是什么」，适合在入驻或监测前先摸清一个社群。

`community_id` 是 x.com/i/communities/ 后面的数字，也可以直接填社群链接，`url` 因此可以不传。这一页返回一个对象，没有翻页；要从关键词找候选社群，用社群搜索，那里不返回简介、创建时间和规则。

## Health

- Live health (24h percent, hourly and daily trends): https://api.everyinfra.com/api/v1/social/availability?platform=twitter&action=community_info

## Parameters

| name | type | required | default | description |
|---|---|---|---|---|
| community_id | not declared | yes | not declared | 社群（Communities）的数字 ID，即 x.com/i/communities/ 后的数字，也可填社群链接。 |
| url | not declared | no | not declared | 兼容写法，可以不传：社群链接直接填进必填的 community_id 即可；两个都填时以 community_id 为准。 |

## Response fields (items in `results`)

| field | meaning |
|---|---|
| id | 该记录在原平台上的唯一标识。仅在同一平台内唯一，跨平台可能重复。 |
| url | 该记录在原平台上的可访问链接。 |
| name | 名称。用于账号/商品/商家类能力，指该对象本身的名字。 |
| description | 简介或描述，通常比 text 短。 |
| topic | 社群的主话题（如 Finance）。 |
| member_count | platform-native meaning |
| is_nsfw | 社群是否标为成人内容。 |
| banner_url | 社群横幅图链接。 |
| created_at | 创建时间，格式同 posted_at。 |
| rules | 社群规则（每条的标题）。 |
| platform | 数据来源平台标识，与请求里的 platform 一致（如 xiaohongshu、tiktok）。 |

## Example

```bash
curl -X POST 'https://api.everyinfra.com/api/v1/social' \
  -H "Authorization: Bearer $EVERYINFRA_API_KEY" \
  -H 'Content-Type: application/json' \
  --data-raw '{
  "platform": "twitter",
  "action": "community_info",
  "params": {
    "community_id": "1508567430188126209"
  }
}'
```

```python
import os
import requests

response = requests.post(
    "https://api.everyinfra.com/api/v1/social",
    headers={"Authorization": f"Bearer {os.environ['EVERYINFRA_API_KEY']}"},
    json={
        "platform": "twitter",
        "action": "community_info",
        "params": {
            "community_id": "1508567430188126209",
        },
    },
    timeout=120,
)
print(response.status_code)
print(response.json())
```

## Response example

No real sample for these example parameters yet: structure only, every value is a placeholder (…).

```text
{
  "id": "req_…",
  "platform": "twitter",
  "action": "community_info",
  "results": {
    "id": …,
    "url": …,
    "name": …,
    "description": …,
    "topic": …,
    "member_count": …,
    "is_nsfw": …,
    "banner_url": …,
    "created_at": …,
    "rules": …,
    "platform": …
  },
  "billing": {
    "charged": …,
    "charged_usd": …,
    "balance_after_usd": …,
    …
  },
  "quota": { … }
}
```

## FAQ

### `rules` 里能拿到规则全文吗？

拿不到。`rules` 只给每条社群规则的标题，没有规则的正文。标题能让你先了解这个社群有哪些规矩；要引用具体条文时，不能只靠这个字段。

### `description` 是帖子正文吗？

不是。`description` 是社群的简介或描述，通常比帖子正文短，这一页也不返回帖子。按社群介绍做分类、打标签时，取 `description` 并配合 `topic` 就够用；`is_nsfw` 标出社群是否为成人内容。

### 社群资料和社群搜索怎么分工？

已知社群 ID，要看这一个社群的细节，用这一页，一次一个对象。只有关键词，要找候选，用社群搜索，每页约 10 条。典型做法是先搜索，再把结果里的 `id` 拿来读资料，读 `member_count` 可以定期跟踪社群规模。

## Also

- Capability catalog (no key): https://api.everyinfra.com/api/v1/social/catalog?platform=twitter
- OpenAPI: https://everyinfra.com/openapi.json · Agents guide: https://everyinfra.com/agents.md
