By Shash7. Posted under guides Posted on 23rd Jul, 2025 - Updated on 17th Sep, 2026
By Shash7. Posted under guides Posted on 23rd Jul, 2025 - Updated on 17th Sep, 2026
Want to pull ad data into a spreadsheet or script? Meta has an official Ad Library API, but its coverage is limited.
An ad being visible in the public library doesn't mean you can fetch it through the API.
Examples checked against Meta's API documentation on 17 September 2026. No authenticated test was run; the JSON output is illustrative.
Here are the two groups Meta currently documents:
The public Ad Library website has broader browsing use cases, including viewing active ads across Meta technologies. The API coverage rules above still apply to API requests, so an API query is not a general-purpose export of every commercial ad currently visible in the Ad Library.
You can request ad IDs, copy, advertiser Pages and delivery information. Spend and targeting fields depend on the ad type and region.
Just browsing? Start with the Facebook Ad Library guide.
Meta requires an access token, but the public Ad Library API page does not promise one fixed token lifetime. Token validity depends on the token type and app configuration, and a token can expire or be revoked. Inspect the token with Meta's current developer tools instead of assuming it will remain valid for a fixed number of months.
Keep access tokens out of source control, screenshots and client-side JavaScript. The examples below use placeholders deliberately.
The endpoint is ads_archive. Replace <API_VERSION> with a supported Graph API version, including the v prefix, and <META_ACCESS_TOKEN> with your token.
This request searches for political or issue ads containing “california” that reached the United States:
curl -G \
--data-urlencode "search_terms=california" \
--data-urlencode "ad_type=POLITICAL_AND_ISSUE_ADS" \
--data-urlencode "ad_reached_countries=['US']" \
--data-urlencode "fields=id,page_id,page_name,ad_snapshot_url,ad_creative_bodies,publisher_platforms,ad_delivery_start_time,ad_delivery_stop_time" \
--data-urlencode "access_token=<META_ACCESS_TOKEN>" \
"https://graph.facebook.com/<API_VERSION>/ads_archive"
Results appear in data, with paging for more pages. Here's an illustrative response:
{
"data": [
{
"id": "1234567890",
"page_id": "123456",
"page_name": "Example Page",
"publisher_platforms": ["FACEBOOK", "INSTAGRAM"],
"ad_creative_bodies": ["Example ad copy"]
}
],
"paging": {
"cursors": {
"before": "CURSOR",
"after": "CURSOR"
},
"next": "https://graph.facebook.com/<API_VERSION>/ads_archive?..."
}
}
This searches for ads containing “shoes” that reached Germany:
curl -G \
--data-urlencode "search_terms=shoes" \
--data-urlencode "ad_type=ALL" \
--data-urlencode "ad_reached_countries=['DE']" \
--data-urlencode "ad_active_status=ALL" \
--data-urlencode "fields=id,page_id,page_name,ad_creative_bodies,ad_snapshot_url" \
--data-urlencode "access_token=<META_ACCESS_TOKEN>" \
"https://graph.facebook.com/<API_VERSION>/ads_archive"
ALL covers ad type and status, but coverage limits still apply. Germany is the delivery country.
Start with these fields, then add more once the request works.
Use the returned cursor to fetch more pages. This example requires Node.js 18+ and stops after five pages.
Set META_ACCESS_TOKEN and META_API_VERSION in your environment first. Save this as fetch-ads.js, then run node fetch-ads.js > ads.json.
async function fetchAds() {
const token = process.env.META_ACCESS_TOKEN;
const version = process.env.META_API_VERSION;
if (!token || !version) {
throw new Error('Set META_ACCESS_TOKEN and META_API_VERSION first.');
}
const endpoint = `https://graph.facebook.com/${version}/ads_archive`;
const params = new URLSearchParams({
search_terms: 'shoes',
ad_type: 'ALL',
ad_reached_countries: JSON.stringify(['DE']),
ad_active_status: 'ALL',
fields: 'id,page_id,page_name,ad_creative_bodies,ad_snapshot_url',
access_token: token,
});
const ads = [];
const maxPages = 5;
let pagesRead = 0;
let hasMore = true;
while (hasMore && pagesRead < maxPages) {
const response = await fetch(`${endpoint}?${params.toString()}`);
const result = await response.json();
if (!response.ok || result.error) {
throw new Error('Meta request failed. Check token, access and fields.');
}
if (!Array.isArray(result.data)) {
throw new Error('Meta returned an unexpected response.');
}
for (const ad of result.data) {
ads.push(ad);
}
pagesRead += 1;
hasMore = Boolean(result.paging && result.paging.next);
if (hasMore) {
const cursors = result.paging.cursors;
if (!cursors || !cursors.after) {
throw new Error('Next page exists, but its cursor is missing.');
}
params.set('after', cursors.after);
}
}
console.log(JSON.stringify({ complete: !hasMore, pagesRead, ads }, null, 2));
}
fetchAds().catch(function (error) {
console.error(error.message);
process.exitCode = 1;
});
complete: false means more pages remain. Failed requests exit with an error. Add retries and rate-limit handling before increasing the page limit.
Snapshot URLs can contain tokens. Keep those exports private.
Quick plug: our Swipekit API gives you access to your saved ads using a workspace key.
The fields you can request depend on the ad type and where it was delivered.
id: the Ad Library ID.page_id and page_name: the Facebook Page associated with the ad.ad_creative_bodies, link titles, descriptions and captions: available creative text.ad_delivery_start_time and ad_delivery_stop_time: delivery dates in UTC.publisher_platforms: Meta technologies where the ad appeared, such as Facebook or Instagram.ad_snapshot_url: a link that displays the archived ad, including its uncompressed creative. Use and storage remain subject to Meta's terms.Request only fields supported for the ad type and location you are querying. Meta may reject an incompatible field or return it without a value.
ad_reached_countries is required. Meta's overview includes UK and EU commercial ads, while its country-parameter note still refers to EU delivery. The commercial example above uses Germany; check a UK-only request against the current reference before relying on it.search_terms is limited to 100 characters. Use search_type to choose unordered keywords or an exact phrase.search_page_ids accepts up to ten Facebook Page IDs in one request.ALL, IMAGE, MEME, VIDEO and NONE.id values.Confirm that the access token is present, belongs to the correct app and remains valid. Generate or inspect tokens through Meta's current developer tooling; do not rely on an old token-lifetime assumption.
Complete identity and location confirmation, confirm the Meta developer account and app are configured, and use the Access the API flow. Access for one Facebook account or app should not be assumed to apply automatically to every other account or app.
Empty data array? Check these:
ad_active_status=ALL to include inactive eligible ads.search_page_ids takes Facebook Page IDs.If the response contains an error, fix that first.
Many spend, reach, targeting and demographic fields are restricted by ad type or delivery location. Remove incompatible fields, confirm the ad's coverage and retry with the smallest working field list.
Read the paging object and follow the next cursor until there is no next page. Apply your own stopping and retry rules so a failed page does not silently truncate a large export.
At a high level, Meta is the official API, but extremely limited. Swipekit is not official and only gives access to your own saved ads.
| Capability | Official Meta Ad Library API | Swipekit API |
|---|---|---|
| Platforms covered | Meta technologies within Meta's documented ad-type and regional coverage | Saved ad research in your Swipekit workspace; the current API specification documents network filters such as Facebook, Instagram and TikTok |
| Service owner | Official Meta transparency API | Independent Swipekit service |
| Authentication | Meta app access token after the required authorization process | Swipekit workspace API key sent as a Bearer token |
| Creative and media data | Creative text and an ad snapshot URL for eligible ads, subject to Meta's field and usage rules | Available fields and saved asset references attached to records already stored in the Swipekit workspace |
| Typical user | Researchers and developers querying Meta's eligible transparency archive | Agencies and marketing teams connecting saved ad research to dashboards, automations and internal tools |
| Documentation | Meta Ad Library API | Swipekit API reference |
Use Meta's official API when your task fits its transparency coverage and fields. Use the Swipekit API when you need programmatic access to the research your team has already collected in Swipekit.
Ready to connect your saved research to an internal tool? Review the Swipekit Ad Library API documentation, create a workspace, and generate an API key from workspace settings.
Save winning ads from every major library, keep the full context, and turn scattered inspiration into reusable creative direction.
Start free trial
AG1 by Athletic Greens
Meet Your New Supplement Routine ✅
Feel Reformed
Upgrade your Matcha
HEC Wellness Center
AG1 by Athletic Greens
Meet Your New Supplement Routine ✅
Feel Reformed
Upgrade your Matcha
HEC Wellness Center