# Lemmy 社区资料 API (lemmy.community)

- Canonical page: [https://everyinfra.com/lemmy-api/community](https://everyinfra.com/lemmy-api/community?utm_medium=ai_doc&utm_campaign=page_md)
- Endpoint: POST https://api.everyinfra.com/api/v1/social with {"platform": "lemmy", "action": "community", "params": {...}}
- Price: $0.001389 per call ($1.39 per 1,000 requests); failed calls and empty results are not charged
- Returns: list, default 20, max 200 per call
- Mode: sync; add "mode": "async" for slow tasks

要盯 Lemmy 上的某一个社区，用社区资料：按 `community` 列出这个社区的帖子，默认 20 条，单次最多 200 条。每条帖子带净得分 `score` 以及拆开的顶数 `upvote_count`、踩数 `downvote_count`，还有评论数。它回答「这个社区最近在聊什么、哪些帖子得分高」，适合盯一个技术或兴趣社区的动向，或者给选题收集社区里的讨论。

`community` 写社区名，也可以写 technology@lemmy.world 这样的 name@instance 形式。`instance` 默认 lemmy.world，决定从哪台服务器发起查询，社区名仍然写在 `community` 里。不传 `sort` 时按 `hot` 排。

## Health

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

## Parameters

| name | type | required | default | description |
|---|---|---|---|---|
| community | not declared | yes | not declared | Lemmy 社区名或 name@instance 形式的跨实例社区标识。community 列社区帖子；comments 按社区读取帖子并展开评论，不是直接按单个帖子 URL 查询。 |
| instance | not declared | no | not declared | Lemmy 实例域名，例如 lemmy.world，默认 lemmy.world；可以传带协议的实例 URL，最终只保留主机名。它指定查询入口，不是社区名称。 |
| sort | enum: active / hot / most_comments / new / new_comments / top | no | not declared | 帖子排序：hot 热门、active 活跃、new 新帖、top 高分、most_comments 评论最多、new_comments 新评论活动。search/community 默认 hot，feed 默认 active，comments 默认 most_comments。 |
| top_range | enum: all / day / hour / month / ninemonths / sixhour / sixmonths / threemonths / twelvehour / week / year | no | not declared | 只在 sort=top 时生效的积分时间窗：hour 1 小时、sixhour 6 小时、twelvehour 12 小时、day 1 天、week 1 周（默认）、month 1 月、threemonths 3 月、sixmonths 6 月、ninemonths 9 月、year 1 年、all 全部。不是评论发布时间过滤。 |
| limit | integer (1–200) | no | 20 | 这次调用最多返回的条数，整数，1–200；不传按默认值，实际返回可能少于这个数。超过上限会在扣费前返回 422。 |

## Response fields (items in `results`)

| field | meaning |
|---|---|
| id | 该记录在原平台上的唯一标识。仅在同一平台内唯一，跨平台可能重复。 |
| title | 标题。平台无标题概念时（如纯文本帖）为 null。 |
| body | 正文。 |
| url | 该记录在原平台上的可访问链接。 |
| external_url | 帖子指向的外部链接。 |
| community | 社区名。 |
| community_url | 社区链接。 |
| instance | 所在实例(服务器)。Lemmy 是联邦宇宙社区，同名社区可存在于不同实例。 |
| author_username | 作者用户名（@handle），通常可用于拼 URL。 |
| author_url | 作者在原平台的主页链接。 |
| score | 净得分（顶减踩）。 |
| upvote_count | 顶数。 |
| downvote_count | 踩数。 |
| comment_count | 评论数。null 表示不公开，不等于 0。 |
| thumbnail_url | 缩略图链接，分辨率低于 image_url。 |
| embed_title | 外链的标题。 |
| is_nsfw | 是否为成人内容。 |
| is_locked | 是否锁定（禁止新评论）。 |
| is_featured | 是否为置顶精选。 |
| posted_at | 发布时间，ISO 8601 格式、UTC 时区（如 2026-08-07T12:34:56+00:00）。平台只给非标准字符串时原样透传，解析前建议做容错。null 表示平台未公开。 |
| updated_at | 编辑时间。 |
| 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": "lemmy",
  "action": "community",
  "params": {
    "community": "technology@lemmy.world"
  }
}'
```

```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": "lemmy",
        "action": "community",
        "params": {
            "community": "technology@lemmy.world",
        },
    },
    timeout=120,
)
print(response.status_code)
print(response.json())
```

## Response example

Real response to the example request above, captured 2026-09-26T08:56:04Z. `results` and `count` are real with personal information (names, handles, avatars, profile links, contact details) removed; the list keeps the first 2 of 20. `id`, `billing` and `quota` differ on every call, so only their shape is shown.

```text
{
  "id": "req_…",
  "platform": "lemmy",
  "action": "community",
  "results": [
    {
      "id": "73849259",
      "title": "I don't like passkeys | Ethan Hawksley",
      "body": "",
      "url": "https://reddthat.com/post/73849259",
      "external_url": "https://hawksley.dev/blog/i-dont-like-passkeys",
      "community": "technology",
      "community_url": "https://lemmy.world/c/technology",
      "instance": "lemmy.world",
      "author_username": "•••",
      "author_url": "https://reddthat.com/•••",
      "score": 43,
      "upvote_count": 43,
      "downvote_count": 0,
      "comment_count": 13,
      "thumbnail_url": "https://lemmy.world/pictrs/image/ff83aff0-6ad8-4dac-93d6-3bc95e681b92.jpeg",
      "embed_title": "I don't like passkeys | Ethan Hawksley",
      "is_nsfw": false,
      "is_locked": false,
      "is_featured": false,
      "posted_at": "2026-09-26T07:42:38.916014+00:00",
      "platform": "lemmy"
    },
    {
      "id": "73847026",
      "title": "A German ISP tampered with their DNS - specifically to sabotage my website (lina.sh)",
      "body": "a year old, but interesting to read",
      "url": "https://reddthat.com/post/73847026",
      "external_url": "https://lina.sh/blog/telefonica-sabotages-me",
      "community": "technology",
      "community_url": "https://lemmy.world/c/technology",
      "instance": "lemmy.world",
      "author_username": "•••",
      "author_url": "https://reddthat.com/•••",
      "score": 107,
      "upvote_count": 107,
      "downvote_count": 0,
      "comment_count": 2,
      "thumbnail_url": "https://lemmy.world/pictrs/image/84c73d7d-3d66-482e-bd62-514e1d5c3970.png",
      "embed_title": "A German ISP tampered with their DNS - specifically to sabotage my website",
      "is_nsfw": false,
      "is_locked": false,
      "is_featured": false,
      "posted_at": "2026-09-26T06:28:03.315923+00:00",
      "platform": "lemmy"
    }
  ],
  "count": 20,
  "billing": {
    "charged": …,
    "charged_usd": …,
    "balance_after_usd": …,
    …
  },
  "quota": { … }
}
```

## FAQ

### 社区资料和信息流有什么不同？

范围不同。社区资料只读 `community` 指定的那一个社区，单次最多 200 条，默认按 `hot` 排；信息流不填社区，上限 100 条，默认按活跃度排。在信息流里发现某个社区帖子多，把它的社区名连同实例写成 name@instance 交给 `community`，就能单独把这个社区拉下来，按它自己的热度和得分重新看一遍。

### `top_range` 什么时候有用？

只在 `sort` 为 `top` 时生效，用来选积分的时间窗，从 `hour` 到 `all`，不传就是 `week`。它是积分统计的时间窗，不是按评论发布时间筛选。盯一个社区时，`top` 配 `day` 按 1 天的时间窗排高分帖，配 `month` 或 `year` 看更长时间窗里的高分帖；中间还有 `sixhour`、`threemonths`、`ninemonths` 等档位。

### 同名社区在不同实例上怎么区分？

用 name@instance 形式传给 `community`，比如 technology@lemmy.world。返回行里的 `instance` 标出帖子所在的实例，`community_url` 是社区链接。Lemmy 是联邦宇宙社区，同名社区可存在于不同实例。

## Also

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