> ## Documentation Index
> Fetch the complete documentation index at: https://getanyapi.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Facebook Post Search

> Sell facebook.search_posts on AnyAPI: the request your endpoint receives, the response it must return, and what the real-request check judges.

Search public Facebook posts by keyword, optionally filtered by location, and get structured post records (text, author, engagement).

This page is the seller-facing summary of one catalog API, `facebook.search_posts`. The transport rules that apply to every API a seller serves - signed requests, the response envelope, timeouts, and body limits - are on [the operator endpoint contract](https://getanyapi.com/docs/sell/operator-endpoint-contract.md).

## The price you compete with

AnyAPI publishes this API from **\$16.00 per 1,000 requests**. That is the price a buyer sees today, so it is the price your endpoint has to come in under to win traffic.

## The request your endpoint receives

| Field | Type | Required | What it means |
| - | - | - | - |
| `endDate` | string | no | Only return posts published on or before this date, format YYYY-MM-DD (e.g. 2024-12-31). |
| `limit` | integer | no | Maximum number of results to return (1-20, default 20). |
| `location` | string | no | Optional place name; include both city and country for best matches (e.g. 'Paris, France'). Uses Facebook's place filter, which favors posts tagged at that place rather than every post by people who live there, and can still return some posts from elsewhere. |
| `query` | string | yes | Keyword or phrase to search Facebook posts for (e.g. 'product launch'). |
| `requireFields` | array | no | Optional; omit it and routing is unchanged, with the cheapest source serving. Name the output fields this request must be able to return, for example `imagesCount` or `albumPreview`, and it is served only by a source that returns every one of them. Fields you do not name are still returned whenever the serving source has them. This can raise your price: when the cheapest source cannot return a named field, a dearer source serves, and you are quoted and charged its price. A named field can still be absent on a post that genuinely lacks it. Naming a combination that no single source returns together is refused as invalid input, with no charge. |
| `startDate` | string | no | Only return posts published on or after this date, format YYYY-MM-DD (e.g. 2024-01-01). |

> [accordion] Full input JSON Schema
>
> ```json theme={"dark"}
> {
>   "$schema": "https://json-schema.org/draft/2020-12/schema",
>   "$id": "https://getanyapi.com/schemas/facebook.search_posts.input.json",
>   "example": {
>     "query": "nike",
>     "limit": 3
>   },
>   "title": "Facebook post search input",
>   "type": "object",
>   "additionalProperties": false,
>   "required": [
>     "query"
>   ],
>   "properties": {
>     "limit": {
>       "type": "integer",
>       "minimum": 1,
>       "maximum": 20,
>       "description": "Maximum number of results to return (1-20, default 20)."
>     },
>     "query": {
>       "type": "string",
>       "description": "Keyword or phrase to search Facebook posts for (e.g. 'product launch')."
>     },
>     "location": {
>       "type": "string",
>       "description": "Optional place name; include both city and country for best matches (e.g. 'Paris, France'). Uses Facebook's place filter, which favors posts tagged at that place rather than every post by people who live there, and can still return some posts from elsewhere."
>     },
>     "startDate": {
>       "type": "string",
>       "pattern": "^\\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01])$",
>       "description": "Only return posts published on or after this date, format YYYY-MM-DD (e.g. 2024-01-01)."
>     },
>     "endDate": {
>       "type": "string",
>       "pattern": "^\\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\\d|3[01])$",
>       "description": "Only return posts published on or before this date, format YYYY-MM-DD (e.g. 2024-12-31)."
>     },
>     "requireFields": {
>       "type": "array",
>       "uniqueItems": true,
>       "items": {
>         "type": "string",
>         "enum": [
>           "albumPreview",
>           "imagesCount",
>           "type"
>         ]
>       },
>       "description": "Optional; omit it and routing is unchanged, with the cheapest source serving. Name the output fields this request must be able to return, for example `imagesCount` or `albumPreview`, and it is served only by a source that returns every one of them. Fields you do not name are still returned whenever the serving source has them. This can raise your price: when the cheapest source cannot return a named field, a dearer source serves, and you are quoted and charged its price. A named field can still be absent on a post that genuinely lacks it. Naming a combination that no single source returns together is refused as invalid input, with no charge."
>     }
>   }
> }
> ```

## The response your endpoint must return

| Field | Type | Always present | What it means |
| - | - | - | - |
| `data` | null or object | yes | |
| `data.albumPreview` | array | no | Preview of the photos attached to the post. |
| `data.albumPreview[].id` | string | no | Numeric Facebook id of the photo, as a string. |
| `data.albumPreview[].image` | string | no | Image URL of the photo. |
| `data.albumPreview[].type` | string | no | Kind of attachment, e.g. "photo". |
| `data.albumPreview[].url` | string | no | Canonical Facebook URL of the photo. |
| `data.authorId` | string | no | Numeric Facebook id of the page or profile that posted, as a string. |
| `data.authorImage` | string | no | Profile picture URL of the page or profile that posted. |
| `data.imagesCount` | integer or null | no | Number of images attached to the post. Null when the source does not report it. |
| `data.items` | array | yes | Matching public Facebook post records for the query. |
| `data.items[].authorName` | string | no | Display name of the post's author. Empty when the upstream omits it. |
| `data.items[].authorUrl` | string | no | Canonical profile URL of the post's author, with tracking query params stripped. Empty when the upstream omits it. |
| `data.items[].commentCount` | integer | no | Total number of comments on the post. |
| `data.items[].createdUtc` | number | yes | UTC epoch timestamp in seconds (Unix time). Multiply by 1000 for a JS Date in milliseconds. |
| `data.items[].id` | string | yes | The post's numeric Facebook ID, as a string. |
| `data.items[].image` | string | no | URL of the post's primary image, a signed CDN URL whose query must be kept. Empty for text-only or video posts. |
| `data.items[].reactionCount` | integer | no | Total number of reactions on the post. |
| `data.items[].shareCount` | integer | no | Total number of shares/reshares of the post. |
| `data.items[].text` | string | yes | The post's text/message. Empty for media-only posts with no caption. |
| `data.items[].url` | string | yes | Canonical URL of the post. A post with no page path keeps the query that identifies it (permalink.php?story\_fbid=...\&id=...). |
| `data.reactions` | object | no | Reaction counts on the post, broken down by reaction type. |
| `data.reactions.angry` | integer | no | Angry reactions. |
| `data.reactions.care` | integer | no | Care reactions. |
| `data.reactions.haha` | integer | no | Haha reactions. |
| `data.reactions.like` | integer | no | Like reactions. |
| `data.reactions.love` | integer | no | Love reactions. |
| `data.reactions.sad` | integer | no | Sad reactions. |
| `data.reactions.wow` | integer | no | Wow reactions. |
| `data.type` | string | no | Kind of record Facebook returned, e.g. "post". |
| `found` | boolean | yes | Whether any matching posts were returned for the query. |

Extra fields are kept, missing declared fields fail.

> [accordion] Full output JSON Schema
>
> ```json theme={"dark"}
> {
>   "$schema": "https://json-schema.org/draft/2020-12/schema",
>   "$id": "https://getanyapi.com/schemas/facebook.search_posts.output.json",
>   "title": "Facebook post search output",
>   "type": "object",
>   "additionalProperties": false,
>   "required": [
>     "found",
>     "data"
>   ],
>   "properties": {
>     "found": {
>       "type": "boolean",
>       "description": "Whether any matching posts were returned for the query."
>     },
>     "data": {
>       "oneOf": [
>         {
>           "type": "null"
>         },
>         {
>           "type": "object",
>           "additionalProperties": false,
>           "required": [
>             "items"
>           ],
>           "properties": {
>             "items": {
>               "x-anyapi-must-populate": true,
>               "type": "array",
>               "description": "Matching public Facebook post records for the query.",
>               "items": {
>                 "type": "object",
>                 "required": [
>                   "id",
>                   "url",
>                   "text",
>                   "createdUtc"
>                 ],
>                 "properties": {
>                   "id": {
>                     "x-anyapi-must-populate": true,
>                     "type": "string",
>                     "description": "The post's numeric Facebook ID, as a string."
>                   },
>                   "url": {
>                     "x-anyapi-domain": "facebook.com",
>                     "x-anyapi-must-populate": true,
>                     "type": "string",
>                     "description": "Canonical URL of the post. A post with no page path keeps the query that identifies it (permalink.php?story_fbid=...&id=...)."
>                   },
>                   "text": {
>                     "type": "string",
>                     "description": "The post's text/message. Empty for media-only posts with no caption."
>                   },
>                   "authorName": {
>                     "type": "string",
>                     "description": "Display name of the post's author. Empty when the upstream omits it."
>                   },
>                   "authorUrl": {
>                     "x-anyapi-domain": "facebook.com",
>                     "type": "string",
>                     "description": "Canonical profile URL of the post's author, with tracking query params stripped. Empty when the upstream omits it."
>                   },
>                   "reactionCount": {
>                     "type": "integer",
>                     "description": "Total number of reactions on the post."
>                   },
>                   "commentCount": {
>                     "type": "integer",
>                     "description": "Total number of comments on the post."
>                   },
>                   "shareCount": {
>                     "type": "integer",
>                     "description": "Total number of shares/reshares of the post."
>                   },
>                   "image": {
>                     "x-anyapi-domain": [
>                       "fbcdn.net",
>                       "cdninstagram.com",
>                       "fbsbx.com"
>                     ],
>                     "type": "string",
>                     "description": "URL of the post's primary image, a signed CDN URL whose query must be kept. Empty for text-only or video posts."
>                   },
>                   "createdUtc": {
>                     "type": "number",
>                     "description": "UTC epoch timestamp in seconds (Unix time). Multiply by 1000 for a JS Date in milliseconds."
>                   }
>                 }
>               }
>             },
>             "type": {
>               "type": "string",
>               "description": "Kind of record Facebook returned, e.g. \"post\"."
>             },
>             "authorId": {
>               "type": "string",
>               "description": "Numeric Facebook id of the page or profile that posted, as a string."
>             },
>             "authorImage": {
>               "x-anyapi-domain": [
>                 "fbcdn.net",
>                 "cdninstagram.com",
>                 "fbsbx.com"
>               ],
>               "type": "string",
>               "description": "Profile picture URL of the page or profile that posted."
>             },
>             "imagesCount": {
>               "type": [
>                 "integer",
>                 "null"
>               ],
>               "description": "Number of images attached to the post. Null when the source does not report it."
>             },
>             "reactions": {
>               "type": "object",
>               "description": "Reaction counts on the post, broken down by reaction type.",
>               "properties": {
>                 "like": {
>                   "type": "integer",
>                   "description": "Like reactions."
>                 },
>                 "love": {
>                   "type": "integer",
>                   "description": "Love reactions."
>                 },
>                 "care": {
>                   "type": "integer",
>                   "description": "Care reactions."
>                 },
>                 "haha": {
>                   "type": "integer",
>                   "description": "Haha reactions."
>                 },
>                 "wow": {
>                   "type": "integer",
>                   "description": "Wow reactions."
>                 },
>                 "sad": {
>                   "type": "integer",
>                   "description": "Sad reactions."
>                 },
>                 "angry": {
>                   "type": "integer",
>                   "description": "Angry reactions."
>                 }
>               }
>             },
>             "albumPreview": {
>               "type": "array",
>               "description": "Preview of the photos attached to the post.",
>               "items": {
>                 "type": "object",
>                 "properties": {
>                   "id": {
>                     "type": "string",
>                     "description": "Numeric Facebook id of the photo, as a string."
>                   },
>                   "type": {
>                     "type": "string",
>                     "description": "Kind of attachment, e.g. \"photo\"."
>                   },
>                   "url": {
>                     "x-anyapi-domain": "facebook.com",
>                     "type": "string",
>                     "description": "Canonical Facebook URL of the photo."
>                   },
>                   "image": {
>                     "x-anyapi-domain": [
>                       "fbcdn.net",
>                       "cdninstagram.com",
>                       "fbsbx.com"
>                     ],
>                     "type": "string",
>                     "description": "Image URL of the photo."
>                   }
>                 }
>               }
>             }
>           }
>         }
>       ]
>     }
>   }
> }
> ```

## Fields that must never come back empty

* `id`
* `items`
* `url`

The repository marks these fields as ones every source must be able to fill. An empty value is only correct when the entity itself genuinely has nothing there.

## Not found, and how it differs from empty

When the entity does not exist, answer 2xx with the not-found shape:

```json theme={"dark"}
{
  "found": false,
  "data": null
}
```

An empty list is not a not-found: when the entity exists and has nothing to return, answer 2xx with `found: true` and an empty `items` array.

This output schema declares no `reason` field, so `found: false` is the whole not-found answer.

## Example request

```json theme={"dark"}
{
  "query": "nike",
  "limit": 3
}
```

The registration tests send this example to your endpoint, with the API's other test inputs. After that, the real-request check sends your endpoint real past customer inputs, and an AI reviewer compares each answer with AnyAPI's own answer to the same input.

## Next

* [The operator endpoint contract](https://getanyapi.com/docs/sell/operator-endpoint-contract.md) for signing, budgets, and the real-request check.
* [Every API open to sellers](https://getanyapi.com/docs/sell/apis/index.md).
* Want to sell an API that is not on that list? Email [support@getanyapi.com](mailto:support@getanyapi.com).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.