GET /v1/meta_ads/search_ads
Meta Ad Library search API: find Facebook and Instagram ads by keyword
Searches the copy of Meta Ad Library ads across every advertiser and returns Page[Post], up to 30 ads a page: the copy is caption, the start is taken_at, and the CTA, link, platforms and countries sit under extra. Send the keyword as query, and narrow it with country, status and media_type.
- Price
- $0.0025 per page
- Billing
- $0.0025/page
- Batch
- Yes, through /v1/batch
- Failed calls
- Not charged
Example request
curl 'https://api.virev.ai/v1/meta_ads/search_ads?query=running%20shoes&max_pages=1' \
-H "Authorization: Bearer $VIREV_API_KEY"import os
import requests
response = requests.request(
"GET",
"https://api.virev.ai/v1/meta_ads/search_ads",
params={
"query": "running shoes",
"max_pages": "1",
},
headers={"Authorization": f"Bearer {os.environ['VIREV_API_KEY']}"},
timeout=60,
)
response.raise_for_status()
print(response.json())Parameters
| Name | In | Type | Description |
|---|---|---|---|
query required | query | string | The words to search for, up to 500 characters. |
country | query | string | A two-letter country code, or ALL; omitted is US. |
status | query | ALL | ACTIVE | INACTIVE | Which ads: ALL (the default), ACTIVE or INACTIVE. |
media_type | query | ALL | IMAGE | VIDEO | MEME | IMAGE_AND_MEME | NONE | Only ads of this media type; omitted is ALL. |
sort_by | query | relevancy_monthly_grouped | The Ad Library's order; only relevancy_monthly_grouped, its default, is observed. |
since | query | string | Not accepted on this operation: its items carry no timestamp, so since returns 400 before billing. |
max_pages | query | integer | Maximum pages to fetch. -1 walks until exhaustion or since with no page cap, and must be written. Omitted, since alone bounds the walk; with neither, the job stops after 10 pages. Any positive integer is accepted. 1 returns one page synchronously with HTTP 200; any other value creates a durable job with HTTP 202. |
cursor | query | string | Opaque next_cursor from an earlier answer of this operation, also with get_raw=true. A native Meta Ads cursor from a raw page answers 400. Result download cursors belong to the results route. |
cached | query | auto | cache_only | live | auto (default) serves a read saved within the last 24 hours for these exact arguments, otherwise fetches. cache_only never contacts Meta Ads (404 not_cached when nothing is saved, whatever its age). live always fetches. Anything else is a 400. cache_only reads one saved page per request: omit max_pages or pass 1, and continue with next_cursor. |
get_raw | query | boolean | true returns the upstream JSON exactly as Meta Ads answered it instead of the normalized Page[Post]. |
Idempotency-Key | header | string | Reuse this key with the same inputs to recover a lost job submission. A different input with the same key returns 409. |
Example response
The example response of the API reference, with lists cut to their first 3 items and long text shortened.
{
"data": {
"items": [
{
"id": "866569929827744",
"shortcode": null,
"taken_at": "2026-06-01T07:00:00+00:00",
"kind": "image",
"product_type": "IMAGE",
"caption": "I watched a man in a Carhartt jacket put back a gallon of milk at the gas station because the total at the pump had already eaten what he came in with.\n\nHe didn't argue.\n\nHe just nodded at the clerk like they'd already had the conversation …",
"hashtags": [],
"mentions": [],
"accessibility_caption": null,
"likes": null,
"comments": null,
"views": null,
"counts_hidden": null,
"comments_disabled": null,
"is_pinned": null,
"is_paid_partnership": false,
"owner": {
"id": "866655706540346",
"username": null,
"full_name": "Cholesterol Relief Community",
"is_verified": null,
"is_private": false,
"avatar_url": "https://scontent.fqnv8-1.fna.fbcdn.net/v/t39.35426-6/704801774_1307804184087393_1622247990819069384_n.jpg?stp=dst-jpg_s60x60_tt6&_nc_cat=102&_nc_map=urlgen_bucketless&ccb=1-7&_nc_sid=c53f8f&_nc_ohc=I1ULe3hY4egQ7kNvwHmriqP&_nc_oc=Adp1YCl23UJ…",
"latest_story_at": null,
"extra": {
"category": "Community Center",
"likes": 3227,
"is_deleted": false,
"url": "https://www.facebook.com/866655706540346"
}
},
"coauthors": [],
"sponsors": [],
"tagged": [],
"location": null,
"audio": null,
"thumbnail_url": "https://scontent.fqnv8-1.fna.fbcdn.net/v/t39.35426-6/710781895_4357881537807857_1908372834204043877_n.jpg?_nc_cat=103&_nc_map=urlgen_bucketless&ccb=1-7&_nc_sid=c53f8f&_nc_ohc=ksXqHTffZPoQ7kNvwGUTKFA&_nc_oc=AdrHUBxwEjHwEIrQysIEMOaplunGgEhZ9U…",
"video_duration": null,
"media": [
{
"kind": "image",
"url": "https://scontent.fqnv8-1.fna.fbcdn.net/v/t39.35426-6/710781895_4357881537807857_1908372834204043877_n.jpg?_nc_cat=103&_nc_map=urlgen_bucketless&ccb=1-7&_nc_sid=c53f8f&_nc_ohc=ksXqHTffZPoQ7kNvwGUTKFA&_nc_oc=AdrHUBxwEjHwEIrQysIEMOaplunGgEhZ9U…",
"width": null,
"height": null,
"duration": null
}
],
"media_urls": [
"https://scontent.fqnv8-1.fna.fbcdn.net/v/t39.35426-6/710781895_4357881537807857_1908372834204043877_n.jpg?_nc_cat=103&_nc_map=urlgen_bucketless&ccb=1-7&_nc_sid=c53f8f&_nc_ohc=ksXqHTffZPoQ7kNvwGUTKFA&_nc_oc=AdrHUBxwEjHwEIrQysIEMOaplunGgEhZ9U…"
],
"extra": {
"url": "https://www.facebook.com/ads/library/?id=866569929827744",
"is_active": true,
"end_date": "2026-10-27T07:00:00+00:00",
"title": "Natural Relief in Weeks",
"link_caption": "shop.pipitea.com",
"link_url": "https://shop.pipitea.com/ppch/sp",
"link_domain": "shop.pipitea.com",
"cta_type": "LEARN_MORE",
"cta_text": "Learn more",
"collation_id": "1541421164361823",
"collation_count": 1,
"publisher_platforms": [
"facebook",
"instagram",
"audience_network"
],
"countries": [],
"categories": [
"UNKNOWN"
],
"currency": null
}
},
{
"id": "914467831604972",
"shortcode": null,
"taken_at": "2026-05-26T07:00:00+00:00",
"kind": "image",
"product_type": "IMAGE",
"caption": "I have been cutting the same man's hair every three weeks for twenty-six years, and last March he sat down in my chair and asked me, very politely, what my name was.\n\nI have known his wife's birthday since 2003. I cut his son's hair before …",
"hashtags": [],
"mentions": [],
"accessibility_caption": null,
"likes": null,
"comments": null,
"views": null,
"counts_hidden": null,
"comments_disabled": null,
"is_pinned": null,
"is_paid_partnership": false,
"owner": {
"id": "866655706540346",
"username": null,
"full_name": "Cholesterol Relief Community",
"is_verified": null,
"is_private": false,
"avatar_url": "https://scontent.fqnv8-1.fna.fbcdn.net/v/t39.35426-6/704801774_1307804184087393_1622247990819069384_n.jpg?stp=dst-jpg_s60x60_tt6&_nc_cat=102&_nc_map=urlgen_bucketless&ccb=1-7&_nc_sid=c53f8f&_nc_ohc=I1ULe3hY4egQ7kNvwHmriqP&_nc_oc=Adp1YCl23UJ…",
"latest_story_at": null,
"extra": {
"category": "Community Center",
"likes": 3227,
"is_deleted": false,
"url": "https://www.facebook.com/866655706540346"
}
},
"coauthors": [],
"sponsors": [],
"tagged": [],
"location": null,
"audio": null,
"thumbnail_url": "https://scontent.fqnv8-1.fna.fbcdn.net/v/t39.35426-6/704980248_1477053767527294_3397865044255430814_n.jpg?_nc_cat=108&_nc_map=urlgen_bucketless&ccb=1-7&_nc_sid=c53f8f&_nc_ohc=_y1Bfc_S4nEQ7kNvwFZuszf&_nc_oc=Ado6alzclBzW7m5VxK2OGEGwwQIrRtoAof…",
"video_duration": null,
"media": [
{
"kind": "image",
"url": "https://scontent.fqnv8-1.fna.fbcdn.net/v/t39.35426-6/704980248_1477053767527294_3397865044255430814_n.jpg?_nc_cat=108&_nc_map=urlgen_bucketless&ccb=1-7&_nc_sid=c53f8f&_nc_ohc=_y1Bfc_S4nEQ7kNvwFZuszf&_nc_oc=Ado6alzclBzW7m5VxK2OGEGwwQIrRtoAof…",
"width": null,
"height": null,
"duration": null
}
],
"media_urls": [
"https://scontent.fqnv8-1.fna.fbcdn.net/v/t39.35426-6/704980248_1477053767527294_3397865044255430814_n.jpg?_nc_cat=108&_nc_map=urlgen_bucketless&ccb=1-7&_nc_sid=c53f8f&_nc_ohc=_y1Bfc_S4nEQ7kNvwFZuszf&_nc_oc=Ado6alzclBzW7m5VxK2OGEGwwQIrRtoAof…"
],
"extra": {
"url": "https://www.facebook.com/ads/library/?id=914467831604972",
"is_active": true,
"end_date": "2026-10-27T07:00:00+00:00",
"title": "Natural Relief in Weeks",
"link_caption": "shop.pipitea.com",
"link_url": "https://shop.pipitea.com/ppch/sp",
"link_domain": "shop.pipitea.com",
"cta_type": "LEARN_MORE",
"cta_text": "Learn more",
"collation_id": "1352218446885589",
"collation_count": 2,
"publisher_platforms": [
"facebook",
"instagram",
"audience_network"
],
"countries": [],
"categories": [
"UNKNOWN"
],
"currency": null
}
}
],
"pages": [
{
"cursor": null,
"fetched_at": "2026-10-27T22:38:40.871552+00:00",
"count": 10
}
],
"next_cursor": "eyJjdXJzb3IiOiJBUUhUWUFQMXdiNTg1dmZMUUJMU2tZREZNZjB4UHRmckN0aFBwN3FYLVNFdGxYdXA2b3o0djZsc05SSDhLTF9iT0xGbSIsIm9wIjoic2VhcmNoX2FkcyJ9",
"has_more": true,
"stop_reason": "pages",
"coverage": {
"since": null,
"oldest_at": null,
"since_reached": false
}
},
"meta": {
"source": "live",
"fetched_at": "2026-10-27T22:38:40.871552+00:00",
"cost": "$0.0025",
"balance": "$49.9925",
"request_id": "req_2282cb1e1502f9fba11d9e36db879406"
}
}How it works
The Ad Library keyword search over ad copy, up to 30 ads a page, across every advertiser. Returns Page[Post] under data, read from the Ad Library as a signed-out guest.
The default request creates a durable job (202). Use max_pages=1 for one synchronous Page response (200). Poll status_url, then read results_url with its opaque cursor. Acquisition stops at the first of max_pages or exhaustion. Jobs continue after disconnects. Result responses are bounded to 3 MiB; this does not limit the crawl. Supply Idempotency-Key to recover a lost submission response; reuse it with the same inputs. The Ad Library sets every page’s size (up to 30 ads) and answers in its own ranked order, so there is no page_size and no since. An answer carries next_cursor and has_more when the Ad Library holds more ads.
An ad answers as a Post: the copy is caption, the start is taken_at, likes, comments and views are null because the Ad Library shows no engagement, and Ad Library facts (the library URL, is_active, end_date, the CTA, the link, publisher_platforms, countries) sit under extra. An advertiser answers as an Account, with Page likes under extra.likes. Unknown, unsupported, and repeated query parameters return 400 before acquisition or billing.
Billing: $0.0025 per call; a job bills $0.0025 for each page it reads, once it completes. A failed read is not charged.
Errors
| Status | When |
|---|---|
400 | The request parameters are invalid. |
401 | Missing, malformed, or revoked API key. |
402 | Balance is too low for this request. |
404 | cached=cache_only found nothing saved for these arguments (not_cached; call again with cached=auto to fetch it), or the Meta Ads account or item does not exist (not_found). You are not charged. |
429 | Over the per-minute limit. The limit belongs to your organization and all its API keys share it: 100 requests per minute unless an increase was granted. Wait for the Retry-After seconds, then retry. On a live read, code rate_limited means the platform itself rate-limited this read; retry after the Retry-After seconds. You are not charged. |
502 | The upstream fetch failed. You are not charged. |
503 | Billing could not be confirmed, so no upstream data was returned. |
504 | The upstream request timed out. You are not charged. |