# Facebook Search API (facebook.search)

- Canonical page: https://everyinfra.com/en/facebook-api/search
- Endpoint: POST https://api.everyinfra.com/api/v1/social with {"platform": "facebook", "action": "search", "params": {...}}
- Price: $0.016 per call ($16 per 1,000 requests); failed calls and empty results are not charged
- Billing unit: every 10 rows you ask for count as one call; blocks that come back with no rows are not charged
- Returns: list, default 10, max 200 per call
- 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=facebook&action=search

## Parameters

| name | type | required | default | description |
|---|---|---|---|---|
| keyword | not declared | yes | not declared | Specifies the search query for distinct platform endpoints. For search, it searches public posts; for ads, it accepts ad keywords or direct Ad Library and Page URLs; for marketplace, it accepts item search terms or complete Marketplace search URLs. Each action queries a different dataset rather than returning the same results under different field names. |
| content_type | enum: latest / most_popular | no | not declared | Sorts results for the search action using allowed values latest for newer posts or most_popular for popular posts. Despite its name, content_type acts as a sorting dimension and does not filter by media format, such as images or videos. |
| since | not declared | no | not declared | Filters post publication dates for the search action from this start date, recommended in YYYY-MM-DD format. Combined with until, it forms the query date range; it does not filter ad run times or comment creation times. |
| until | not declared | no | not declared | Filters post publication dates for the search action up to this end date, recommended in YYYY-MM-DD format. Combined with since, it forms the query date range; it does not control ad expiration dates. |
| limit | integer (1–200) | no | 10 | The most rows to return in this call, an integer from 1 to 200. The default applies when you leave it out, and a call can return fewer rows. Larger values return 422 before any charge. |

## Response fields (items in `results`)

| field | meaning |
|---|---|
| id | The record's unique ID on the platform. Unique only within one platform; IDs can repeat across platforms. |
| url | Link to the record on the platform. |
| text | Body text with HTML removed, returned in full and never cut short (on a few platforms the list results themselves carry only an excerpt; the platform's field notes say so). |
| author_name | Author's display name. |
| author_username | Author's username (@handle), usually usable in URLs. |
| author_id | Numeric user id of the comment author (stable identifier for cross-request deduplication). |
| author_url | Profile link of the comment author. |
| author_avatar_url | platform-native meaning |
| media | platform-native meaning |
| reactions | platform-native meaning |
| view_count | Views or plays. null means not disclosed, not 0. |
| link | platform-native meaning |
| group_name | platform-native meaning |
| is_paid_partnership | platform-native meaning |
| like_count | Likes. null means the platform or this capability does not disclose it; it is not 0. |
| comment_count | Comments. null means not disclosed, not 0. |
| share_count | Shares. null means not disclosed, not 0. |
| posted_at | Publish time in ISO 8601, UTC (for example 2026-08-07T12:34:56+00:00). Non-standard strings from the platform are passed through as is, so parse defensively. null means the platform does not disclose it. |
| platform | Source platform identifier, the same as platform in the request (for example 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": "search",
  "params": {
    "keyword": "urban gardening"
  }
}'
```

```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": "search",
        "params": {
            "keyword": "urban gardening",
        },
    },
    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 10. `id`, `billing` and `quota` differ on every call, so only their shape is shown.

```text
{
  "id": "req_…",
  "platform": "facebook",
  "action": "search",
  "results": [
    {
      "id": "•••",
      "url": "https://www.facebook.com/permalink.php?story_fbid=pfbid0vKMztoky1iJDEbVmvrqgZAsKJUFvpaiMh6i1KHScVCkSrd5QaPKjHiRobJfgjsuhl&id=61594613075925",
      "text": "What would you plant?",
      "author_name": "•••",
      "author_username": "•••",
      "like_count": 0,
      "comment_count": 0,
      "share_count": 0,
      "posted_at": "2026-09-24T07:34:03+00:00",
      "platform": "facebook"
    },
    {
      "id": "•••",
      "url": "https://www.facebook.com/hackhousegarden/posts/pfbid02icHy9PvAydrr77x9t6fzt5wfZnkwSdBEb7VfXG7Db63FD8afuoeDhj3BQCQxKMkDl",
      "text": "Rooftop Urban Garden: Sustainable Living Above the City\n\nThis image showcases a thriving rooftop garden that transforms a compact urban space into a productive and sustainable oasis. Surrounded by neighboring buildings, the rooftop is filled with an impressive variety of vegetabl…",
      "author_name": "•••",
      "author_username": "•••",
      "like_count": 112,
      "comment_count": 0,
      "share_count": 6,
      "posted_at": "2026-07-14T20:10:30+00:00",
      "platform": "facebook"
    }
  ],
  "count": 10,
  "billing": {
    "charged": …,
    "charged_usd": …,
    "balance_after_usd": …,
    …
  },
  "quota": { … }
}
```

## 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
