All URIs are relative to https://api.pinterest.com/v5
Method | HTTP request | Description |
---|---|---|
ad_previews_create | POST /ad_accounts/{ad_account_id}/ad_previews | Create ad preview with pin or image |
ad_targeting_analytics_get | GET /ad_accounts/{ad_account_id}/ads/targeting_analytics | Get targeting analytics for ads |
ads_analytics | GET /ad_accounts/{ad_account_id}/ads/analytics | Get ad analytics |
ads_create | POST /ad_accounts/{ad_account_id}/ads | Create ads |
ads_get | GET /ad_accounts/{ad_account_id}/ads/{ad_id} | Get ad |
ads_list | GET /ad_accounts/{ad_account_id}/ads | List ads |
ads_update | PATCH /ad_accounts/{ad_account_id}/ads | Update ads |
AdPreviewURLResponse ad_previews_create(ad_account_id, ad_preview_request)
Create ad preview with pin or image
Create an ad preview given an ad account ID and either an existing organic pin ID or the URL for an image to be used to create the Pin and the ad.
If you are creating a preview from an existing Pin, that Pin must be promotable: that is, it must have a clickthrough link and meet other requirements. (See <a href="https://help.pinterest.com/en/business/article/promoted-pins-overview\" target="_blank">Ads Overview.)
You can view the returned preview URL on a webpage or iframe for 7 days, after which the URL expires. Collection ads are not currently supported ad preview.
- OAuth Authentication (pinterest_oauth2):
import time
import openapi_generated.pinterest_client
from openapi_generated.pinterest_client.api import ads_api
from openapi_generated.pinterest_client.model.error import Error
from openapi_generated.pinterest_client.model.ad_preview_url_response import AdPreviewURLResponse
from openapi_generated.pinterest_client.model.ad_preview_request import AdPreviewRequest
from pprint import pprint
# Defining the host is optional and defaults to https://api.pinterest.com/v5
# See configuration.py for a list of all supported configuration parameters.
configuration = openapi_generated.pinterest_client.Configuration(
host = "https://api.pinterest.com/v5"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure OAuth2 access token for authorization: pinterest_oauth2
configuration = openapi_generated.pinterest_client.Configuration(
host = "https://api.pinterest.com/v5"
)
configuration.access_token = 'YOUR_ACCESS_TOKEN'
# Enter a context with an instance of the API client
with openapi_generated.pinterest_client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = ads_api.AdsApi(api_client)
ad_account_id = "4" # str | Unique identifier of an ad account.
ad_preview_request = AdPreviewRequest(None) # AdPreviewRequest | Create ad preview with pin or image.
# example passing only required values which don't have defaults set
try:
# Create ad preview with pin or image
api_response = api_instance.ad_previews_create(ad_account_id, ad_preview_request)
pprint(api_response)
except openapi_generated.pinterest_client.ApiException as e:
print("Exception when calling AdsApi->ad_previews_create: %s\n" % e)
Name | Type | Description | Notes |
---|---|---|---|
ad_account_id | str | Unique identifier of an ad account. | |
ad_preview_request | AdPreviewRequest | Create ad preview with pin or image. |
- Content-Type: application/json
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | Successful ad preview creation. | - |
400 | Invalid Pin parameters response | - |
0 | Unexpected error | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
MetricsResponse ad_targeting_analytics_get(ad_account_id, ad_ids, start_date, end_date, targeting_types, columns, granularity)
Get targeting analytics for ads
Get targeting analytics for one or more ads. For the requested ad(s) and metrics, the response will include the requested metric information (e.g. SPEND_IN_DOLLAR) for the requested target type (e.g. "age_bucket") for applicable values (e.g. "45-49").
- The token's user_account must either be the Owner of the specified ad account, or have one of the necessary roles granted to them via <a href="https://help.pinterest.com/en/business/article/share-and-manage-access-to-your-ad-accounts\">Business Access: Admin, Analyst, Campaign Manager. - If granularity is not HOUR, the furthest back you can are allowed to pull data is 90 days before the current date in UTC time and the max time range supported is 90 days. - If granularity is HOUR, the furthest back you can are allowed to pull data is 8 days before the current date in UTC time and the max time range supported is 3 days.
- OAuth Authentication (pinterest_oauth2):
import time
import openapi_generated.pinterest_client
from openapi_generated.pinterest_client.api import ads_api
from openapi_generated.pinterest_client.model.error import Error
from openapi_generated.pinterest_client.model.granularity import Granularity
from openapi_generated.pinterest_client.model.ads_analytics_ad_targeting_type import AdsAnalyticsAdTargetingType
from openapi_generated.pinterest_client.model.conversion_report_attribution_type import ConversionReportAttributionType
from openapi_generated.pinterest_client.model.metrics_response import MetricsResponse
from pprint import pprint
# Defining the host is optional and defaults to https://api.pinterest.com/v5
# See configuration.py for a list of all supported configuration parameters.
configuration = openapi_generated.pinterest_client.Configuration(
host = "https://api.pinterest.com/v5"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure OAuth2 access token for authorization: pinterest_oauth2
configuration = openapi_generated.pinterest_client.Configuration(
host = "https://api.pinterest.com/v5"
)
configuration.access_token = 'YOUR_ACCESS_TOKEN'
# Enter a context with an instance of the API client
with openapi_generated.pinterest_client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = ads_api.AdsApi(api_client)
ad_account_id = "4" # str | Unique identifier of an ad account.
ad_ids = [
"4",
] # [str] | List of Ad Ids to use to filter the results.
start_date = dateutil_parser('1970-01-01').date() # date | Metric report start date (UTC). Format: YYYY-MM-DD. Cannot be more than 90 days back from today.
end_date = dateutil_parser('1970-01-01').date() # date | Metric report end date (UTC). Format: YYYY-MM-DD. Cannot be more than 90 days past start_date.
targeting_types = [
AdsAnalyticsAdTargetingType("APPTYPE"),
] # [AdsAnalyticsAdTargetingType] | Targeting type breakdowns for the report. The reporting per targeting type <br> is independent from each other. [\"AGE_BUCKET_AND_GENDER\"] is in BETA and not yet available to all users.
columns = [
"TOTAL_CONVERSIONS",
] # [str] | Columns to retrieve, encoded as a comma-separated string. **NOTE**: Any metrics defined as MICRO_DOLLARS returns a value based on the advertiser profile's currency field. For USD,($1/1,000,000, or $0.000001 - one one-ten-thousandth of a cent). it's microdollars. Otherwise, it's in microunits of the advertiser's currency.<br/>For example, if the advertiser's currency is GBP (British pound sterling), all MICRO_DOLLARS fields will be in GBP microunits (1/1,000,000 British pound).<br/>If a column has no value, it may not be returned
granularity = Granularity("DAY") # Granularity | TOTAL - metrics are aggregated over the specified date range.<br> DAY - metrics are broken down daily.<br> HOUR - metrics are broken down hourly.<br>WEEKLY - metrics are broken down weekly.<br>MONTHLY - metrics are broken down monthly
click_window_days = 1 # int | Number of days to use as the conversion attribution window for a pin click action. Applies to Pinterest Tag conversion metrics. Prior conversion tags use their defined attribution windows. If not specified, defaults to `30` days. (optional) if omitted the server will use the default value of 30
engagement_window_days = 30 # int | Number of days to use as the conversion attribution window for an engagement action. Engagements include saves, closeups, link clicks, and carousel card swipes. Applies to Pinterest Tag conversion metrics. Prior conversion tags use their defined attribution windows. If not specified, defaults to `30` days. (optional) if omitted the server will use the default value of 30
view_window_days = 1 # int | Number of days to use as the conversion attribution window for a view action. Applies to Pinterest Tag conversion metrics. Prior conversion tags use their defined attribution windows. If not specified, defaults to `1` day. (optional) if omitted the server will use the default value of 1
conversion_report_time = "TIME_OF_AD_ACTION" # str | The date by which the conversion metrics returned from this endpoint will be reported. There are two dates associated with a conversion event: the date that the user interacted with the ad, and the date that the user completed a conversion event. (optional) if omitted the server will use the default value of "TIME_OF_AD_ACTION"
attribution_types = ConversionReportAttributionType("INDIVIDUAL") # ConversionReportAttributionType | List of types of attribution for the conversion report (optional)
# example passing only required values which don't have defaults set
try:
# Get targeting analytics for ads
api_response = api_instance.ad_targeting_analytics_get(ad_account_id, ad_ids, start_date, end_date, targeting_types, columns, granularity)
pprint(api_response)
except openapi_generated.pinterest_client.ApiException as e:
print("Exception when calling AdsApi->ad_targeting_analytics_get: %s\n" % e)
# example passing only required values which don't have defaults set
# and optional values
try:
# Get targeting analytics for ads
api_response = api_instance.ad_targeting_analytics_get(ad_account_id, ad_ids, start_date, end_date, targeting_types, columns, granularity, click_window_days=click_window_days, engagement_window_days=engagement_window_days, view_window_days=view_window_days, conversion_report_time=conversion_report_time, attribution_types=attribution_types)
pprint(api_response)
except openapi_generated.pinterest_client.ApiException as e:
print("Exception when calling AdsApi->ad_targeting_analytics_get: %s\n" % e)
Name | Type | Description | Notes |
---|---|---|---|
ad_account_id | str | Unique identifier of an ad account. | |
ad_ids | [str] | List of Ad Ids to use to filter the results. | |
start_date | date | Metric report start date (UTC). Format: YYYY-MM-DD. Cannot be more than 90 days back from today. | |
end_date | date | Metric report end date (UTC). Format: YYYY-MM-DD. Cannot be more than 90 days past start_date. | |
targeting_types | [AdsAnalyticsAdTargetingType] | Targeting type breakdowns for the report. The reporting per targeting type <br> is independent from each other. ["AGE_BUCKET_AND_GENDER"] is in BETA and not yet available to all users. | |
columns | [str] | Columns to retrieve, encoded as a comma-separated string. NOTE: Any metrics defined as MICRO_DOLLARS returns a value based on the advertiser profile's currency field. For USD,($1/1,000,000, or $0.000001 - one one-ten-thousandth of a cent). it's microdollars. Otherwise, it's in microunits of the advertiser's currency.<br/>For example, if the advertiser's currency is GBP (British pound sterling), all MICRO_DOLLARS fields will be in GBP microunits (1/1,000,000 British pound).<br/>If a column has no value, it may not be returned | |
granularity | Granularity | TOTAL - metrics are aggregated over the specified date range.<br> DAY - metrics are broken down daily.<br> HOUR - metrics are broken down hourly.<br>WEEKLY - metrics are broken down weekly.<br>MONTHLY - metrics are broken down monthly | |
click_window_days | int | Number of days to use as the conversion attribution window for a pin click action. Applies to Pinterest Tag conversion metrics. Prior conversion tags use their defined attribution windows. If not specified, defaults to `30` days. | [optional] if omitted the server will use the default value of 30 |
engagement_window_days | int | Number of days to use as the conversion attribution window for an engagement action. Engagements include saves, closeups, link clicks, and carousel card swipes. Applies to Pinterest Tag conversion metrics. Prior conversion tags use their defined attribution windows. If not specified, defaults to `30` days. | [optional] if omitted the server will use the default value of 30 |
view_window_days | int | Number of days to use as the conversion attribution window for a view action. Applies to Pinterest Tag conversion metrics. Prior conversion tags use their defined attribution windows. If not specified, defaults to `1` day. | [optional] if omitted the server will use the default value of 1 |
conversion_report_time | str | The date by which the conversion metrics returned from this endpoint will be reported. There are two dates associated with a conversion event: the date that the user interacted with the ad, and the date that the user completed a conversion event. | [optional] if omitted the server will use the default value of "TIME_OF_AD_ACTION" |
attribution_types | ConversionReportAttributionType | List of types of attribution for the conversion report | [optional] |
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | Success | - |
0 | Unexpected error | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
AdsAnalyticsResponse ads_analytics(ad_account_id, start_date, end_date, columns, granularity)
Get ad analytics
Get analytics for the specified ads in the specified ad_account_id
, filtered by the specified options. - The token's user_account must either be the Owner of the specified ad account, or have one of the necessary roles granted to them via <a href="https://help.pinterest.com/en/business/article/share-and-manage-access-to-your-ad-accounts\">Business Access: Admin, Analyst, Campaign Manager. - The request must contain either ad_ids or both campaign_ids and pin_ids. - If granularity is not HOUR, the furthest back you can are allowed to pull data is 90 days before the current date in UTC time and the max time range supported is 90 days. - If granularity is HOUR, the furthest back you can are allowed to pull data is 8 days before the current date in UTC time and the max time range supported is 3 days.
- OAuth Authentication (pinterest_oauth2):
import time
import openapi_generated.pinterest_client
from openapi_generated.pinterest_client.api import ads_api
from openapi_generated.pinterest_client.model.ads_analytics_response import AdsAnalyticsResponse
from openapi_generated.pinterest_client.model.error import Error
from openapi_generated.pinterest_client.model.granularity import Granularity
from pprint import pprint
# Defining the host is optional and defaults to https://api.pinterest.com/v5
# See configuration.py for a list of all supported configuration parameters.
configuration = openapi_generated.pinterest_client.Configuration(
host = "https://api.pinterest.com/v5"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure OAuth2 access token for authorization: pinterest_oauth2
configuration = openapi_generated.pinterest_client.Configuration(
host = "https://api.pinterest.com/v5"
)
configuration.access_token = 'YOUR_ACCESS_TOKEN'
# Enter a context with an instance of the API client
with openapi_generated.pinterest_client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = ads_api.AdsApi(api_client)
ad_account_id = "4" # str | Unique identifier of an ad account.
start_date = dateutil_parser('1970-01-01').date() # date | Metric report start date (UTC). Format: YYYY-MM-DD. Cannot be more than 90 days back from today.
end_date = dateutil_parser('1970-01-01').date() # date | Metric report end date (UTC). Format: YYYY-MM-DD. Cannot be more than 90 days past start_date.
columns = [
"TOTAL_CONVERSIONS",
] # [str] | Columns to retrieve, encoded as a comma-separated string. **NOTE**: Any metrics defined as MICRO_DOLLARS returns a value based on the advertiser profile's currency field. For USD,($1/1,000,000, or $0.000001 - one one-ten-thousandth of a cent). it's microdollars. Otherwise, it's in microunits of the advertiser's currency.<br/>For example, if the advertiser's currency is GBP (British pound sterling), all MICRO_DOLLARS fields will be in GBP microunits (1/1,000,000 British pound).<br/>If a column has no value, it may not be returned
granularity = Granularity("DAY") # Granularity | TOTAL - metrics are aggregated over the specified date range.<br> DAY - metrics are broken down daily.<br> HOUR - metrics are broken down hourly.<br>WEEKLY - metrics are broken down weekly.<br>MONTHLY - metrics are broken down monthly
ad_ids = [
"4",
] # [str] | List of Ad Ids to use to filter the results. (optional)
click_window_days = 1 # int | Number of days to use as the conversion attribution window for a pin click action. Applies to Pinterest Tag conversion metrics. Prior conversion tags use their defined attribution windows. If not specified, defaults to `30` days. (optional) if omitted the server will use the default value of 30
engagement_window_days = 30 # int | Number of days to use as the conversion attribution window for an engagement action. Engagements include saves, closeups, link clicks, and carousel card swipes. Applies to Pinterest Tag conversion metrics. Prior conversion tags use their defined attribution windows. If not specified, defaults to `30` days. (optional) if omitted the server will use the default value of 30
view_window_days = 1 # int | Number of days to use as the conversion attribution window for a view action. Applies to Pinterest Tag conversion metrics. Prior conversion tags use their defined attribution windows. If not specified, defaults to `1` day. (optional) if omitted the server will use the default value of 1
conversion_report_time = "TIME_OF_AD_ACTION" # str | The date by which the conversion metrics returned from this endpoint will be reported. There are two dates associated with a conversion event: the date that the user interacted with the ad, and the date that the user completed a conversion event. (optional) if omitted the server will use the default value of "TIME_OF_AD_ACTION"
pin_ids = [
"4",
] # [str] | List of Pin IDs. (optional)
campaign_ids = [
"4",
] # [str] | List of Campaign Ids to use to filter the results. (optional)
# example passing only required values which don't have defaults set
try:
# Get ad analytics
api_response = api_instance.ads_analytics(ad_account_id, start_date, end_date, columns, granularity)
pprint(api_response)
except openapi_generated.pinterest_client.ApiException as e:
print("Exception when calling AdsApi->ads_analytics: %s\n" % e)
# example passing only required values which don't have defaults set
# and optional values
try:
# Get ad analytics
api_response = api_instance.ads_analytics(ad_account_id, start_date, end_date, columns, granularity, ad_ids=ad_ids, click_window_days=click_window_days, engagement_window_days=engagement_window_days, view_window_days=view_window_days, conversion_report_time=conversion_report_time, pin_ids=pin_ids, campaign_ids=campaign_ids)
pprint(api_response)
except openapi_generated.pinterest_client.ApiException as e:
print("Exception when calling AdsApi->ads_analytics: %s\n" % e)
Name | Type | Description | Notes |
---|---|---|---|
ad_account_id | str | Unique identifier of an ad account. | |
start_date | date | Metric report start date (UTC). Format: YYYY-MM-DD. Cannot be more than 90 days back from today. | |
end_date | date | Metric report end date (UTC). Format: YYYY-MM-DD. Cannot be more than 90 days past start_date. | |
columns | [str] | Columns to retrieve, encoded as a comma-separated string. NOTE: Any metrics defined as MICRO_DOLLARS returns a value based on the advertiser profile's currency field. For USD,($1/1,000,000, or $0.000001 - one one-ten-thousandth of a cent). it's microdollars. Otherwise, it's in microunits of the advertiser's currency.<br/>For example, if the advertiser's currency is GBP (British pound sterling), all MICRO_DOLLARS fields will be in GBP microunits (1/1,000,000 British pound).<br/>If a column has no value, it may not be returned | |
granularity | Granularity | TOTAL - metrics are aggregated over the specified date range.<br> DAY - metrics are broken down daily.<br> HOUR - metrics are broken down hourly.<br>WEEKLY - metrics are broken down weekly.<br>MONTHLY - metrics are broken down monthly | |
ad_ids | [str] | List of Ad Ids to use to filter the results. | [optional] |
click_window_days | int | Number of days to use as the conversion attribution window for a pin click action. Applies to Pinterest Tag conversion metrics. Prior conversion tags use their defined attribution windows. If not specified, defaults to `30` days. | [optional] if omitted the server will use the default value of 30 |
engagement_window_days | int | Number of days to use as the conversion attribution window for an engagement action. Engagements include saves, closeups, link clicks, and carousel card swipes. Applies to Pinterest Tag conversion metrics. Prior conversion tags use their defined attribution windows. If not specified, defaults to `30` days. | [optional] if omitted the server will use the default value of 30 |
view_window_days | int | Number of days to use as the conversion attribution window for a view action. Applies to Pinterest Tag conversion metrics. Prior conversion tags use their defined attribution windows. If not specified, defaults to `1` day. | [optional] if omitted the server will use the default value of 1 |
conversion_report_time | str | The date by which the conversion metrics returned from this endpoint will be reported. There are two dates associated with a conversion event: the date that the user interacted with the ad, and the date that the user completed a conversion event. | [optional] if omitted the server will use the default value of "TIME_OF_AD_ACTION" |
pin_ids | [str] | List of Pin IDs. | [optional] |
campaign_ids | [str] | List of Campaign Ids to use to filter the results. | [optional] |
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | Success | - |
400 | Invalid ad account ads analytics parameters. | - |
0 | Unexpected error | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
AdArrayResponse ads_create(ad_account_id, ad_create_request)
Create ads
Create multiple new ads. Request must contain ad_group_id, creative_type, and the source Pin pin_id.
- OAuth Authentication (pinterest_oauth2):
import time
import openapi_generated.pinterest_client
from openapi_generated.pinterest_client.api import ads_api
from openapi_generated.pinterest_client.model.ad_create_request import AdCreateRequest
from openapi_generated.pinterest_client.model.error import Error
from openapi_generated.pinterest_client.model.ad_array_response import AdArrayResponse
from pprint import pprint
# Defining the host is optional and defaults to https://api.pinterest.com/v5
# See configuration.py for a list of all supported configuration parameters.
configuration = openapi_generated.pinterest_client.Configuration(
host = "https://api.pinterest.com/v5"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure OAuth2 access token for authorization: pinterest_oauth2
configuration = openapi_generated.pinterest_client.Configuration(
host = "https://api.pinterest.com/v5"
)
configuration.access_token = 'YOUR_ACCESS_TOKEN'
# Enter a context with an instance of the API client
with openapi_generated.pinterest_client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = ads_api.AdsApi(api_client)
ad_account_id = "4" # str | Unique identifier of an ad account.
ad_create_request = [
AdCreateRequest(),
] # [AdCreateRequest] | List of ads to create, size limit [1, 30].
# example passing only required values which don't have defaults set
try:
# Create ads
api_response = api_instance.ads_create(ad_account_id, ad_create_request)
pprint(api_response)
except openapi_generated.pinterest_client.ApiException as e:
print("Exception when calling AdsApi->ads_create: %s\n" % e)
Name | Type | Description | Notes |
---|---|---|---|
ad_account_id | str | Unique identifier of an ad account. | |
ad_create_request | [AdCreateRequest] | List of ads to create, size limit [1, 30]. |
- Content-Type: application/json
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | Success | - |
0 | Unexpected error | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
AdResponse ads_get(ad_account_id, ad_id)
Get ad
Get a specific ad given the ad ID. If your pin is rejected, rejected_reasons will contain additional information from the Ad Review process. For more information about our policies and rejection reasons see the <a href="https://www.pinterest.com/_/_/policy/advertising-guidelines/\" target="_blank">Pinterest advertising standards.
- OAuth Authentication (pinterest_oauth2):
import time
import openapi_generated.pinterest_client
from openapi_generated.pinterest_client.api import ads_api
from openapi_generated.pinterest_client.model.error import Error
from openapi_generated.pinterest_client.model.ad_response import AdResponse
from pprint import pprint
# Defining the host is optional and defaults to https://api.pinterest.com/v5
# See configuration.py for a list of all supported configuration parameters.
configuration = openapi_generated.pinterest_client.Configuration(
host = "https://api.pinterest.com/v5"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure OAuth2 access token for authorization: pinterest_oauth2
configuration = openapi_generated.pinterest_client.Configuration(
host = "https://api.pinterest.com/v5"
)
configuration.access_token = 'YOUR_ACCESS_TOKEN'
# Enter a context with an instance of the API client
with openapi_generated.pinterest_client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = ads_api.AdsApi(api_client)
ad_account_id = "4" # str | Unique identifier of an ad account.
ad_id = "4" # str | Unique identifier of an ad.
# example passing only required values which don't have defaults set
try:
# Get ad
api_response = api_instance.ads_get(ad_account_id, ad_id)
pprint(api_response)
except openapi_generated.pinterest_client.ApiException as e:
print("Exception when calling AdsApi->ads_get: %s\n" % e)
Name | Type | Description | Notes |
---|---|---|---|
ad_account_id | str | Unique identifier of an ad account. | |
ad_id | str | Unique identifier of an ad. |
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | Success | - |
0 | Unexpected error | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
bool, date, datetime, dict, float, int, list, str, none_type ads_list(ad_account_id)
List ads
List ads that meet the filters provided: - Listed campaign ids or ad group ids or ad ids - Listed entity statuses
If no filter is provided, all ads in the ad account are returned.
Note:
Provide only campaign_id or ad_group_id or ad_id. Do not provide more than one type.
Review status is provided for each ad; if review_status is REJECTED, the rejected_reasons field will contain additional information. For more, see <a href="https://policy.pinterest.com/en/advertising-guidelines\">Pinterest advertising standards.
- OAuth Authentication (pinterest_oauth2):
import time
import openapi_generated.pinterest_client
from openapi_generated.pinterest_client.api import ads_api
from openapi_generated.pinterest_client.model.error import Error
from openapi_generated.pinterest_client.model.paginated import Paginated
from openapi_generated.pinterest_client.model.ad_response import AdResponse
from pprint import pprint
# Defining the host is optional and defaults to https://api.pinterest.com/v5
# See configuration.py for a list of all supported configuration parameters.
configuration = openapi_generated.pinterest_client.Configuration(
host = "https://api.pinterest.com/v5"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure OAuth2 access token for authorization: pinterest_oauth2
configuration = openapi_generated.pinterest_client.Configuration(
host = "https://api.pinterest.com/v5"
)
configuration.access_token = 'YOUR_ACCESS_TOKEN'
# Enter a context with an instance of the API client
with openapi_generated.pinterest_client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = ads_api.AdsApi(api_client)
ad_account_id = "4" # str | Unique identifier of an ad account.
campaign_ids = [
"4",
] # [str] | List of Campaign Ids to use to filter the results. (optional)
ad_group_ids = [
"4",
] # [str] | List of Ad group Ids to use to filter the results. (optional)
ad_ids = [
"4",
] # [str] | List of Ad Ids to use to filter the results. (optional)
entity_statuses = ["ACTIVE","PAUSED"] # [str] | Entity status (optional) if omitted the server will use the default value of ["ACTIVE","PAUSED"]
page_size = 25 # int | Maximum number of items to include in a single page of the response. See documentation on <a href='/docs/reference/pagination/'>Pagination</a> for more information. (optional) if omitted the server will use the default value of 25
order = "ASCENDING" # str | The order in which to sort the items returned: “ASCENDING” or “DESCENDING” by ID. Note that higher-value IDs are associated with more-recently added items. (optional)
bookmark = "bookmark_example" # str | Cursor used to fetch the next page of items (optional)
# example passing only required values which don't have defaults set
try:
# List ads
api_response = api_instance.ads_list(ad_account_id)
pprint(api_response)
except openapi_generated.pinterest_client.ApiException as e:
print("Exception when calling AdsApi->ads_list: %s\n" % e)
# example passing only required values which don't have defaults set
# and optional values
try:
# List ads
api_response = api_instance.ads_list(ad_account_id, campaign_ids=campaign_ids, ad_group_ids=ad_group_ids, ad_ids=ad_ids, entity_statuses=entity_statuses, page_size=page_size, order=order, bookmark=bookmark)
pprint(api_response)
except openapi_generated.pinterest_client.ApiException as e:
print("Exception when calling AdsApi->ads_list: %s\n" % e)
Name | Type | Description | Notes |
---|---|---|---|
ad_account_id | str | Unique identifier of an ad account. | |
campaign_ids | [str] | List of Campaign Ids to use to filter the results. | [optional] |
ad_group_ids | [str] | List of Ad group Ids to use to filter the results. | [optional] |
ad_ids | [str] | List of Ad Ids to use to filter the results. | [optional] |
entity_statuses | [str] | Entity status | [optional] if omitted the server will use the default value of ["ACTIVE","PAUSED"] |
page_size | int | Maximum number of items to include in a single page of the response. See documentation on <a href='/docs/reference/pagination/'>Pagination</a> for more information. | [optional] if omitted the server will use the default value of 25 |
order | str | The order in which to sort the items returned: “ASCENDING” or “DESCENDING” by ID. Note that higher-value IDs are associated with more-recently added items. | [optional] |
bookmark | str | Cursor used to fetch the next page of items | [optional] |
bool, date, datetime, dict, float, int, list, str, none_type
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | Success | - |
400 | Invalid ad account ads parameters. | - |
0 | Unexpected error | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
AdArrayResponse ads_update(ad_account_id, ad_update_request)
Update ads
Update multiple existing ads
- OAuth Authentication (pinterest_oauth2):
import time
import openapi_generated.pinterest_client
from openapi_generated.pinterest_client.api import ads_api
from openapi_generated.pinterest_client.model.error import Error
from openapi_generated.pinterest_client.model.ad_array_response import AdArrayResponse
from openapi_generated.pinterest_client.model.ad_update_request import AdUpdateRequest
from pprint import pprint
# Defining the host is optional and defaults to https://api.pinterest.com/v5
# See configuration.py for a list of all supported configuration parameters.
configuration = openapi_generated.pinterest_client.Configuration(
host = "https://api.pinterest.com/v5"
)
# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.
# Configure OAuth2 access token for authorization: pinterest_oauth2
configuration = openapi_generated.pinterest_client.Configuration(
host = "https://api.pinterest.com/v5"
)
configuration.access_token = 'YOUR_ACCESS_TOKEN'
# Enter a context with an instance of the API client
with openapi_generated.pinterest_client.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = ads_api.AdsApi(api_client)
ad_account_id = "4" # str | Unique identifier of an ad account.
ad_update_request = [
AdUpdateRequest(),
] # [AdUpdateRequest] | List of ads to update, size limit [1, 30]
# example passing only required values which don't have defaults set
try:
# Update ads
api_response = api_instance.ads_update(ad_account_id, ad_update_request)
pprint(api_response)
except openapi_generated.pinterest_client.ApiException as e:
print("Exception when calling AdsApi->ads_update: %s\n" % e)
Name | Type | Description | Notes |
---|---|---|---|
ad_account_id | str | Unique identifier of an ad account. | |
ad_update_request | [AdUpdateRequest] | List of ads to update, size limit [1, 30] |
- Content-Type: application/json
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | Success | - |
0 | Unexpected error | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]