# How to Read Meta Ad Library Data With an API (Search Active Facebook & Instagram Ads)

Complete developer guide to searching active commercial Facebook & Instagram ads, tracking competitor Page IDs, and transcribing video ad hooks via the Meta Ad Library API & MCP.

Every growth marketer, DTC founder, and media buyer eventually hits the same wall with Meta's official Graph API ( /ads_archive ): after uploading a government ID and waiting for verification, you discover that outside the EU and UK, Meta's official API only returns ads about social issues, elections, or politics —leaving commercial US, Canadian, Australian, and APAC e-commerce or SaaS ads completely blank. Here is how to read active Facebook and Instagram ads programmatically via the SocialToAI Meta Ad Library API . 


## Why Meta's official API blocks commercial ad research

 While anyone can open facebook.com/ads/library in a browser and type a brand name, automating that workflow officially is restricted in three ways: 
 
 - Identity & residency gate: Meta requires personal Facebook login, 2FA, government ID upload, and physical mail verification before granting ads_read archive access.

 - Category restriction outside Europe: Queries for commercial categories (app installs, footwear, skincare, AI SaaS, supplements) in the United States or global markets return empty sets unless the advertiser flagged the ad as political.

 - No video creative transcription: Even when creative metadata is returned, spoken hooks inside video Reels ads require separate media extraction and ASR pipelines.

 


## The 5 Meta Ad Library API operations in SocialToAI

 SocialToAI exposes five specialized operations through POST https://socialtoai.app/v1/call/{op} (and over MCP at https://socialtoai.app/mcp ), each priced at 2 credits per call : 
 
 Operation Required input Typical use case 
 
 meta.ad_search query (+ optional country/media filters) Find active ads matching a product niche, keyword, or domain (30 ads/page). 
 meta.advertiser_search query Resolve a brand name (e.g. "Hoka" or "Notion" ) to its exact Facebook Page ID. 
 meta.advertiser_ads id (Facebook Page ID) Pull every active Facebook, Instagram & Audience Network ad run by that advertiser. 
 meta.ad_detail id (Ad archive ID) Inspect full ad body copy, headline, CTA label, destination URL, and active dates. 
 meta.ad_transcript id (Ad archive ID) Extract the spoken script and timestamps from a video ad creative. 
 
 


## 1. Search active Facebook & Instagram ads by keyword (cURL)

 Pass any product keyword or landing-page domain to meta.ad_search : 

```
curl -X POST "https://socialtoai.app/v1/call/meta.ad_search" \
 -H "Authorization: Bearer $SOCIALTOAI_API_KEY" \
 -H "Idempotency-Key: $(uuidgen)" \
 -H "Content-Type: application/json" \
 -d '{
 "query": "ai note taker"
 }'
```

 Each item in items[] includes normalized fields such as id , format ( image / video ), text , landing_url , first_shown_at , last_shown_at , and advertiser metadata. Ads running continuously for 30+ days ( first_shown_at vs. today) are strong signals of profitable winning creatives. 


## 2. Python workflow: find a competitor's Page ID & list long-running ads

 Combine meta.advertiser_search and meta.advertiser_ads to build an automated competitor creative tracker in 35 lines of Python: 

```
import os
import uuid
import requests

API_KEY = os.environ["SOCIALTOAI_API_KEY"]

def call_op(op: str, payload: dict) -> dict:
 r = requests.post(
 f"https://socialtoai.app/v1/call/{op}",
 headers={
 "Authorization": f"Bearer {API_KEY}",
 "Idempotency-Key": str(uuid.uuid4()),
 "Content-Type": "application/json",
 },
 json=payload,
 timeout=30,
 )
 r.raise_for_status()
 return r.json()

def audit_competitor_ads(brand_name: str):
 pages = call_op("meta.advertiser_search", {"query": brand_name}).get("items", [])
 if not pages:
 return []
 page_id = str(pages[0]["id"])
 ads = call_op("meta.advertiser_ads", {"id": page_id}).get("items", [])
 return [
 {
 "ad_id": ad.get("id"),
 "format": ad.get("format"),
 "landing_url": ad.get("landing_url"),
 "first_shown_at": ad.get("first_shown_at"),
 "copy_preview": (ad.get("text") or "")[:140],
 }
 for ad in ads
 ]

if __name__ == "__main__":
 for row in audit_competitor_ads("Linear")[:5]:
 print(row)
```



## 3. Extract spoken hooks from video ads with meta.ad_transcript

 Static body copy is only half of a Reels or Feed video ad. Once you spot a video ad (`format === "video"`) that has stayed live for weeks, pass its archive ID to POST /v1/call/meta.ad_transcript (2 credits) to read the exact UGC voiceover script and timestamps—letting Claude or GPT rewrite fresh angles grounded in proven ad hooks. 


## Cost breakdown vs. $199/mo ad-spy SaaS subscriptions

 Standalone ad-spy dashboards typically lock teams into $99–$299/month seats even if you only audit creatives once a week. On SocialToAI: 
 
 - 100 free credits on sign-up: Run 50 Meta Ad Library API calls (~1,500 active ads) before paying a cent.

 - $0.23 per 1,000 ads: At $10 for 3,000 credits (never expiring, payable by card or Alipay), monitoring 10 competitors every week for an entire year costs less than a single month of legacy ad-spy software.

 
 Explore all 5 endpoints on the Meta Ad Library API overview or test meta.ad_search right now in the Console Playground .
