Call it
curl https://api.peume.com/v1/call/instagram-search-facebook-ad-library-ads-by-keyword \
-H "Authorization: Bearer $PEUME_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"input": {
"query": "running",
"sort_by": "total_impressions",
"search_type": "keyword_unordered",
"ad_type": "all",
"country": "ALL",
"status": "ACTIVE"
}
}'const res = await fetch("https://api.peume.com/v1/call/instagram-search-facebook-ad-library-ads-by-keyword", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.PEUME_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"input": {
"query": "running",
"sort_by": "total_impressions",
"search_type": "keyword_unordered",
"ad_type": "all",
"country": "ALL",
"status": "ACTIVE"
}
}),
});
const { output, cost_usd } = await res.json();import os, requests
res = requests.post(
"https://api.peume.com/v1/call/instagram-search-facebook-ad-library-ads-by-keyword",
headers={"Authorization": f"Bearer {os.environ['PEUME_API_KEY']}"},
json={
"input": {
"query": "running",
"sort_by": "total_impressions",
"search_type": "keyword_unordered",
"ad_type": "all",
"country": "ALL",
"status": "ACTIVE"
}
},
)
print(res.json()["output"])Answer: {"id": "run_…", "status": "completed", "cost_usd": …, "output": {…}}. Long jobs answer 202 with a run id to read later. From an AI agent, connect the MCP server and ask for this by name: instagram-search-facebook-ad-library-ads-by-keyword.
Parameters
queryRequiredstringKeyword to search for
Example: running
sort_bystringOrder only. One of: total_impressions | relevancy_monthly_grouped. Defaults to impressions ranking (total_impressions). Controls result ORDER, not verified performance — does not guarantee non-null spend, impressions_text, or a positive impressions_index. Those fields are often null / -1 for commercial ads and are not verified performance metrics.
total_impressions · relevancy_monthly_grouped
Example: total_impressions
search_typestringIf you want to search by exact phrase or not
Example: keyword_unordered
ad_typestringSearch for all ads or only political and issue ads
Example: all
countrystringThis can only be one country. It has to be the 2 letter code for the country. It defaults to ALL.
Example: ALL
statusstringStatus of the ad. Defaults to ACTIVE.
Example: ACTIVE
media_typestringMedia type of the ad. Defaults to ALL. Meme just means the ad has text and an image. No clue why they call it meme.
Example: ALL
start_datestringImpressions start date. Needs to be in YYYY-MM-DD format.
Example: 2025-01-05
end_datestringImpressions end date. Needs to be in YYYY-MM-DD format.
Example: 2025-02-16
cursorstringCursor to paginate through results
Example: AQHRYLVDkoMkvGv7yK1rcce-vJmKiKv330R4v3j9KHSOaYvmF1bq1QkotG0rgW8Fkrj-
trimbooleanSet to true for a trimmed down version of the response
Example: false
Other ways to do it
Same job, other sources, cheapest first.
