Back to Blog
Facebook Ads

Facebook Ad Library Scraper: Download Competitor Creatives at Scale

November 25, 2025
4 min read
S
By SociaVault Team
Facebook AdsAd LibraryCompetitor AnalysisScraping

The Facebook Ad Library is the single best resource for marketers. It lets you see exactly what your competitors are running.

But it has a major flaw: It's manual.

You can't "Download All". You can't filter by "Running for > 30 days" (a key signal of a winning ad). You have to click on every single ad to see the details.

If you're an agency or a serious media buyer, you need a better way.

In this guide, we'll build a Facebook Ad Library Scraper using SociaVault. We will automate the process of finding a competitor's page, extracting all their active ads, and saving the creative assets (images/videos) for your swipe file.

The Workflow

  1. Find the Page ID: We need the unique identifier for the brand (e.g., "Monday.com").
  2. Fetch Active Ads: We'll pull a list of all ads currently running.
  3. Download Creatives: We'll extract the high-res image or video URLs.

Prerequisites

You'll need a SociaVault API key. You can get one here.

Step 1: Find Your Competitor's Page ID

You can't just search for "Nike". You need their specific Page ID. We have an endpoint for that.

const axios = require('axios');

const API_KEY = 'YOUR_SOCIAVAULT_API_KEY';
const BASE_URL = 'https://api.sociavault.com/v1';

async function findPageId(brandName) {
  const response = await axios.get(`${BASE_URL}/scrape/facebook-ad-library/search-companies`, {
    params: { query: brandName },
    headers: { 'x-api-key': API_KEY }
  });

  if (response.data.success) {
    const bestMatch = response.data.data[0];
    console.log(`Found Page: ${bestMatch.name} (ID: ${bestMatch.id})`);
    return bestMatch.id;
  }
}

// Example: Find Monday.com
findPageId('Monday.com');

Step 2: Download All Active Ads

Now that we have the Page ID, let's get the ads. We'll use the /company-ads endpoint.

We will filter for:

  • status: 'ACTIVE' (We only care about live ads)
  • country: 'US' (Focus on the US market)
  • media_type: 'VIDEO' (We want video creatives)
async function scrapeCompetitorAds(pageId) {
  console.log(`šŸš€ Scraping active video ads for Page ID: ${pageId}...`);

  try {
    const response = await axios.get(`${BASE_URL}/scrape/facebook-ad-library/company-ads`, {
      params: {
        pageId: pageId,
        status: 'ACTIVE',
        country: 'US',
        media_type: 'VIDEO',
        trim: true // Get clean output
      },
      headers: { 'x-api-key': API_KEY }
    });

    if (response.data.success) {
      const ads = response.data.data;
      console.log(`āœ… Found ${ads.length} active video ads.`);

      // Process the ads
      ads.forEach((ad, index) => {
        console.log(`\n[Ad #${index + 1}]`);
        console.log(`Headline: ${ad.headline || 'No headline'}`);
        console.log(`Started: ${ad.startDate}`);
        console.log(`Video URL: ${ad.videoUrl}`);
        console.log(`CTA: ${ad.ctaType}`);
      });
      
      return ads;
    }
  } catch (error) {
    console.error("Error scraping ads:", error.response?.data || error.message);
  }
}

Step 3: Analyze the "Winners"

The raw data is useful, but the insights come from analyzing the duration.

If an ad has been active for more than 30 days, it is likely profitable. Nobody burns money on a losing ad for a month.

Here is a helper function to filter your results for "Winning Ads":

function filterWinningAds(ads) {
  const thirtyDaysAgo = new Date();
  thirtyDaysAgo.setDate(thirtyDaysAgo.getDate() - 30);

  const winners = ads.filter(ad => {
    const startDate = new Date(ad.startDate);
    return startDate < thirtyDaysAgo;
  });

  console.log(`\nšŸ† Found ${winners.length} "Winning Ads" (Running > 30 Days)`);
  return winners;
}

Why This Matters

By automating this, you can build a Competitor Dashboard that updates every morning.

  • Creative Teams: Get a daily folder of new video ads to reference.
  • Media Buyers: See which headlines are being tested right now.
  • Agencies: Impress clients with deep competitive intelligence.

Comparison: Facebook vs LinkedIn

We recently covered how to do this for LinkedIn Ads. The main difference is volume. Facebook ads churn much faster. You might see 50 new creatives a week on Facebook, versus 5 on LinkedIn.

This makes automation even more critical for Facebook.

Get Started

Ready to build your own Ad Spy tool? Get your API key here.

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.