Apify example task · whoareyouanas/facebook-ads-library-api

Real estate Facebook ad examples: homes for sale

Collect active US real estate ads that use the exact phrase homes for sale, from home builders, agents and listing sites, with ad copy, creatives, calls to action and landing pages.

Actor
Facebook Ads Library API & Instagram Ads Scraper
Result limit
30 (maxAds)
Estimated cost
Up to $0.12
Run options
0.5 GB memory · 300 s timeout

Example updated 2026-11-23 · actor build 0.2.10 · runs in your own Apify account

01 / About the actor

Facebook Ads Library API & Instagram Ads Scraper

Facebook Ads Library API for developers and AI agents. Search Facebook and Instagram ads by keyword, Page ID or Ad Library URL and get ad copy, images, videos, CTAs, landing pages and dates as JSON in seconds. No Meta token, login or proxy setup. Exact ad limits. MCP-ready.

One focused search

Use one keyword, Page ID, or direct search URL per run.

Bound the ad sample

Set maxAds rather than relying on Meta's approximate displayed result count.

Keep creative structure

Review image, video, carousel, and dynamic creative fields in JSON or dataset exports.

02 / Input

The exact input this example runs.

Provide targetUrl, searchQuery, or pageId and set maxAds for the unique-ad cap. Use the documented country, status, media, and date filters where applicable. The current Actor uses built-in proxies and ignores the legacy proxyConfiguration field.

input.json · real-estate-facebook-ads
{
  "targetUrl": "https://www.facebook.com/ads/library/?active_status=active&ad_type=all&country=US&media_type=all&q=homes%20for%20sale&search_type=keyword_exact_phrase",
  "maxAds": 30
}
Input fields used by this example, their values and what they control
FieldValue in this exampleWhat it controls
targetUrlChange this"https://www.facebook.com/ads/library/?active_status=active&ad_type=all&country=US&media_type=all&q=homes%20for%20sale&search_type=keyword_exact_phrase"Paste any Meta Ad Library search URL from your browser. It takes precedence over Page ID and keyword, and its filters (country, status, platforms, sort, date range) take precedence over the form. Tracking parameters such as fbclid are removed automatically. To look up one ad by its ID, use our Facebook Ad Library Single Ad Lookup.
maxAdsChange this30Maximum unique ads to deliver in this run, from 1 to 10,000. You pay only for ads delivered, and the run stops exactly at this limit.
Other inputs you can add (7)
Deployed actor input fields, types, defaults, and descriptions
FieldType / requiredDefaultPurpose
searchQuerystringNot specifiedFind ads that mention a keyword, brand or product, for example nike or protein powder. The example searches nike. A URL or Page ID takes precedence when provided.
pageIdstringNot specifiedNumeric Facebook Page ID of one advertiser, the number after view_all_page_id= in its Ad Library URL. Takes precedence over the keyword example. A search URL takes precedence over this field.
countrystring"US"Two-letter country code where the ads were shown, such as US, GB, IN or DE, or ALL for every country. Used for keyword and Page ID searches.
activeStatusstring"active"Which ads to return by status. Used for keyword and Page ID searches.

Options: active, inactive, all

mediaTypestring"all"Return only ads with this kind of creative. Used for keyword and Page ID searches.

Options: all, image, video, meme, none

dateFromstringNot specifiedFirst day of the range, YYYY-MM-DD. Leave empty for no start limit.
dateTostringNot specifiedLast day of the range, YYYY-MM-DD. Leave empty for no end limit.

03 / Make it yours

Change these fields for your own research.

  1. 01 · targetUrl

    Ad Library search URL

    Paste any Meta Ad Library search URL from your browser. It takes precedence over Page ID and keyword, and its filters (country, status, platforms, sort, date range) take precedence over the form. Tracking parameters such as fbclid are removed automatically. To look up one ad by its ID, use our Facebook Ad Library Single Ad Lookup.

    Example: "https://www.facebook.com/ads/library/?active_status=active&ad_type=all&country=US&media_type=all&q=homes%20for%20sale&search_type=keyword_exact_phrase"

  2. 02 · maxAds

    Maximum ads

    Maximum unique ads to deliver in this run, from 1 to 10,000. You pay only for ads delivered, and the run stops exactly at this limit.

    Example: 30

