Facebook Ad Library API and competitor ads tracker
Pull competitors' ads from the Meta Ad Library, Google Ads Transparency Center and LinkedIn Ad Library as JSON: copy, creative, format and dates. Pay per ad.
See what your competitors advertise: the copy, creative and start date of their ads in the Meta Ad Library, the format, regions and dates of their Google ads, and their LinkedIn campaigns. Each ad library is a data tool. You send it the library URL you would open in a browser, and get every ad back as JSON, priced per ad. Run it weekly from a script as a competitor ads tracker, or ask your AI agent to do it.
Hand it to your AI agent
Copy this prompt into Claude Code, Cursor, Codex or any coding agent. It tells the agent where the docs are and how to use your API key.
Track my competitors' ads (copy, creative, format and dates) from the Meta Ad Library, Google Ads Transparency Center and LinkedIn Ad Library. Use the Lovely Router data tools: each returns JSON and is billed per result.
- Docs (read first): https://lovelyrouter.com/docs/tools/find.md and https://lovelyrouter.com/docs/tools/run.md
- Plan first: POST https://lovelyrouter.com/v1/tools/suggest with `{"task": "<my task in plain words>"}` (free). It returns the tools to run in order, each with an example `input`, the `input_required` fields, an estimated cost and a ready-made `run` request. Replace the example values with my task's; if a field is unclear, read the tool with GET https://lovelyrouter.com/v1/tools/<id>. To browse instead, POST https://lovelyrouter.com/v1/tools/discover searches the catalog.
- Show me the plan and its estimated cost (`total_est_cost_usd`) before running anything large.
- Run: POST https://lovelyrouter.com/v1/tools/<id>/run with `{"input": {...}, "max_results": N}`. A 200 has the finished run with `items`; a 202 means it is still running, so poll the `poll` path until `status` is `succeeded`, `failed`, `timed_out` or `stopped`.
- Only delivered results are billed. Keep max_results small on the first run, check the output, then scale up.
- If you support MCP, connect https://lovelyrouter.com/mcp instead (Streamable HTTP, same key; https://lovelyrouter.com/docs/tools/mcp.md) and use suggest_tools, get_tool and run_tool.
- Auth: read my API key from the LOVELY_API_KEY environment variable and send it as `Authorization: Bearer $LOVELY_API_KEY`. Never print or commit the key. If it is not set, ask me to create one at https://lovelyrouter.com/app/keys.
- Billing is prepaid: every call is charged to my balance, so test with a small request before running anything large.
- Every docs page is plain Markdown; the full index is https://lovelyrouter.com/llms.txt.
My task: <the competitors, the countries and what to report about their ads>How it works
Build the library URL
Search the Meta Ad Library as you normally would, with a country, an active status and a keyword, or open an advertiser's Page, and copy the URL. For Google, open the advertiser or domain in the Ads Transparency Center. For LinkedIn, use an Ad Library search URL.
Run the tool
Send the URL to facebook-ads in
urls, or to google-ads-transparency and linkedin-ads instartUrls, with amax_resultscap.Compare over time
Store the ads with their advertiser and dates, run again next week, and diff. A model on the same key can sort the copy into offers, angles and calls to action.
Search the Facebook Ad Library with one request
This run collects up to 100 active US ads that match "meal kit":
curl https://lovelyrouter.com/v1/tools/facebook-ads/run \
-H "Authorization: Bearer $LOVELY_API_KEY" \
-H "content-type: application/json" \
-d '{
"input": {
"urls": [{"url": "https://www.facebook.com/ads/library/?active_status=active&ad_type=all&country=US&q=meal%20kit"}],
"count": 100
},
"max_results": 100
}'Each item in items is one ad with its creative, copy, start date and advertiser. To follow one competitor instead of a keyword, put their Facebook Page URL in urls. Several URLs in one run work too; limitPerSource caps the ads taken from each. A run still going after 60 seconds comes back as 202 with a poll path, as described in Run a tool.
The Google tool takes a Transparency Center URL for an advertiser or a domain:
curl https://lovelyrouter.com/v1/tools/google-ads-transparency/run \
-H "Authorization: Bearer $LOVELY_API_KEY" \
-H "content-type: application/json" \
-d '{"input": {"startUrls": [{"url": "https://adstransparency.google.com/?region=US&domain=nike.com"}]}, "max_results": 50}'It returns each ad's format, text, the dates it was shown and its regions.
The tools
Ads from the Meta Ad Library for a search URL: creative, copy, start date, advertiser.
An advertiser's ads from the Google Ads Transparency Center: format, text, dates shown, regions.
Ads from the LinkedIn Ad Library for an advertiser or keyword search URL: copy, format, dates.
Estimated traffic for websites from Similarweb: monthly visits, ranks, traffic sources, top countries, engagement.
| Library | Tool | Input | What comes back |
|---|---|---|---|
| Meta Ad Library | facebook-ads | urls: Ad Library search URLs or Page URLs; limitPerSource | Creative, copy, start date, advertiser |
| Google Ads Transparency Center | google-ads-transparency | startUrls on adstransparency.google.com for an advertiser or domain; skipDetails | Format, text, dates shown, regions |
| LinkedIn Ad Library | linkedin-ads | startUrls: Ad Library search URLs, or company page URLs | Copy, format, dates |
| Website traffic | website-traffic | domains | Estimated monthly visits, ranks, traffic sources, top countries, engagement |
Tip
For LinkedIn, an Ad Library search URL beats a company page URL: it carries the date and country filters, and the run is faster. For Google, "skipDetails": true lists every ad without opening each one, which is faster but leaves some fields less complete.
Recipes
For each competitor, run facebook-ads on their Page URL, google-ads-transparency on ?region=US&domain=theirdomain.com and linkedin-ads on their Ad Library search. Keep the ads whose start date is newer than last week's run, and post the new ones to your team.
Search the Meta Ad Library for the category keyword in each country you sell in, then ask a model to group the copy by offer (free trial, discount, guarantee) and by audience.
Compare the regions and dates from google-ads-transparency with the traffic sources and top countries that website-traffic reports for the same domain.
Run linkedin-ads on your three closest competitors every month, and read their pricing page with web-fetch to line up each campaign with the offer it points to.
Ask your agent
Connect the MCP server to Claude Code, Cursor or another MCP client, then ask: "Pull the active US ads of these three brands from the Meta Ad Library and the Google Ads Transparency Center, list the ones that started in the last 30 days, and group them by offer. Set max_results on every run." The agent finds the tools with suggest_tools, reads their schemas with get_tool and runs them from your balance.
What you pay
The ad library tools bill per ad returned, and website-traffic bills per site plus a per-call fee. The cards above show today's prices. Starting a run holds its maximum cost, which is the per-call fee plus the per-result fee times max_results, and the run settles to what it actually returned. A run that fails pays only for the ads delivered before it ended, so a failed run with no results costs nothing. There is no subscription: you top up a prepaid balance that also pays for models and other data tools. See pricing.
Frequently asked questions
Is there an API for the Facebook Ad Library?+
The facebook-ads tool is a Meta Ad Library scraper. Send an Ad Library search URL or a Facebook Page URL and get each ad's creative, copy, start date and advertiser as JSON, billed per ad.
Can I filter ads by country?+
Yes, through the URL you send. Set country= in a Meta Ad Library URL, region= in a Google Ads Transparency Center URL, and use a LinkedIn Ad Library search URL, which carries country and date filters.
How do I track only new competitor ads?+
Run the same URLs on a schedule, store each ad with its start date, and keep the ads that started after your previous run. The run object's max_results cap keeps the cost of each run fixed in advance.
Can I see a competitor's Google and LinkedIn ads too?+
Yes. The google-ads-transparency tool returns an advertiser's Google ads with format, text, dates and regions, and the linkedin-ads tool returns LinkedIn ads with copy, format and dates.
Do I need a Meta or Google developer account?+
No. The tools run with the same API key and prepaid balance you use for models, with no separate account. You send the public ad library URL and the tool reads it for you.
For what customers say about those competitors, see social listening and review monitoring; for their products and prices, see e-commerce intelligence.