Skip to main content
POST
Facebook Ad Search

Authorizations

Authorization
string
header
default:YOUR_ANYAPI_KEY
required

Your AnyAPI key as a Bearer token.

Headers

Idempotency-Key
string

Optional wallet idempotency key, scoped to this customer for 24 hours. When the gateway honors the key, this synchronous in-process execution can continue after the caller disconnects, bounded by its execution deadline. A completed replayable result charges normally exactly once and can be replayed without another provider run or charge. A pending duplicate returns 409 idempotency_in_progress; reuse with different request semantics returns 409 idempotency_conflict.

Required string length: 1 - 255

Query Parameters

fields
string

Optional. Comma-separated keys (dotted paths like author.name descend into nested objects) to keep on each result item. Keys are matched relative to each result item after the data/items envelope is unwrapped, not against the top-level response envelope, so use jq to reshape the whole envelope. Shrinks the response without changing cost.

max_items
integer

Optional. Cap the number of result rows returned; a _truncated note reports how many were withheld so you can page via the API's own limit. Does not change cost.

Required range: x >= 0
summary
boolean

Optional. Return only a structural outline (top-level keys, item counts, and per-field byte sizes) instead of the full data. Does not change cost.

jq
string

Optional. A jq expression applied to the result envelope; its output replaces output (multiple outputs collect into an array). Reshape freely, e.g. jq=.data | {title, description, md: .markdown[:3500]}. Runs sandboxed with a 250ms / 2MB budget; on failure the full result is returned with a jqError. Does not change cost.

Body

application/json
query
string
required

Keyword to search the Meta Ad Library for (e.g. "protein powder").

adType
enum<string>

Restrict to all ads (default) or only political and issue ads.

Available options:
all,
political_and_issue_ads
country
string

Two-letter country code to scope results. Omit for all countries.

cursor
string

Opaque pagination cursor from a previous response's nextCursor.

endDate
string

Filter to ads with impressions on or before this date, in YYYY-MM-DD format.

mediaType
enum<string>

Creative media type filter.

Available options:
ALL,
IMAGE,
VIDEO,
MEME,
IMAGE_AND_MEME,
NONE
searchType
enum<string>

Match mode for the query: loose keyword match (keyword_unordered, the default) or exact phrase (keyword_exact_phrase).

Available options:
keyword_unordered,
keyword_exact_phrase
sortBy
enum<string>

Sort order: impressions (highest first, the default) or recent (most recent).

Available options:
impressions,
recent
startDate
string

Filter to ads with impressions on or after this date, in YYYY-MM-DD format.

status
enum<string>
default:ACTIVE

Ad status filter.

Available options:
ALL,
ACTIVE,
INACTIVE

Response

Normalized result.

costUsd
number
required

USD charged on the original run. On a replay this value is echoed for parity; the replay itself is free.

output
Facebook ad search output · object | null
required

Normalized output, or null when the replay payload was not retained.

provider
string
required

Always "AnyAPI".

replayed
boolean
required

True when this response replays the durable result of an earlier run without billing or upstream execution.

items
integer

Number of result rows returned. For per-result SKUs the per-item cost is charged against this count; for input-priced SKUs the charge is per submitted input, independent of this count.

jqError
string

Present only when a jq expression failed; output then carries the full unshaped result and this explains why the reshape did not apply.

resultId
string

Opaque handle to the full unshaped result, cached ~15 min. Re-shape it for free (fields/max_items/summary/jq) via GET /v1/results/{id}, no re-billing. Absent when the result was too large to cache.