Pinterest Generated API Client

0.1.11 · active · verified Thu Apr 16

The `pinterest-generated-client` is an auto-generated Python SDK for interacting with the Pinterest REST API (v5). It provides programmatic access to Pinterest's platform, enabling developers to manage ads, pins, boards, users, and more. As an auto-generated client, it aims to quickly reflect changes in the Pinterest API specification. It is actively maintained with frequent minor releases reflecting API spec updates.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize the Pinterest API client using an OAuth2 access token from an environment variable and fetch user account details. Remember to set `PINTEREST_ACCESS_TOKEN` before running.

import os
import pinterest_generated_client
from pinterest_generated_client.rest import ApiException

# Configure OAuth2 access token for authentication
configuration = pinterest_generated_client.Configuration(
    host = "https://api-sandbox.pinterest.com/v5"
)
configuration.access_token = os.environ.get("PINTEREST_ACCESS_TOKEN", "")

# Create an instance of the API client
api_client = pinterest_generated_client.ApiClient(configuration)

# Create an instance of the specific API you want to use
api_instance = pinterest_generated_client.UserAccountApi(api_client)

try:
    # Get user account information
    user_account = api_instance.get_user_account()
    print("User Account Data:", user_account)
except ApiException as e:
    print(f"Exception when calling UserAccountApi->get_user_account: {e}")
    if e.status == 401:
        print("Hint: Check your PINTEREST_ACCESS_TOKEN environment variable.")
except Exception as e:
    print(f"An unexpected error occurred: {e}")
finally:
    api_client.close()

view raw JSON →