Social platforms

Search Facebook Ad Library ads · Facebook API

GET/facebook/ads/search
$min $0.003

Searches the Meta Ad Library by keyword with country, status, media type, language and date filters. Paginate with `cursor`.

Using ChatGPT, Claude Code or another client? See the setup steps

Request
curl https://api.unifapi.com/facebook/ads/search?query= \
  -H "Authorization: Bearer $UNIFAPI_KEY"

Parameters

queryqueryrequired
Search query text for Facebook Ad Library ads.
sort_byquery
Optional sort order for returned ads.
search_typequery
Optional keyword matching mode for the search query.
ad_typequery
Optional filter for all ads or political and issue ads.
countryquery
Optional country code filter. Use ALL to search all countries.
languagequery
Optional ISO 639-1 language code (two letters, for example EN, ES or FR) to only return ads in that language.
statusquery
Optional ad status filter.
media_typequery
Optional creative media filter.
start_datequery
Optional start date filter in YYYY-MM-DD format.
end_datequery
Optional end date filter in YYYY-MM-DD format.
cursorquery
Opaque pagination cursor from a previous response's `pagination.next_cursor`. Omit for the first page.
The parameter for this Facebook operation. Use the URL-visible slug or id described in the docs.
Overview

This operation is part of the Facebook API in the social platforms category. It uses the same Bearer token, request tracing, error model, and billing envelope as every UnifAPI endpoint, so agents can switch between platforms without custom per-vendor glue code.

Use it when a workflow needs Facebook public data alongside other social networks, but should still keep one API key, one account balance, and one predictable JSON contract.

Common agent workflows

  • Search Facebook for public mentions, creators, posts, or topics matching a user query.
  • Feed ranked Facebook results into research, monitoring, and enrichment workflows.
  • Give an AI agent a stable Facebook data source without building a per-platform integration.
  • Normalize Facebook responses into the same UnifAPI envelope used across the catalog.
Response shape

Unified envelope, platform-native fields

  • List-style responses return `data` as an array of top-level records plus optional `pagination` for continuation tokens or cursors.
  • The operation has a 3 credits ($0.003) minimum charge, so `billing.records_charged` can be higher than the visible records returned.
  • If the workspace balance cannot cover every result, the response can be truncated and `billing.truncated_due_to_balance` tells the caller why.

Response status codes

200400401402404429500502503

Billing

This operation charges 1 credit per billable record, with a 3 credits ($0.003) operation minimum. Public responses include billing metadata with credits charged, records charged, and remaining workspace balance. Incorrect Credit deductions caused by platform failures can be restored as billing corrections.

Errors and retries

Authentication, validation, rate-limit, not-found, and provider errors use the unified UnifAPI error format. Agents should log `request_id`, retry only retryable failures, and treat invalid API keys, disabled keys, and expired keys as the same public `unauthorized` error type.

Response fields

Fields on each record in data

A successful Search Facebook Ad Library ads call returns data as an array; each record carries these fields (12 of 16 shown — the docs list the full schema).

idstring | null
Stable identifier for the ad.
ad_idstring | null
Platform ad id when available.
urlstring | null
Public Facebook Ad Library URL for this ad when available.
pageobject | null
Advertiser page summary for this ad.
campaignobject | null
Campaign collation metadata for this ad.
is_activeboolean | null
Whether the ad is currently active.
publisher_platformsstring[]
Publisher platforms where the ad ran or is running.
started_atnumber | null
ISO-8601 timestamp for when the ad started, when available. Unix seconds.
ended_atnumber | null
ISO-8601 timestamp for when the ad ended, when available. Unix seconds.
categoriesstring[]
Ad categories reported by the platform.
countriesstring[]
Countries targeted or reached by the ad when available.
impressionsobject | null
Impressions metadata when available.
Related endpoints

More Facebook operations

Combine endpoints from the same platform, then join the results with other UnifAPI categories without changing authentication or response parsing.