Run it in three steps

  1. Open the example on Apify and select Try for free to copy it into your Apify account.
  2. Replace the sample values above with your own target and keep the limit small.
  3. Start the run, then export the dataset as JSON, CSV or Excel.

04 / Output

What the results table shows.

Columns in the “Ads” view

libraryID

Ad ID

brand

Advertiser

pageId

Page ID

active

Active

body

Ad copy

linkTitle

Headline

ctaText

Call to action

linkUrl

Landing page

format

Format

platforms

Platforms

startDate

Started

endDate

Ended

collaboratorName

Partnership creator

images

Images

videos

Videos

adLibraryUrl

View ad

A view selects columns for the table. The full JSON export keeps every field, including nested arrays and objects.

05 / Cost

What this example costs to run.

At most about $0.12: up to 30 results at $0.004 each (Ad). Fewer results cost less. The live Pricing tab on Apify is authoritative.

Prices checked 2026-11-24. Set a run spending limit in Apify when you widen the input.

06 / API

Run the same input from your code.

This call starts a billable run of Facebook Ads Library API & Instagram Ads Scraper with this example's input and returns the dataset items when it finishes. Synchronous calls wait up to five minutes; for longer runs, POST to /runs instead and read the run's default dataset when it succeeds. Keep the token in an environment variable.

cURL · run and return the results
curl --request POST \
  'https://api.apify.com/v2/acts/whoareyouanas~facebook-ads-library-api/run-sync-get-dataset-items?format=json' \
  --header "Authorization: Bearer $APIFY_TOKEN" \
  --header 'Content-Type: application/json' \
  --data '{"targetUrl":"https://www.facebook.com/ads/library/?active_status=active&ad_type=all&country=US&media_type=all&q=homes%20for%20sale&search_type=keyword_exact_phrase","maxAds":30}'

Coverage & interpretation

Check the result before relying on it.

Questions

About this example.

What does the "Real estate Facebook ad examples: homes for sale" example collect?

Collect active US real estate ads that use the exact phrase homes for sale, from home builders, agents and listing sites, with ad copy, creatives, calls to action and landing pages. It runs Facebook Ads Library API & Instagram Ads Scraper, published by whoareyouanas on Apify.

Which input does this example use?

Ad Library search URL (targetUrl) set to "https://www.facebook.com/ads/library/?active_status=active&ad_type=all&country=US&media_type=all&q=homes%20for%20sale&search_type=keyword_exact_phrase"; Maximum ads (maxAds) set to 30. The full JSON input is shown on this page.

How much does it cost to run this example?

At most about $0.12: up to 30 results at $0.004 each (Ad). Fewer results cost less. The live Pricing tab on Apify is authoritative.

How do I change it for my own research?

Open the example on Apify and select Try for free to copy it into your account, then edit Ad Library search URL, Maximum ads. Keep the result limit small for the first run and check the output before scaling up.

Can I run it from the API or on a schedule?

Yes. Send the same JSON input to the Facebook Ads Library API & Instagram Ads Scraper run endpoint with your Apify API token, or save the copied task in your Apify account and add a schedule. Results land in the run's default dataset as JSON, CSV or Excel.

Why does this example use a search URL?

The URL sets search_type=keyword_exact_phrase, so only ads containing the exact phrase homes for sale match. A plain keyword search matches the words in any order and returns broader results.

Can I see ads for my market?

Add your city to the phrase, such as homes for sale in Austin, or enter a local agent's or builder's Facebook Page ID to get only their ads.

More examples

Related tasks you can copy.

Guides

Read more about this workflow.