Jkennedy559
Jkennedy559

Reputation: 133

Query Facebook Graph Ad Library API - searching by page ids

I am trying to query the Ad Library API using specific page ids. The below query returns no results despite the page ids belonging to the UK Conservative Party & Boris Johnson. Anyone have any ideas why this wouldn't return any results?

I'm using Python & the requests library for the query.

import requests

access_token = my_access_token

#8807334278 - UK Conservative Party 
#7972991316 - Boris Johnson
page_ids = ['7972991316', '8807334278']

payload = {'access_token': access_token,
           'ad_reached_countries': 'GB',
           'ad_type': 'POLITICAL_AND_ISSUE_ADS',
           'fields': ['id', 'ad_creative_body'],
           'search_page_ids': ','.join(page_ids)}

r = requests.get('https://graph.facebook.com/v6.0/ads_archive', params=payload)

print(r.json())

RESPONSE - {'data': []}

Upvotes: 0

Views: 1105

Answers (1)

Jkennedy559
Jkennedy559

Reputation: 133

Silly mistake on my part. I needed to include 'ad_active_status': 'ALL' given my query was originally searching for 'ad_active_status': 'ACTIVE' by default and the correct response was that there aren't any ads currently active.

Upvotes: 3

Related Questions