Facebook Ad Library Scraper API: Research Competitor Ads at Scale
The Facebook Ad Library contains millions of ads running across Meta's platforms. This guide shows you how to scrape and analyze competitor advertising strategies.
Facebook Ad Library Endpoints
| Endpoint | Description |
|---|---|
| Search | Search ads by keyword |
| Company Ads | Get all ads from a company |
| Ad Details | Get single ad details |
| Search Companies | Find companies in the library |
Search Ads by Keyword
Find ads related to a topic:
const response = await fetch('https://api.sociavault.com/facebook-ad-library/search', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
query: 'saas software'
})
});
const ads = await response.json();
Response
{
"ads": [
{
"id": "123456789",
"pageId": "987654321",
"pageName": "TechCompany",
"adCreativeBody": "Streamline your workflow with our all-in-one platform...",
"adCreativeLink": "https://techcompany.com/signup",
"callToAction": "Sign Up",
"startDate": "2026-01-01",
"endDate": null,
"status": "ACTIVE",
"impressions": {
"lowerBound": 50000,
"upperBound": 100000
},
"spend": {
"lowerBound": 1000,
"upperBound": 5000,
"currency": "USD"
},
"platforms": ["facebook", "instagram"],
"mediaType": "image",
"mediaUrl": "https://..."
}
],
"hasMore": true
}
Get Company Ads
Get all ads a company is running:
const response = await fetch('https://api.sociavault.com/facebook-ad-library/company-ads', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
companyName: 'Nike'
})
});
const companyAds = await response.json();
Search Companies
Find companies in the Ad Library:
const response = await fetch('https://api.sociavault.com/facebook-ad-library/search-companies', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
query: 'Nike'
})
});
const companies = await response.json();
Response
{
"companies": [
{
"id": "123456789",
"name": "Nike",
"pageUrl": "https://www.facebook.com/nike",
"activeAdsCount": 450,
"verified": true
}
]
}
Ad Details
Get comprehensive information about a single ad:
const response = await fetch('https://api.sociavault.com/facebook-ad-library/ad-details', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
id: '123456789'
})
});
const adDetails = await response.json();
Use Cases
Competitor Ad Analysis
Track what competitors are advertising:
async function analyzeCompetitorAds(companyName) {
const { ads } = await getCompanyAds(companyName);
const analysis = {
totalActiveAds: ads.filter(a => a.status === 'ACTIVE').length,
platforms: [...new Set(ads.flatMap(a => a.platforms))],
avgSpend: calculateAvgSpend(ads),
callToActions: countCallToActions(ads),
mediaTypes: countMediaTypes(ads)
};
return analysis;
}
function countCallToActions(ads) {
const ctas = {};
ads.forEach(ad => {
ctas[ad.callToAction] = (ctas[ad.callToAction] || 0) + 1;
});
return ctas;
}
Creative Research
Study ad creative trends:
async function studyCreatives(keyword) {
const { ads } = await searchAds(keyword);
// Group by media type
const byType = {
image: ads.filter(a => a.mediaType === 'image'),
video: ads.filter(a => a.mediaType === 'video'),
carousel: ads.filter(a => a.mediaType === 'carousel')
};
// Analyze performance by type
const performance = Object.entries(byType).map(([type, typeAds]) => ({
type,
count: typeAds.length,
avgImpressions: typeAds.reduce((s, a) => s + a.impressions.upperBound, 0) / typeAds.length
}));
return performance;
}
Track Spend Over Time
Monitor competitor ad spend:
async function trackSpend(companyName) {
const { ads } = await getCompanyAds(companyName);
const totalSpend = ads.reduce((sum, ad) => {
return sum + ((ad.spend.lowerBound + ad.spend.upperBound) / 2);
}, 0);
await saveMetric({
company: companyName,
estimatedSpend: totalSpend,
activeAds: ads.length,
timestamp: new Date()
});
}
Copy Research
Analyze winning ad copy:
async function analyzeCopy(keyword) {
const { ads } = await searchAds(keyword);
// Sort by impressions
const topAds = ads
.sort((a, b) => b.impressions.upperBound - a.impressions.upperBound)
.slice(0, 20);
// Extract copy patterns
const copyPatterns = topAds.map(ad => ({
headline: ad.adCreativeBody.split('.')[0],
cta: ad.callToAction,
length: ad.adCreativeBody.length,
hasEmoji: /[\u{1F300}-\u{1F9FF}]/u.test(ad.adCreativeBody),
hasNumbers: /\d/.test(ad.adCreativeBody)
}));
return copyPatterns;
}
Platform Strategy Analysis
See where competitors advertise:
async function analyzePlatforms(competitors) {
const platformData = {};
for (const company of competitors) {
const { ads } = await getCompanyAds(company);
const platforms = {};
ads.forEach(ad => {
ad.platforms.forEach(p => {
platforms[p] = (platforms[p] || 0) + 1;
});
});
platformData[company] = platforms;
}
return platformData;
}
Related Endpoints
- Google Ad Library - Google ads research
- LinkedIn Ad Library - LinkedIn ads
- Facebook Scraper - Facebook pages & posts
Frequently Asked Questions
What regions are covered?
The Facebook Ad Library covers ads running globally. You can filter by country in your analysis.
How far back does the data go?
The Ad Library contains ads that have run in the last 7 years. Historical ads remain accessible.
Can I see ad targeting?
The Ad Library shows general targeting info (age ranges, locations) but not detailed custom audiences.
Are all ads included?
Active and inactive ads from Pages that run social issue, electoral, or political ads are included. Other ads must meet transparency requirements.
How current is the data?
Ad Library data updates in near real-time. New ads appear within hours of launching.
Get Started
Sign up free and start researching Facebook ads.
Documentation: /docs/api-reference/facebook-ad-library/search
Found this helpful?
Share it with others who might benefit
Ready to Try SociaVault?
Start extracting social media data with our powerful API. No credit card required.