Advertisement
An advertisement from the Meta Ad Library.
Advertisement can be created with:
Advertisement.from_ad_id(context: FacebookContext, ad_id: str) -> Advertisement
Properties
Identity & status
id: str- Advertisement ID.
is_active: bool | None- Whether the ad is currently running.
categories: list[str] | None- Categories assigned to the ad.
start_date: int | None- Unix timestamp when the ad started running.
end_date: int | None- Unix timestamp when the ad stopped running. May be
Nonefor active ads. publisher_platforms: list[str] | None- Platforms the ad runs on, e.g.
"FACEBOOK","INSTAGRAM".
Content
text: str | None- Body text of the ad.
snapshot: AdSnapshot | None- Creative snapshot.
advertiser: Profile | None- Profile of the advertiser that published the ad.
fev_info: AdFevInfo | None- Advertiser verification info.
The advertiser may not be a Facebook profile (e.g. an Instagram profile). It still returns a Profile (props like display_name, url and profile_picture_url) remain accessible. Accessing any other property raises NotFacebookProfileException, since only Facebook profiles can be resolved.
Delivery & spend
impressions: str | None- Estimated impression range, as a display string.
reach_estimate: str | None- Estimated audience reach.
currency: str | None- Currency code used for spend.
spend: str | None- Estimated spend range, as a display string.
Methods
get_collation()-> PaginatedIterator[Advertisement]Other ads in the same collation group: ads that reuse the same creative (image or video and text) but run with different start dates, locations or budgets.
Related types
These types are only returned through Advertisement properties.
AdSnapshot
The ad creative, returned by ad.snapshot.
primary_text: str | None- Main ad text.
headline: str | None- Ad headline.
display_format: str | None- Creative format, e.g.
"IMAGE","VIDEO","CAROUSEL". link_url: str | None- Destination URL.
cta_type: str | None- Call-to-action type.
cta_text: str | None- Call-to-action label.
page_categories: tuple[str, ...] | None- Categories of the advertiser's Page.
page_like_count: int | None- Likes on the advertiser's Page.
images: tuple[AdImage, ...] | None- Images in the creative.
videos: tuple[AdVideo, ...] | None- Videos in the creative.
cards: tuple[AdCard, ...] | None- Carousel cards.
extra_links: tuple[str, ...] | None- Additional links.
extra_texts: tuple[dict, ...] | None- Additional text blocks.
extra_images: tuple[AdImage, ...] | None- Additional images.
extra_videos: tuple[AdVideo, ...] | None- Additional videos.
AdCard
One card of a carousel ad.
title: str | None- Card title.
body: str | None- Card body text.
link_description: str | None- Link description.
link_url: str | None- Card destination URL.
cta_type: str | None- Call-to-action type.
cta_text: str | None- Call-to-action label.
image: AdImage | None- Card image.
video: AdVideo | None- Card video.
AdImage
image_url: str | None- Image URL.
AdVideo
video_url: str | None- Video URL.
preview_image_url: str | None- Preview image URL.
AdFevInfo
Advertiser verification and contact details. - Politic and Issue Ads Only
authorized_entity_text: str | None- Entity authorized to run the ad.
submitted_on: str | None- Date the verification was submitted.
phone: str | None- Contact phone number.
email: str | None- Contact email.
website: str | None- Contact website.
address: str | None- Contact address.
Example
import facebook_gql_scraper as fgs
context = fgs.FacebookContext(cookies_file="facebook_cookies.json")
ad = fgs.Advertisement.from_ad_id(context, ad_id="1145379027885091")
print(ad.id, ad.is_active, ad.advertiser.display_name)
snap = ad.snapshot
if snap:
print(snap.page_categories, snap.display_format)
for card in snap.cards or ():
print(card.title)
# Ads that share the same creative
for similar_ad in ad.get_collation():
print(similar_ad.id, similar_ad.advertiser.display_name)