# Mastodon 话题内容 API (mastodon.hashtag)

- Canonical page: [https://everyinfra.com/mastodon-api/hashtag](https://everyinfra.com/mastodon-api/hashtag?utm_medium=ai_doc&utm_campaign=page_md)
- Endpoint: POST https://api.everyinfra.com/api/v1/social with {"platform": "mastodon", "action": "hashtag", "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 100 per call
- Mode: sync; add "mode": "async" for slow tasks

话题内容按 `hashtag` 读取一个 Mastodon 实例上某个标签下的帖子，标签词不带 #。每条带正文、作者、`like_count`、`reblog_count`、`comment_count`、`language`、`media_urls` 和 `hashtags`。它回答「这个话题在这个实例上大家在聊什么」，适合监测一个话题的走向，或者找某个话题下活跃的创作者。

读取范围是 `instance` 指定的那一个实例，不传默认 mastodon.social。结果不包含转嘟和回复，也不是联邦全网这个标签的完整样本。不传 `limit` 时每次读 20 条，上限 100 条。

## Health

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

## Parameters

| name | type | required | default | description |
|---|---|---|---|---|
| hashtag | not declared | yes | not declared | 标签词，不带 #，在指定 instance 上读取话题流。不包含转嘟与回复，不能把它当作联邦全网标签的完整样本。 |
| instance | not declared | no | not declared | Mastodon 实例域名，不带协议或路径。timeline 默认 fosstodon.org，其他入口默认 mastodon.social；显式 instance 优先于 username 中的实例，因此二者应保持一致。 |
| limit | integer (1–100) | no | 20 | 这次调用最多返回的条数，整数，1–100；不传按默认值，实际返回可能少于这个数。超过上限会在扣费前返回 422。 |

## Response fields (items in `results`)

| field | meaning |
|---|---|
| id | 该记录在原平台上的唯一标识。仅在同一平台内唯一，跨平台可能重复。 |
| url | 该记录在原平台上的可访问链接。 |
| text | 正文内容，已去除 HTML 标签，全文返回、不截断（个别平台的列表结果本身只有摘要，以该平台的字段说明为准）。 |
| author_name | 作者昵称（显示名）。 |
| author_username | 作者用户名（@handle），通常可用于拼 URL。 |
| author_url | 作者在原平台的主页链接。 |
| instance | 所属实例域名。 |
| like_count | 点赞数。null 表示该平台或该接口不公开此数据，不等于 0。 |
| reblog_count | 转嘟数。 |
| comment_count | 评论数。null 表示不公开，不等于 0。 |
| language | 内容语言代码（如 zh、en），由平台判定，可能不准。 |
| is_reblog | 是否为转嘟（Mastodon 的转发）。 |
| posted_at | 发布时间，ISO 8601 格式、UTC 时区（如 2026-08-07T12:34:56+00:00）。平台只给非标准字符串时原样透传，解析前建议做容错。null 表示平台未公开。 |
| platform | 数据来源平台标识，与请求里的 platform 一致（如 xiaohongshu、tiktok）。 |
| media_urls | platform-native meaning |
| hashtags | 正文里的话题标签数组，按出现顺序；没有时不出现这个字段。 |

## 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": "mastodon",
  "action": "hashtag",
  "params": {
    "hashtag": "art"
  }
}'
```

```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": "mastodon",
        "action": "hashtag",
        "params": {
            "hashtag": "art",
        },
    },
    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 40. `id`, `billing` and `quota` differ on every call, so only their shape is shown.

```text
{
  "id": "req_…",
  "platform": "mastodon",
  "action": "hashtag",
  "results": [
    {
      "id": "•••",
      "url": "https://pixelfed.social/p/fabdsp/1009398452348448480",
      "author_name": "•••",
      "author_username": "•••",
      "author_url": "https://pixelfed.social/•••",
      "instance": "mastodon.social",
      "posted_at": "2026-09-26T09:49:04+00:00",
      "platform": "mastodon",
      "hashtags": [
        "art",
        "painting",
        "drawing"
      ]
    },
    {
      "id": "•••",
      "url": "https://flipboard.com/@•••/flipboard-exchange-feed-%F0%9F%97%9E%EF%B8%8F-a2ri49sqz/-/a-mINcnEnIQd-kH_gnIO7qQA%3Aa%3A4091604380-%2F0",
      "author_name": "•••",
      "author_username": "•••",
      "author_url": "https://flipboard.com/•••",
      "instance": "mastodon.social",
      "language": "en",
      "posted_at": "2026-09-26T09:48:57+00:00",
      "platform": "mastodon",
      "hashtags": [
        "art",
        "culture",
        "exhibitions"
      ]
    }
  ],
  "count": 40,
  "billing": {
    "charged": …,
    "charged_usd": …,
    "balance_after_usd": …,
    …
  },
  "quota": { … }
}
```

## FAQ

### 为什么读不到某些转嘟和回复？

这一页读的是指定实例上的话题流，里面不包含转嘟与回复。所以它反映的是原创帖子的情况，不是这个标签在联邦全网的完整样本。做声量统计时，要在报告里写明读取的实例和这个限制。

### `instance` 怎么填？

填实例的域名，不带协议或路径，例如 mastodon.social 这种写法。不传时默认 mastodon.social。想比较同一个话题在不同实例上的热度，就换 `instance` 各调一次，再自己合并。各实例返回的 `posted_at` 都是 UTC 时间，合并后可以直接按时间排。

### 话题内容和用户内容怎么选？

已知话题、不知道谁在发，用这一页，传 `hashtag`。已知账号、要读它发了什么，用用户内容，传账号名，写法可以是 user@instance。两页的字段和条数上限相同，所以拿到话题里活跃的作者后，可以接着读他的用户内容。

## Also

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