loading...

February 1, 2025

How to Get Data from Facebook Ads Library API

What is Facebook Ads Library?

Launched in 2018, Facebook Ads Library was created to promote transparency in advertising. It allows you to access all ads related to your industry, including those run by your competitors. The best part? You don’t even need a Facebook account to view them!

Now, Facebook has an Ads Library API, which lets you search ads using custom keywords. This API provides insights into active and inactive ads related to politics, social issues, finance, and more.

Here’s what you can do with the Ads Library API:

  • Search ads related to politics, social issues, and elections from the past 7 years worldwide.
  • Access all ads displayed in the EU within the last year.
  • Retrieve essential details like:
    • Library ID
    • Ad creative content
    • Page name & ID
    • Ad delivery dates
    • Platforms the ad appeared on (Facebook, Instagram, etc.)
    • Spend estimates, impressions, and demographic data (for specific ads)

If you’re familiar with programming, you can unlock deeper insights through the API. If not, start with the Ad Library Report for a more user-friendly experience.


Setting Up Access to Facebook Ads Library API in 3 Easy Steps

Step 1: Log in to Facebook & Verify Your ID

To use the API, you need a confirmed Facebook ID. This process takes around 1-2 days. If you don’t already have one, create an account and get verified.

Step 2: Register for Meta Developer Access

  1. Go to Meta for Developers (Click Here)
  2. Click ‘Get Started’ and agree to the terms & policies.
  3. Once your ID is confirmed, create a new app:
    • Navigate to My Apps > Create App
    • Choose Other under Use Cases
    • Add Marketing API to your app

Your app may start in Development Mode—this is fine for now.

Step 3: Get Your API Access Token

Now, head over to Graph Explorer (Click Here)

  1. In the Meta App field, select your newly created app.
  2. Under Permissions, select all options (there are 38 total).
  3. Click Generate Token.
  4. Connect the app to your assets.

Once the token is generated, you’re ready to make your first API call!


Making API Calls with Facebook Ads Library

Now that you have API access, you can start fetching ad data. Here’s a basic example:

Sample API Request

ads_archive?ad_reached_countries=['GB']&search_page_ids=15087023444&ad_type=all&fields="eu_total_reach"

Breakdown of Parameters:

  • ads_archive? → Accesses the Ads Library
  • ad_reached_countries=['GB'] → Filters for ads seen in the UK
  • search_page_ids=15087023444 → Targets a specific page
  • ad_type=all → Fetches all ad types
  • fields="eu_total_reach" → Retrieves EU reach data

Want more options? Find the full list of parameters here.


Automating Facebook Ads Monitoring with Google Sheets

Want to track ads automatically? You can connect the API to Google Sheets using the free API Connector extension.

Steps to Set Up API Connector:

  1. In Graph Explorer, click Get Code.
  2. Copy the cURL request.
  3. Open Google Sheets & install the API Connector extension.
  4. Paste the cURL request into the Request URL field.
  5. Adjust the output settings as needed.

To schedule regular updates, you’ll need the paid version of API Connector.


Processing & Analyzing Ads Library Data

Once the API sends data to Google Sheets, you can:

  • Monitor competitors’ ad reach daily
  • Analyze total reach or specific ad performance
  • Identify long-running, high-performing ads
  • Use AI (like ChatGPT) to analyze ad text and generate similar content

This is the output you may expect

The final result might be a graph showing the daily reach of the page you’re interested in, like this:

Bonus Use Cases with ChatGPT:

  • Perform semantic analysis on ad text
  • Generate basic insights on competitor strategies
  • Use AI to suggest better ad copies

With these tools in place, you’ll have a powerful ad tracking system without spending a fortune on paid analytics platforms.


What’s Next?

You’re now equipped with the basics of Facebook Ads Library API! Whether you’re a marketer, researcher, or data analyst, this tool can give you a competitive edge in ad tracking and performance analysis.

 

 

Posted in General