The Python client is currently launched and open to the public. There may be minor API changes in future releases.
The Python client is currently launched and open to the public. There may be minor API changes in future releases.
The Pinterest SDK currently offers a Python library that supports campaign management and simplifies authentication and error handling. We will be adding additional functionality and additional languages over time.
Please submit your feedback here See the README on GitHub in the SDK package for information on installation, getting started, setting your environment variables, examples/use cases, and model documentation. You must use Python 3.7 or greater
You must have an active app
You must have an access token
The Python SDK supports ad campaign creation and management, specifically:
Creating and managing campaigns, ad groups, and ads
Setting ads targeting using keywords
Creating and updating customer lists and audiences
Ad campaign management
Targeting
from pinterest.ads.campaigns import Campaign
campaign = Campaign.create(
ad_account_id="123456",
name="SDK Test Campaign",
objective_type="AWARENESS",
daily_spend_cap=10,
)
from pinterest.ads.ad_groups import AdGroup
AD_ACCOUNT_ID = "123456"
CAMPAIGN_ID = "22334455"
ad_group = AdGroup.create(
ad_account_id=AD_ACCOUNT_ID,
campaign_id=CAMPAIGN_ID,
billable_event="IMPRESSION",
name="My first adgroup from SDK",
)
from pinterest.ads.ads import Ad
AD_ACCOUNT_ID = "12345"
AD_GROUP_ID = "3333444"
PIN_ID = "44445555"
ad = Ad.create(
ad_account_id=AD_ACCOUNT_ID,
ad_group_id=AD_GROUP_ID,
creative_type="REGULAR",
pin_id=PIN_ID,
name="My SDK AD",
status="ACTIVE",
)
from pinterest.ads.customer_lists import CustomerList
AD_ACCOUNT_ID = "12345"
customer_list = CustomerList.create(
ad_account_id=AD_ACCOUNT_ID,
name="SDK Test Customer List",
records="test@pinterest.com,test@example.com",
list_type="EMAIL",
)
from pinterest.ads.keywords import Keyword
AD_ACCOUNT_ID = "12345"
AD_GROUP_ID = "22334455"
keyword = Keyword.create(
ad_account_id=AD_ACCOUNT_ID,
parent_id=AD_GROUP_ID,
value="baby shoes",
match_type="BROAD",
bid=1000,
)
from pinterest.ads.audiences import Audience
AD_ACCOUNT_ID = "12345"
audience = Audience.create(
ad_account_id=AD_ACCOUNT_ID,
name="SDK Test Audience",
rule=dict(
engager_type=1
),
audience_type="ENGAGEMENT",
description="SDK Test Audience Description",
)
Additional information about campaigns and campaign management can be found in: