All URIs are relative to https://api.pinterest.com/v5
Method | HTTP request | Description |
---|---|---|
audiences_create | POST /ad_accounts/{ad_account_id}/audiences | Create audience |
audiences_create_custom | POST /ad_accounts/{ad_account_id}/audiences/custom | Create custom audience |
audiences_get | GET /ad_accounts/{ad_account_id}/audiences/{audience_id} | Get audience |
audiences_list | GET /ad_accounts/{ad_account_id}/audiences | List audiences |
audiences_update | PATCH /ad_accounts/{ad_account_id}/audiences/{audience_id} | Update audience |
Audience audiences_create(ad_account_id, audience_create_request)
Create audience
Create an audience you can use in targeting for specific ad groups. Targeting combines customer information with the ways users interact with Pinterest to help you reach specific groups of users; you can include or exclude specific audience_ids when you create an ad group.
For more, see <a class="reference external" href="https://help.pinterest.com/en/business/article/audience-targeting\" target="_blank">Audience targeting.
- OAuth Authentication (pinterest_oauth2):
import time
import openapi_generated.pinterest_client
from openapi_generated.pinterest_client.api import audiences_api
from openapi_generated.pinterest_client.model.error import Error
from openapi_generated.pinterest_client.model.audience_create_request import AudienceCreateRequest
from openapi_generated.pinterest_client.model.audience import Audience
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 = audiences_api.AudiencesApi(api_client)
ad_account_id = "4" # str | Unique identifier of an ad account.
audience_create_request = AudienceCreateRequest() # AudienceCreateRequest | List of ads to create, size limit [1, 30]
# example passing only required values which don't have defaults set
try:
# Create audience
api_response = api_instance.audiences_create(ad_account_id, audience_create_request)
pprint(api_response)
except openapi_generated.pinterest_client.ApiException as e:
print("Exception when calling AudiencesApi->audiences_create: %s\n" % e)
Name | Type | Description | Notes |
---|---|---|---|
ad_account_id | str | Unique identifier of an ad account. | |
audience_create_request | AudienceCreateRequest | 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]
Audience audiences_create_custom(ad_account_id, audience_create_custom_request)
Create custom audience
Create a custom audience and find the audiences you want your ads to reach.
- OAuth Authentication (pinterest_oauth2):
import time
import openapi_generated.pinterest_client
from openapi_generated.pinterest_client.api import audiences_api
from openapi_generated.pinterest_client.model.error import Error
from openapi_generated.pinterest_client.model.audience_create_custom_request import AudienceCreateCustomRequest
from openapi_generated.pinterest_client.model.audience import Audience
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 = audiences_api.AudiencesApi(api_client)
ad_account_id = "4" # str | Unique identifier of an ad account.
audience_create_custom_request = AudienceCreateCustomRequest() # AudienceCreateCustomRequest | Custom audience to create.
# example passing only required values which don't have defaults set
try:
# Create custom audience
api_response = api_instance.audiences_create_custom(ad_account_id, audience_create_custom_request)
pprint(api_response)
except openapi_generated.pinterest_client.ApiException as e:
print("Exception when calling AudiencesApi->audiences_create_custom: %s\n" % e)
Name | Type | Description | Notes |
---|---|---|---|
ad_account_id | str | Unique identifier of an ad account. | |
audience_create_custom_request | AudienceCreateCustomRequest | Custom audience to create. |
- 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]
Audience audiences_get(ad_account_id, audience_id)
Get audience
Get a specific audience given the audience ID.
- OAuth Authentication (pinterest_oauth2):
import time
import openapi_generated.pinterest_client
from openapi_generated.pinterest_client.api import audiences_api
from openapi_generated.pinterest_client.model.error import Error
from openapi_generated.pinterest_client.model.audience import Audience
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 = audiences_api.AudiencesApi(api_client)
ad_account_id = "4" # str | Unique identifier of an ad account.
audience_id = "4" # str | Unique identifier of an audience
# example passing only required values which don't have defaults set
try:
# Get audience
api_response = api_instance.audiences_get(ad_account_id, audience_id)
pprint(api_response)
except openapi_generated.pinterest_client.ApiException as e:
print("Exception when calling AudiencesApi->audiences_get: %s\n" % e)
Name | Type | Description | Notes |
---|---|---|---|
ad_account_id | str | Unique identifier of an ad account. | |
audience_id | str | Unique identifier of an audience |
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | Success | - |
404 | Audience not found. | - |
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 audiences_list(ad_account_id)
List audiences
Get list of audiences for the ad account.
- OAuth Authentication (pinterest_oauth2):
import time
import openapi_generated.pinterest_client
from openapi_generated.pinterest_client.api import audiences_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.audience import Audience
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 = audiences_api.AudiencesApi(api_client)
ad_account_id = "4" # str | Unique identifier of an ad account.
bookmark = "bookmark_example" # str | Cursor used to fetch the next page of items (optional)
order = "ASCENDING" # str | The order in which to sort the items returned: “ASCENDING” or “DESCENDING” by ID. For received audiences, it is sorted by sharing event time. Note that higher-value IDs are associated with more-recently added items. (optional)
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
ownership_type = "OWNED" # str | Filter audiences by ownership type. (optional) if omitted the server will use the default value of "OWNED"
# example passing only required values which don't have defaults set
try:
# List audiences
api_response = api_instance.audiences_list(ad_account_id)
pprint(api_response)
except openapi_generated.pinterest_client.ApiException as e:
print("Exception when calling AudiencesApi->audiences_list: %s\n" % e)
# example passing only required values which don't have defaults set
# and optional values
try:
# List audiences
api_response = api_instance.audiences_list(ad_account_id, bookmark=bookmark, order=order, page_size=page_size, ownership_type=ownership_type)
pprint(api_response)
except openapi_generated.pinterest_client.ApiException as e:
print("Exception when calling AudiencesApi->audiences_list: %s\n" % e)
Name | Type | Description | Notes |
---|---|---|---|
ad_account_id | str | Unique identifier of an ad account. | |
bookmark | str | Cursor used to fetch the next page of items | [optional] |
order | str | The order in which to sort the items returned: “ASCENDING” or “DESCENDING” by ID. For received audiences, it is sorted by sharing event time. Note that higher-value IDs are associated with more-recently added items. | [optional] |
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 |
ownership_type | str | Filter audiences by ownership type. | [optional] if omitted the server will use the default value of "OWNED" |
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 audience parameters. | - |
0 | Unexpected error | - |
[Back to top] [Back to API list] [Back to Model list] [Back to README]
Audience audiences_update(ad_account_id, audience_id)
Update audience
Update (edit or remove) an existing targeting audience.
- OAuth Authentication (pinterest_oauth2):
import time
import openapi_generated.pinterest_client
from openapi_generated.pinterest_client.api import audiences_api
from openapi_generated.pinterest_client.model.error import Error
from openapi_generated.pinterest_client.model.audience_update_request import AudienceUpdateRequest
from openapi_generated.pinterest_client.model.audience import Audience
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 = audiences_api.AudiencesApi(api_client)
ad_account_id = "4" # str | Unique identifier of an ad account.
audience_id = "4" # str | Unique identifier of an audience
audience_update_request = AudienceUpdateRequest() # AudienceUpdateRequest | The audience to be updated. (optional)
# example passing only required values which don't have defaults set
try:
# Update audience
api_response = api_instance.audiences_update(ad_account_id, audience_id)
pprint(api_response)
except openapi_generated.pinterest_client.ApiException as e:
print("Exception when calling AudiencesApi->audiences_update: %s\n" % e)
# example passing only required values which don't have defaults set
# and optional values
try:
# Update audience
api_response = api_instance.audiences_update(ad_account_id, audience_id, audience_update_request=audience_update_request)
pprint(api_response)
except openapi_generated.pinterest_client.ApiException as e:
print("Exception when calling AudiencesApi->audiences_update: %s\n" % e)
Name | Type | Description | Notes |
---|---|---|---|
ad_account_id | str | Unique identifier of an ad account. | |
audience_id | str | Unique identifier of an audience | |
audience_update_request | AudienceUpdateRequest | The audience to be updated. | [optional] |
- 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]