Facebook Ads Search Endpoint
Search the public Ads Library from a keyword, page, or library URL.
Getting Started
Send your API key as a bearer token. Start with the smallest request below.
Search Ads
Send one source: query, page_id, url, or urls.
curl -X POST "https://api.datablue.dev/v1/data/facebook-ads/search" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"query": "kiro beauty",
"country": "IN",
"limit": 10
}'{
"success": true,
"source": "facebook_ads_library",
"operation": "search",
"query": "kiro beauty",
"country": "IN",
"total_results": 1,
"time_taken": 2.5,
"ads": [
{
"position": 1,
"ad_archive_id": "1234567890",
"is_active": true,
"page_name": "Kiro Beauty",
"body": "Clean beauty essentials",
"cta_text": "Shop Now",
"image_count": 1,
"video_count": 0,
"publisher_platforms": [
"facebook"
],
"ad_library_url": "https://www.facebook.com/ads/library/?id=1234567890"
}
]
}Search Sources
Search a Page
Set page_id to return ads associated with one Facebook page.
curl -X POST "https://api.datablue.dev/v1/data/facebook-ads/search" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"page_id": "123456789",
"country": "IN",
"limit": 10
}'{
"success": true,
"source": "facebook_ads_library",
"operation": "search",
"query": "kiro beauty",
"country": "IN",
"total_results": 1,
"time_taken": 2.5,
"ads": [
{
"position": 1,
"ad_archive_id": "1234567890",
"is_active": true,
"page_name": "Kiro Beauty",
"body": "Clean beauty essentials",
"cta_text": "Shop Now",
"image_count": 1,
"video_count": 0,
"publisher_platforms": [
"facebook"
],
"ad_library_url": "https://www.facebook.com/ads/library/?id=1234567890"
}
]
}Use a Library URL
Send url for one Ads Library source.
curl -X POST "https://api.datablue.dev/v1/data/facebook-ads/search" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://www.facebook.com/ads/library/?id=1234567890",
"country": "IN"
}'{
"success": true,
"source": "facebook_ads_library",
"operation": "search",
"query": "kiro beauty",
"country": "IN",
"total_results": 1,
"time_taken": 2.5,
"ads": [
{
"position": 1,
"ad_archive_id": "1234567890",
"is_active": true,
"page_name": "Kiro Beauty",
"body": "Clean beauty essentials",
"cta_text": "Shop Now",
"image_count": 1,
"video_count": 0,
"publisher_platforms": [
"facebook"
],
"ad_library_url": "https://www.facebook.com/ads/library/?id=1234567890"
}
]
}Use Multiple Library URLs
Send urls for a bounded batch of Ads Library sources.
curl -X POST "https://api.datablue.dev/v1/data/facebook-ads/search" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"urls": [
"https://www.facebook.com/ads/library/?id=1234567890",
"https://www.facebook.com/ads/library/?id=1234567891"
],
"country": "IN"
}'{
"success": true,
"source": "facebook_ads_library",
"operation": "search",
"query": "kiro beauty",
"country": "IN",
"total_results": 1,
"time_taken": 2.5,
"ads": [
{
"position": 1,
"ad_archive_id": "1234567890",
"is_active": true,
"page_name": "Kiro Beauty",
"body": "Clean beauty essentials",
"cta_text": "Shop Now",
"image_count": 1,
"video_count": 0,
"publisher_platforms": [
"facebook"
],
"ad_library_url": "https://www.facebook.com/ads/library/?id=1234567890"
}
]
}Ad Filters
Filter Status and Media
Set country, active_status, and media_type to narrow results.
curl -X POST "https://api.datablue.dev/v1/data/facebook-ads/search" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"query": "kiro beauty",
"country": "IN",
"active_status": "active",
"media_type": "video"
}'{
"success": true,
"source": "facebook_ads_library",
"operation": "search",
"query": "kiro beauty",
"country": "IN",
"total_results": 1,
"time_taken": 2.5,
"ads": [
{
"position": 1,
"ad_archive_id": "1234567890",
"is_active": true,
"page_name": "Kiro Beauty",
"body": "Clean beauty essentials",
"cta_text": "Shop Now",
"image_count": 1,
"video_count": 0,
"publisher_platforms": [
"facebook"
],
"ad_library_url": "https://www.facebook.com/ads/library/?id=1234567890"
}
]
}Filter Dates and Platforms
Set start_date, end_date, and publisher_platforms for a bounded campaign view.
curl -X POST "https://api.datablue.dev/v1/data/facebook-ads/search" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"query": "kiro beauty",
"country": "IN",
"start_date": "2026-01-01",
"end_date": "2026-06-30",
"publisher_platforms": [
"facebook",
"instagram"
]
}'{
"success": true,
"source": "facebook_ads_library",
"operation": "search",
"query": "kiro beauty",
"country": "IN",
"total_results": 1,
"time_taken": 2.5,
"ads": [
{
"position": 1,
"ad_archive_id": "1234567890",
"is_active": true,
"page_name": "Kiro Beauty",
"body": "Clean beauty essentials",
"cta_text": "Shop Now",
"image_count": 1,
"video_count": 0,
"publisher_platforms": [
"facebook"
],
"ad_library_url": "https://www.facebook.com/ads/library/?id=1234567890"
}
]
}Details and Pagination
Include Ad Details
Set scrape_ad_details to include available snapshot media and detail fields.
curl -X POST "https://api.datablue.dev/v1/data/facebook-ads/search" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"query": "kiro beauty",
"country": "IN",
"scrape_ad_details": true,
"limit": 10
}'{
"success": true,
"source": "facebook_ads_library",
"operation": "search",
"query": "kiro beauty",
"country": "IN",
"total_results": 1,
"time_taken": 2.5,
"ads": [
{
"position": 1,
"ad_archive_id": "1234567890",
"is_active": true,
"page_name": "Kiro Beauty",
"body": "Clean beauty essentials",
"cta_text": "Shop Now",
"image_count": 1,
"video_count": 0,
"publisher_platforms": [
"facebook"
],
"ad_library_url": "https://www.facebook.com/ads/library/?id=1234567890"
}
]
}Continue with a Cursor
Send the previous cursor and set limit from 1 to 50.
curl -X POST "https://api.datablue.dev/v1/data/facebook-ads/search" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"query": "kiro beauty",
"country": "IN",
"cursor": "NEXT_CURSOR",
"limit": 25
}'{
"success": true,
"source": "facebook_ads_library",
"operation": "search",
"query": "kiro beauty",
"country": "IN",
"total_results": 1,
"time_taken": 2.5,
"ads": [
{
"position": 1,
"ad_archive_id": "1234567890",
"is_active": true,
"page_name": "Kiro Beauty",
"body": "Clean beauty essentials",
"cta_text": "Shop Now",
"image_count": 1,
"video_count": 0,
"publisher_platforms": [
"facebook"
],
"ad_library_url": "https://www.facebook.com/ads/library/?id=1234567890"
}
]
}Request Controls
Set Provider Timeout
Set timeout_ms from 5,000 to 90,000 milliseconds.
curl -X POST "https://api.datablue.dev/v1/data/facebook-ads/search" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"query": "kiro beauty",
"timeout_ms": 45000
}'{
"success": true,
"source": "facebook_ads_library",
"operation": "search",
"query": "kiro beauty",
"country": "IN",
"total_results": 1,
"time_taken": 2.5,
"ads": [
{
"position": 1,
"ad_archive_id": "1234567890",
"is_active": true,
"page_name": "Kiro Beauty",
"body": "Clean beauty essentials",
"cta_text": "Shop Now",
"image_count": 1,
"video_count": 0,
"publisher_platforms": [
"facebook"
],
"ad_library_url": "https://www.facebook.com/ads/library/?id=1234567890"
}
]
}Response
Consume normalized rows from ads; use has_next_page and cursor for pagination.
Error Handling
Handle 401 for authentication, 422 for invalid input, 429 for limits, and retry only transient failures.
