# Facebook 活动搜索 API (facebook.events_search)

- Canonical page: https://everyinfra.com/facebook-api/events_search
- Endpoint: POST /api/v1/social with {"platform": "facebook", "action": "events_search", "params": {...}}
- Price: $0.000958 per call ($0.96 per 1,000 requests); failed and empty results are not charged
- Returns: list, one page of up to 5 per call; the number of rows varies from page to page and a short page is not the end (limit is ignored; pass the top-level next_page_token from the response as page_token for the next page; no next_page_token means the end)
- 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

Facebook 活动搜索按 `keyword` 找公开活动，每个活动一行：名称、链接、开始时间、地点、是否线上、是否已结束，以及标了「参加」和「感兴趣」的人数、票价说明和图片。它回答「某个主题或城市里有哪些活动、热度如何」，适合找合作场地、观察竞品办的活动，或在目标城市里选要去的展会。

`keyword` 可以把主题和地名写在一起，例如 music festival、yoga Singapore。结果包含已经结束的活动，用 `is_past` 筛掉；`starts_at` 是 ISO 8601 的 UTC 时间，`date_text` 是页面上显示的原文，带当地时区，和活动所在地的时间对照时用后者。

## Health

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

## Parameters

| name | type | required | default | description |
|---|---|---|---|---|
| keyword | not declared | yes | not declared | 活动关键词，如 music festival、yoga Singapore。返回公开活动，含已结束的（is_past）。 |
| page_token | not declared | no | not declared | 翻页令牌：把上一次响应里的 next_page_token 原样传回，拿下一页（每页约 5 个）；不传从第一页开始。令牌 24 小时有效，每页算一次调用。 |

## Response fields (items in `results`)

| field | meaning |
|---|---|
| id | 该记录在原平台上的唯一标识。仅在同一平台内唯一，跨平台可能重复。 |
| url | 该记录在原平台上的可访问链接。 |
| name | 名称。用于账号/商品/商家类能力，指该对象本身的名字。 |
| starts_at | 活动开始时间（events_search、page_events；ISO 8601，UTC）。 |
| date_text | Facebook 页面上显示的活动时间原文，带当地时区（events_search、page_events），如「Sat, Oct 31 at 8:00 PM CDT」。 |
| place_name | 活动地点名称或地址（events_search、page_events）；线上活动可能没有。 |
| place_id | 活动地点的 Facebook 主页 ID（events_search）。 |
| is_online | 是否线上活动（events_search、page_events）。 |
| is_past | 活动是否已结束（events_search、page_events）。 |
| going_count | 标记「参加」的人数（events_search）。 |
| interested_count | 标记「感兴趣」的人数（events_search）。 |
| price_text | 票价说明原文（events_search）；免费或没写时没有这个字段。 |
| image_url | 图片链接。多图能力可能返回 image_urls 数组。 |
| next_page_token | 翻页令牌（events_search、page_events）：作为下一次请求的 page_token 原样传回取下一页；同一页每行的值相同，响应顶层也有同一个 next_page_token。没有该字段即到底。 |
| 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": "facebook",
  "action": "events_search",
  "params": {
    "keyword": "music festival"
  }
}'
```

```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": "facebook",
        "action": "events_search",
        "params": {
            "keyword": "music festival",
        },
    },
    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": "facebook",
  "action": "events_search",
  "results": [
    {
      "id": …,
      "url": …,
      "name": …,
      "starts_at": …,
      "date_text": …,
      "place_name": …,
      "place_id": …,
      "is_online": …,
      "is_past": …,
      "going_count": …,
      "interested_count": …,
      "price_text": …,
      "image_url": …,
      "next_page_token": …,
      "platform": …
    }
  ],
  "next_page_token": …,
  "pagination": { … },
  "count": …,
  "billing": {
    "charged": …,
    "charged_usd": …,
    "balance_after_usd": …,
    …
  },
  "quota": { … }
}
```

## FAQ

### 活动搜索和主页活动怎么选？

手里是主题词或地名，想看有哪些活动，用活动搜索；手里是一个公共主页，想看它办过什么、要办什么，用主页活动那一页，传主页链接。那一页每页约 10 个，多出城市、主办主页和是否取消，但没有参加和感兴趣的人数。

### `price_text` 为空就是免费吗？

不一定。免费的活动和没写票价的活动，都没有这个字段，所以字段缺失只能说明页面上没有票价说明，不能当成免费。需要确认时，打开 `url` 看活动页。有票价时，它是页面上的原文，原样返回。

### 怎么只留下还没结束的线下活动？

筛 `is_past` 为 false、`is_online` 为 false 的行。线上活动的 `place_name` 可能没有，所以也可以先看它是否为空。`place_id` 是活动地点的 Facebook 主页 ID，要把同一个场地办的活动归到一起时用它分组。

## Also

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