Code Monkey home page Code Monkey logo

pinterest-python-generated-api-client's Introduction

This client library is not design to be use directly, instead use ours Pinterest Python SDK

Pinterest_Generated_Client

Pinterest's REST API

This Python package is automatically generated by the OpenAPI Generator project:

  • API version: 5.10.0
  • Package version: 0.1.8
  • Build package: org.openapitools.codegen.languages.PythonClientCodegen For more information, please visit https://developers.pinterest.com/

Requirements.

Python >=3.6

Installation & Usage

pip install

If the python package is hosted on a repository, you can install directly using:

Using HTTPS

pip install git+https://github.com/pinterest/pinterest-python-generated-api-client.git

(you may need to run pip with root permission: sudo pip install git+https://github.com/pinterest/pinterest-python-generated-api-client.git)

Using SSH

pip install git+ssh://github.com/pinterest/pinterest-python-generated-api-client.git

(you may need to run pip with root permission: sudo pip install git+https://github.com/pinterest/pinterest-python-generated-api-client.git)

Then import the package:

import openapi_generated.pinterest_client

Setuptools

Install via Setuptools.

python setup.py install --user

(or sudo python setup.py install to install the package for all users)

Then import the package:

import openapi_generated.pinterest_client

Getting Started

Please follow the installation procedure and then run the following:

import time
import openapi_generated.pinterest_client
from pprint import pprint
from openapi_generated.pinterest_client.api import ad_accounts_api
from openapi_generated.pinterest_client.model.ad_account import AdAccount
from openapi_generated.pinterest_client.model.ad_account_analytics_response import AdAccountAnalyticsResponse
from openapi_generated.pinterest_client.model.ad_account_create_request import AdAccountCreateRequest
from openapi_generated.pinterest_client.model.ads_analytics_create_async_request import AdsAnalyticsCreateAsyncRequest
from openapi_generated.pinterest_client.model.ads_analytics_create_async_response import AdsAnalyticsCreateAsyncResponse
from openapi_generated.pinterest_client.model.ads_analytics_get_async_response import AdsAnalyticsGetAsyncResponse
from openapi_generated.pinterest_client.model.ads_analytics_targeting_type import AdsAnalyticsTargetingType
from openapi_generated.pinterest_client.model.conversion_report_attribution_type import ConversionReportAttributionType
from openapi_generated.pinterest_client.model.error import Error
from openapi_generated.pinterest_client.model.granularity import Granularity
from openapi_generated.pinterest_client.model.metrics_response import MetricsResponse
from openapi_generated.pinterest_client.model.paginated import Paginated
# 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 = ad_accounts_api.AdAccountsApi(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
    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) (default to 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) (default to 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) (default to 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) (default to "TIME_OF_AD_ACTION")

    try:
        # Get ad account analytics
        api_response = api_instance.ad_account_analytics(ad_account_id, start_date, end_date, 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)
        pprint(api_response)
    except openapi_generated.pinterest_client.ApiException as e:
        print("Exception when calling AdAccountsApi->ad_account_analytics: %s\n" % e)

Documentation for API Endpoints

All URIs are relative to https://api.pinterest.com/v5

Class Method HTTP request Description
AdAccountsApi ad_account_analytics GET /ad_accounts/{ad_account_id}/analytics Get ad account analytics
AdAccountsApi ad_account_targeting_analytics_get GET /ad_accounts/{ad_account_id}/targeting_analytics Get targeting analytics for an ad account
AdAccountsApi ad_accounts_create POST /ad_accounts Create ad account
AdAccountsApi ad_accounts_get GET /ad_accounts/{ad_account_id} Get ad account
AdAccountsApi ad_accounts_list GET /ad_accounts List ad accounts
AdAccountsApi analytics_create_report POST /ad_accounts/{ad_account_id}/reports Create async request for an account analytics report
AdAccountsApi analytics_create_template_report POST /ad_accounts/{ad_account_id}/templates/{template_id}/reports Create async request for an analytics report using a template
AdAccountsApi analytics_get_report GET /ad_accounts/{ad_account_id}/reports Get the account analytics report created by the async call
AdAccountsApi sandbox_delete DELETE /ad_accounts/{ad_account_id}/sandbox Delete ads data for ad account in API Sandbox
AdAccountsApi templates_list GET /ad_accounts/{ad_account_id}/templates List templates
AdGroupsApi ad_groups_analytics GET /ad_accounts/{ad_account_id}/ad_groups/analytics Get ad group analytics
AdGroupsApi ad_groups_bid_floor_get POST /ad_accounts/{ad_account_id}/bid_floor Get bid floors
AdGroupsApi ad_groups_create POST /ad_accounts/{ad_account_id}/ad_groups Create ad groups
AdGroupsApi ad_groups_get GET /ad_accounts/{ad_account_id}/ad_groups/{ad_group_id} Get ad group
AdGroupsApi ad_groups_list GET /ad_accounts/{ad_account_id}/ad_groups List ad groups
AdGroupsApi ad_groups_targeting_analytics_get GET /ad_accounts/{ad_account_id}/ad_groups/targeting_analytics Get targeting analytics for ad groups
AdGroupsApi ad_groups_update PATCH /ad_accounts/{ad_account_id}/ad_groups Update ad groups
AdsApi ad_previews_create POST /ad_accounts/{ad_account_id}/ad_previews Create ad preview with pin or image
AdsApi ad_targeting_analytics_get GET /ad_accounts/{ad_account_id}/ads/targeting_analytics Get targeting analytics for ads
AdsApi ads_analytics GET /ad_accounts/{ad_account_id}/ads/analytics Get ad analytics
AdsApi ads_create POST /ad_accounts/{ad_account_id}/ads Create ads
AdsApi ads_get GET /ad_accounts/{ad_account_id}/ads/{ad_id} Get ad
AdsApi ads_list GET /ad_accounts/{ad_account_id}/ads List ads
AdsApi ads_update PATCH /ad_accounts/{ad_account_id}/ads Update ads
AudienceInsightsApi audience_insights_get GET /ad_accounts/{ad_account_id}/audience_insights Get audience insights
AudienceInsightsApi audience_insights_scope_and_type_get GET /ad_accounts/{ad_account_id}/insights/audiences Get audience insights scope and type
AudienceInsightsApi audiences_insights_category_list GET /ad_accounts/{ad_account_id}/insights/audiences/{scope}/{type}/{category_id} Get category sub-interest (DEPRECATED)
AudiencesApi audiences_create POST /ad_accounts/{ad_account_id}/audiences Create audience
AudiencesApi audiences_create_custom POST /ad_accounts/{ad_account_id}/audiences/custom Create custom audience
AudiencesApi audiences_get GET /ad_accounts/{ad_account_id}/audiences/{audience_id} Get audience
AudiencesApi audiences_list GET /ad_accounts/{ad_account_id}/audiences List audiences
AudiencesApi audiences_update PATCH /ad_accounts/{ad_account_id}/audiences/{audience_id} Update audience
BoardsApi board_sections_create POST /boards/{board_id}/sections Create board section
BoardsApi board_sections_delete DELETE /boards/{board_id}/sections/{section_id} Delete board section
BoardsApi board_sections_list GET /boards/{board_id}/sections List board sections
BoardsApi board_sections_list_pins GET /boards/{board_id}/sections/{section_id}/pins List Pins on board section
BoardsApi board_sections_update PATCH /boards/{board_id}/sections/{section_id} Update board section
BoardsApi boards_create POST /boards Create board
BoardsApi boards_delete DELETE /boards/{board_id} Delete board
BoardsApi boards_get GET /boards/{board_id} Get board
BoardsApi boards_list GET /boards List boards
BoardsApi boards_list_pins GET /boards/{board_id}/pins List Pins on board
BoardsApi boards_update PATCH /boards/{board_id} Update board
BulkApi bulk_download_create POST /ad_accounts/{ad_account_id}/bulk/download Get advertiser entities in bulk
BulkApi bulk_request_get GET /ad_accounts/{ad_account_id}/bulk/{bulk_request_id} Download advertiser entities in bulk
BulkApi bulk_upsert_create POST /ad_accounts/{ad_account_id}/bulk/upsert Create/update ad entities in bulk
CampaignsApi campaign_targeting_analytics_get GET /ad_accounts/{ad_account_id}/campaigns/targeting_analytics Get targeting analytics for campaigns
CampaignsApi campaigns_analytics GET /ad_accounts/{ad_account_id}/campaigns/analytics Get campaign analytics
CampaignsApi campaigns_create POST /ad_accounts/{ad_account_id}/campaigns Create campaigns
CampaignsApi campaigns_get GET /ad_accounts/{ad_account_id}/campaigns/{campaign_id} Get campaign
CampaignsApi campaigns_list GET /ad_accounts/{ad_account_id}/campaigns List campaigns
CampaignsApi campaigns_update PATCH /ad_accounts/{ad_account_id}/campaigns Update campaigns
CatalogsApi catalogs_product_group_pins_list GET /catalogs/product_groups/{product_group_id}/products List products for a Product Group
CatalogsApi catalogs_product_groups_create POST /catalogs/product_groups Create product group
CatalogsApi catalogs_product_groups_delete DELETE /catalogs/product_groups/{product_group_id} Delete product group
CatalogsApi catalogs_product_groups_get GET /catalogs/product_groups/{product_group_id} Get product group
CatalogsApi catalogs_product_groups_list GET /catalogs/product_groups List product groups
CatalogsApi catalogs_product_groups_product_counts_get GET /catalogs/product_groups/{product_group_id}/product_counts Get product counts for a Product Group
CatalogsApi catalogs_product_groups_update PATCH /catalogs/product_groups/{product_group_id} Update product group
CatalogsApi feed_processing_results_list GET /catalogs/feeds/{feed_id}/processing_results List processing results for a given feed
CatalogsApi feeds_create POST /catalogs/feeds Create feed
CatalogsApi feeds_delete DELETE /catalogs/feeds/{feed_id} Delete feed
CatalogsApi feeds_get GET /catalogs/feeds/{feed_id} Get feed
CatalogsApi feeds_list GET /catalogs/feeds List feeds
CatalogsApi feeds_update PATCH /catalogs/feeds/{feed_id} Update feed
CatalogsApi items_batch_get GET /catalogs/items/batch/{batch_id} Get catalogs items batch
CatalogsApi items_batch_post POST /catalogs/items/batch Operate on item batch
CatalogsApi items_get GET /catalogs/items Get catalogs items
CatalogsApi items_issues_list GET /catalogs/processing_results/{processing_result_id}/item_issues List item issues for a given processing result
CatalogsApi products_by_product_group_filter_list POST /catalogs/products/get_by_product_group_filters List filtered products
ConversionEventsApi events_create POST /ad_accounts/{ad_account_id}/events Send conversion events to the Pinterest API for Conversions
ConversionTagsApi conversion_tags_create POST /ad_accounts/{ad_account_id}/conversion_tags Create conversion tag
ConversionTagsApi conversion_tags_get GET /ad_accounts/{ad_account_id}/conversion_tags/{conversion_tag_id} Get conversion tag
ConversionTagsApi conversion_tags_list GET /ad_accounts/{ad_account_id}/conversion_tags Get conversion tags
ConversionTagsApi ocpm_eligible_conversion_tags_get GET /ad_accounts/{ad_account_id}/conversion_tags/ocpm_eligible Get Ocpm eligible conversion tags
ConversionTagsApi page_visit_conversion_tags_get GET /ad_accounts/{ad_account_id}/conversion_tags/page_visit Get page visit conversion tags
CustomerListsApi customer_lists_create POST /ad_accounts/{ad_account_id}/customer_lists Create customer lists
CustomerListsApi customer_lists_get GET /ad_accounts/{ad_account_id}/customer_lists/{customer_list_id} Get customer list
CustomerListsApi customer_lists_list GET /ad_accounts/{ad_account_id}/customer_lists Get customer lists
CustomerListsApi customer_lists_update PATCH /ad_accounts/{ad_account_id}/customer_lists/{customer_list_id} Update customer list
IntegrationsApi integrations_commerce_del DELETE /integrations/commerce/{external_business_id} Delete commerce integration
IntegrationsApi integrations_commerce_get GET /integrations/commerce/{external_business_id} Get commerce integration
IntegrationsApi integrations_commerce_patch PATCH /integrations/commerce/{external_business_id} Update commerce integration
IntegrationsApi integrations_commerce_post POST /integrations/commerce Create commerce integration
IntegrationsApi integrations_get_by_id GET /integrations/{id} Get integration metadata
IntegrationsApi integrations_get_list GET /integrations Get integration metadata list
InterestsApi interests_followed_interests GET /users/{username}/interests/follow List following interests
KeywordsApi country_keywords_metrics_get GET /ad_accounts/{ad_account_id}/keywords/metrics Get country's keyword metrics
KeywordsApi keywords_create POST /ad_accounts/{ad_account_id}/keywords Create keywords
KeywordsApi keywords_get GET /ad_accounts/{ad_account_id}/keywords Get keywords
KeywordsApi keywords_update PATCH /ad_accounts/{ad_account_id}/keywords Update keywords
KeywordsApi trending_keywords_list GET /trends/keywords/{region}/top/{trend_type} List trending keywords
LeadFormsApi lead_form_get GET /ad_accounts/{ad_account_id}/lead_forms/{lead_form_id} Get lead form by id
LeadFormsApi lead_forms_list GET /ad_accounts/{ad_account_id}/lead_forms Get lead forms
MediaApi media_create POST /media Register media upload
MediaApi media_get GET /media/{media_id} Get media upload details
MediaApi media_list GET /media List media uploads
OauthApi oauth_token POST /oauth/token Generate OAuth access token
OrderLinesApi order_lines_get GET /ad_accounts/{ad_account_id}/order_lines/{order_line_id} Get order line
OrderLinesApi order_lines_list GET /ad_accounts/{ad_account_id}/order_lines Get order lines
PinsApi pins_analytics GET /pins/{pin_id}/analytics Get Pin analytics
PinsApi pins_create POST /pins Create Pin
PinsApi pins_delete DELETE /pins/{pin_id} Delete Pin
PinsApi pins_get GET /pins/{pin_id} Get Pin
PinsApi pins_list GET /pins List Pins
PinsApi pins_save POST /pins/{pin_id}/save Save Pin
PinsApi pins_update PATCH /pins/{pin_id} Update Pin
ProductGroupPromotionsApi product_group_promotions_create POST /ad_accounts/{ad_account_id}/product_group_promotions Create product group promotions
ProductGroupPromotionsApi product_group_promotions_get GET /ad_accounts/{ad_account_id}/product_group_promotions/{product_group_promotion_id} Get a product group promotion by id
ProductGroupPromotionsApi product_group_promotions_list GET /ad_accounts/{ad_account_id}/product_group_promotions Get product group promotions
ProductGroupPromotionsApi product_group_promotions_update PATCH /ad_accounts/{ad_account_id}/product_group_promotions Update product group promotions
ProductGroupPromotionsApi product_groups_analytics GET /ad_accounts/{ad_account_id}/product_groups/analytics Get product group analytics
ProductGroupsApi ad_accounts_catalogs_product_groups_list GET /ad_accounts/{ad_account_id}/product_groups/catalogs Get catalog product groups
ResourcesApi ad_account_countries_get GET /resources/ad_account_countries Get ad accounts countries
ResourcesApi delivery_metrics_get GET /resources/delivery_metrics Get available metrics' definitions
ResourcesApi interest_targeting_options_get GET /resources/targeting/interests/{interest_id} Get interest details
ResourcesApi metrics_ready_state_get GET /resources/metrics_ready_state Get metrics ready state
ResourcesApi targeting_options_get GET /resources/targeting/{targeting_type} Get targeting options
SearchApi search_user_boards_get GET /search/boards Search user's boards
SearchApi search_user_pins_list GET /search/pins Search user's Pins
TermsApi terms_related_list GET /terms/related List related terms
TermsApi terms_suggested_list GET /terms/suggested List suggested terms
TermsOfServiceApi terms_of_service_get GET /ad_accounts/{ad_account_id}/terms_of_service Get terms of service
UserAccountApi boards_user_follows_list GET /user_account/following/boards List following boards
UserAccountApi follow_user_update POST /user_account/following/{username} Follow user
UserAccountApi followers_list GET /user_account/followers List followers
UserAccountApi linked_business_accounts_get GET /user_account/businesses List linked businesses
UserAccountApi unverify_website_delete DELETE /user_account/websites Unverify website
UserAccountApi user_account_analytics GET /user_account/analytics Get user account analytics
UserAccountApi user_account_analytics_top_pins GET /user_account/analytics/top_pins Get user account top pins analytics
UserAccountApi user_account_analytics_top_video_pins GET /user_account/analytics/top_video_pins Get user account top video pins analytics
UserAccountApi user_account_get GET /user_account Get user account
UserAccountApi user_following_get GET /user_account/following List following
UserAccountApi user_websites_get GET /user_account/websites Get user websites
UserAccountApi verify_website_update POST /user_account/websites Verify website
UserAccountApi website_verification_get GET /user_account/websites/verification Get user verification code for website claiming

Documentation For Models

Documentation For Authorization

basic

  • Type: HTTP basic authentication

conversion_token

  • Type: Bearer authentication

pinterest_oauth2

  • Type: OAuth
  • Flow: accessCode
  • Authorization URL: https://www.pinterest.com/oauth/
  • Scopes:
  • ads:read: See all of your advertising data, including ads, ad groups, campaigns etc.
  • ads:write: Create, update, or delete ads, ad groups, campaigns etc.
  • boards:read: See your public boards, including group boards you join
  • boards:read_secret: See your secret boards
  • boards:write: Create, update, or delete your public boards
  • boards:write_secret: Create, update, or delete your secret boards
  • catalogs:read: See all of your catalogs data
  • catalogs:write: Create, update, or delete your catalogs data
  • pins:read: See your public Pins
  • pins:read_secret: See your secret Pins
  • pins:write: Create, update, or delete your public Pins
  • pins:write_secret: Create, update, or delete your secret Pins
  • user_accounts:read: See your user accounts and followers
  • user_accounts:write: Update your user accounts and followers

Author

[email protected]

Notes for Large OpenAPI documents

If the OpenAPI document is large, imports in openapi_generated.pinterest_client.apis and openapi_generated.pinterest_client.models may fail with a RecursionError indicating the maximum recursion limit has been exceeded. In that case, there are a couple of solutions:

Solution 1: Use specific imports for apis and models like:

  • from openapi_generated.pinterest_client.api.default_api import DefaultApi
  • from openapi_generated.pinterest_client.model.pet import Pet

Solution 2: Before importing the package, adjust the maximum recursion limit as shown below:

import sys
sys.setrecursionlimit(1500)
import openapi_generated.pinterest_client
from openapi_generated.pinterest_client.apis import *
from openapi_generated.pinterest_client.models import *

pinterest-python-generated-api-client's People

Contributors

dfana01 avatar rushabhvaria avatar t20 avatar thucngyyen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

pinterest-python-generated-api-client's Issues

Error when running the code

I'm getting this error:

Exception when calling AdAccountsApi->ad_account_analytics: (401)
Reason: Unauthorized
HTTP response headers: HTTPHeaderDict({'Connection': 'keep-alive', 'Content-Length': '64', 'content-type': 'application/json', 'x-content-type-options': 'nosniff', 'x-envoy-upstream-service-time': '0', 'cache-control': 'no-cache, no-store, must-revalidate', 'age': '0', 'set-cookie': '_ir=0; Max-Age=1800; HttpOnly; Path=/; Secure', 'x-pinterest-rid': '1337919202421304', 'Date': 'Tue, 22 Aug 2023 20:50:58 GMT', 'X-CDN': 'fastly', 'alt-svc': 'h3=":443";ma=600', 'Pinterest-Generated-By': 'tpp-api-canary-0a019891'})
HTTP response body: {"code":2,"message":"Authentication failed.","status":"failure"}

I have created the API and it's already Trial access active, so I generate the token for the sandbox environment, which provides access to all these scopes:
https://developers.pinterest.com/docs/getting-started/scopes/#OpenAPI%20security%20definitions

So, I don't know what's the problem. By the way I have Analyst access to the ads account.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.