# Telegram 频道内搜消息 API (telegram.search_in_channel)

- Canonical page: [https://everyinfra.com/telegram-api/search_in_channel](https://everyinfra.com/telegram-api/search_in_channel?utm_medium=ai_doc&utm_campaign=page_md)
- Endpoint: POST https://api.everyinfra.com/api/v1/social with {"platform": "telegram", "action": "search_in_channel", "params": {...}}
- Price: $0.000556 per call ($0.56 per 1,000 requests); failed calls and empty results are not charged
- Returns: list, default 20, max 100 per call (larger values are capped)
- Pagination: pass next_page_token back as page_token for the next page, other params unchanged; one call per page, tokens last 24 hours
- Mode: sync; add "mode": "async" for slow tasks

## Health

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

## Parameters

| name | type | required | default | description |
|---|---|---|---|---|
| username | not declared | yes | not declared | 要在里面搜的公开频道：name、@name、t.me/name 或 t.me/s/name。频道不存在时返回 200 和空结果，empty_reason 为 account_not_found，不扣费。 |
| keyword | not declared | yes | not declared | 关键词，最多 100 个字；用 Telegram 自己的频道内搜索，翻遍这个频道的全部历史，从新到旧。没有命中返回空列表，不扣费。 |
| page_token | not declared | no | not declared | 翻页令牌：把上一次响应里的 next_page_token 原样传回，拿下一页，其他参数和第一页一样；不传从第一页开始。每页算一次调用；没有 next_page_token 就是最后一页。 |
| limit | integer (1–100) | no | 20 | 正整数（≥1），本次最多返回的条数：不传则返回本次取到的全部结果，传了只把结果截短到这个条数以内，不会多取，也不会变多。扣费不受 `limit` 影响。 |

## Response fields (items in `results`)

| field | meaning |
|---|---|
| id | 该记录在原平台上的唯一标识。仅在同一平台内唯一，跨平台可能重复。 |
| url | 该记录在原平台上的可访问链接。 |
| channel_username | 频道用户名（@开头的公开标识）。 |
| channel_title | 频道名称。 |
| text | 正文内容，已去除 HTML 标签，全文返回、不截断（个别平台的列表结果本身只有摘要，以该平台的字段说明为准）。 |
| view_count | 浏览/播放数。null 表示不公开，不等于 0。 |
| posted_at | 发布时间，ISO 8601 格式、UTC 时区（如 2026-08-07T12:34:56+00:00）。平台只给非标准字符串时原样透传，解析前建议做容错。null 表示平台未公开。 |
| media_type | 媒体类型（照片/视频/文件/语音）；post_comments、search_in_channel 里多张图或视频的相册是 album，纯文字的没有这个字段。 |
| media_url | 媒体文件链接。 |
| author | 消息发送者。 |
| is_forwarded | 该消息是否为转发。 |
| forwarded_from | 转发来源。追溯信息传播链用。 |
| reply_to_url | 被回复消息的链接。 |
| platform | 数据来源平台标识，与请求里的 platform 一致（如 xiaohongshu、tiktok）。 |
| link_preview_url | 帖子里链接预览卡片指向的网址（channel_posts / post_detail）；帖子没有链接预览时不出现这个字段。 |
| reactions | 表情回应及各自数量；post_comments、search_in_channel 里每项是 {emoji, emoji_id, count, is_paid}，自定义表情没有 emoji、给 emoji_id。 |
| text_html | 正文的 HTML 版本，保留链接和格式（post_comments、search_in_channel）。 |
| image_urls | 图片链接数组，按平台展示顺序；没有图片时不出现这个字段。 |
| video_url | 视频文件地址（post_comments、search_in_channel），带签名、会过期；没有视频时没有这个字段。 |
| media | 消息里的每个图片、视频（post_comments、search_in_channel）：[{type, url, id, width, height, thumbnail_url, duration_sec}]，各项有值才出现；地址会过期。 |
| reaction_count | 表情回应的总数（post_comments、search_in_channel）。 |
| reaction_count_estimated | reaction_count 是不是约数：Telegram 页面上显示成 9.37K 这种写法时为 true（post_comments、search_in_channel）。 |
| links | 正文里的链接，按出现顺序（post_comments、search_in_channel）；没有时没有这个字段。 |
| reply_to_id | 被回复的那条消息或评论的编号（post_comments、search_in_channel）；Telegram 没给时没有这个字段。 |
| reply_to_name | 被回复的人的名字（post_comments、search_in_channel）。 |
| reply_to_text | 被回复的那条的正文，Telegram 页面上引用显示的那段（post_comments、search_in_channel）。 |
| is_edited | 消息发出后是否编辑过（search_in_channel）。 |
| image_count | 消息里的图片张数（search_in_channel）。 |
| video_urls | 消息里每个视频的地址（search_in_channel），相册可能有好几个；带签名、会过期。 |
| thumbnail_url | 缩略图链接，分辨率低于 image_url。 |
| duration_sec | 视频时长，单位秒（search_in_channel），与 duration_seconds 同值。 |
| duration_seconds | 时长，单位秒。非视频/音频内容为 null。 |
| width | 图片或视频的宽度，像素（search_in_channel）。 |
| height | 图片或视频的高度，像素（search_in_channel）。 |
| hashtags | 正文里的话题标签数组，按出现顺序；没有时不出现这个字段。 |
| mentions | 正文里 @ 提到的用户名（search_in_channel）。 |
| is_reply | 这条消息是否回复了另一条消息（search_in_channel）。 |
| view_count_estimated | view_count 是不是约数：Telegram 页面上显示成 2.57M 这种写法时为 true（search_in_channel）。 |
| link_preview | 消息里的链接预览卡片（search_in_channel）：{url, site_name, title, description, image_url}，各项有值才出现；url 同 link_preview_url。 |
| reposted_post | 转发的消息的来源信息，原样给（search_in_channel）；只在转发的消息上出现。 |
| poll_question | 投票的问题（search_in_channel）；只在投票消息上出现。 |
| poll_options | 投票的各个选项，原样给（search_in_channel）。 |
| poll_total_votes | 投票的总票数（search_in_channel）。 |
| poll_total_votes_estimated | poll_total_votes 是不是约数（search_in_channel），规则同 view_count_estimated。 |
| channel_id | 频道的数字编号（search_in_channel）。 |
| channel_url | 频道链接 https://t.me/<频道名>（search_in_channel）。 |
| channel_avatar_url | 频道头像图片地址（search_in_channel）。 |
| channel_description | 频道简介。 |
| channel_subscriber_count | 频道订阅数。 |
| channel_subscriber_count_estimated | channel_subscriber_count 是不是约数（search_in_channel 里是 Telegram 页面上的约数，如 9.83M 记为 9830000，此时为 true）。 |

## 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": "telegram",
  "action": "search_in_channel",
  "params": {
    "username": "durov",
    "keyword": "TON"
  }
}'
```

```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": "telegram",
        "action": "search_in_channel",
        "params": {
            "username": "durov",
            "keyword": "TON",
        },
    },
    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": "telegram",
  "action": "search_in_channel",
  "results": [
    {
      "id": …,
      "url": …,
      "channel_username": …,
      "channel_title": …,
      "text": …,
      "view_count": …,
      "posted_at": …,
      "media_type": …,
      "media_url": …,
      "author": …,
      "is_forwarded": …,
      "forwarded_from": …,
      "reply_to_url": …,
      "platform": …,
      "link_preview_url": …,
      "reactions": …,
      "text_html": …,
      "image_urls": …,
      "video_url": …,
      "media": …,
      "reaction_count": …,
      "reaction_count_estimated": …,
      "links": …,
      "reply_to_id": …,
      "reply_to_name": …,
      "reply_to_text": …,
      "is_edited": …,
      "image_count": …,
      "video_urls": …,
      "thumbnail_url": …,
      "duration_sec": …,
      "duration_seconds": …,
      "width": …,
      "height": …,
      "hashtags": …,
      "mentions": …,
      "is_reply": …,
      "view_count_estimated": …,
      "link_preview": …,
      "reposted_post": …,
      "poll_question": …,
      "poll_options": …,
      "poll_total_votes": …,
      "poll_total_votes_estimated": …,
      "channel_id": …,
      "channel_url": …,
      "channel_avatar_url": …,
      "channel_description": …,
      "channel_subscriber_count": …,
      "channel_subscriber_count_estimated": …
    }
  ],
  "next_page_token": …,
  "pagination": { … },
  "count": …,
  "billing": {
    "charged": …,
    "charged_usd": …,
    "balance_after_usd": …,
    …
  },
  "quota": { … }
}
```

## Also

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