{"id":8422,"library":"pinterest-generated-client","title":"Pinterest Generated API Client","description":"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.","status":"active","version":"0.1.11","language":"en","source_language":"en","source_url":"https://github.com/pinterest/pinterest-python-generated-api-client","tags":["api-client","pinterest","rest-api","generated","marketing","e-commerce"],"install":[{"cmd":"pip install pinterest-generated-client","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"HTTP client for API requests.","package":"urllib3"},{"reason":"For date/time parsing and serialization.","package":"python-dateutil"},{"reason":"For handling immutable dictionary structures.","package":"frozendict"},{"reason":"For data validation and serialization (version < 2 required).","package":"pydantic","optional":false},{"reason":"For handling enumerated types.","package":"aenum","optional":false}],"imports":[{"symbol":"Configuration","correct":"import pinterest_generated_client\nconfiguration = pinterest_generated_client.Configuration(...)"},{"symbol":"ApiClient","correct":"import pinterest_generated_client\napi_client = pinterest_generated_client.ApiClient(...)"},{"symbol":"ApiException","correct":"from pinterest_generated_client.rest import ApiException"},{"symbol":"UserAccountApi","correct":"import pinterest_generated_client\napi_instance = pinterest_generated_client.UserAccountApi(api_client)"}],"quickstart":{"code":"import os\nimport pinterest_generated_client\nfrom pinterest_generated_client.rest import ApiException\n\n# Configure OAuth2 access token for authentication\nconfiguration = pinterest_generated_client.Configuration(\n    host = \"https://api-sandbox.pinterest.com/v5\"\n)\nconfiguration.access_token = os.environ.get(\"PINTEREST_ACCESS_TOKEN\", \"\")\n\n# Create an instance of the API client\napi_client = pinterest_generated_client.ApiClient(configuration)\n\n# Create an instance of the specific API you want to use\napi_instance = pinterest_generated_client.UserAccountApi(api_client)\n\ntry:\n    # Get user account information\n    user_account = api_instance.get_user_account()\n    print(\"User Account Data:\", user_account)\nexcept ApiException as e:\n    print(f\"Exception when calling UserAccountApi->get_user_account: {e}\")\n    if e.status == 401:\n        print(\"Hint: Check your PINTEREST_ACCESS_TOKEN environment variable.\")\nexcept Exception as e:\n    print(f\"An unexpected error occurred: {e}\")\nfinally:\n    api_client.close()\n","lang":"python","description":"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."},"warnings":[{"fix":"Ensure your `pip install` command is `pip install pinterest-generated-client` and update all `import` statements to use `pinterest_generated_client`.","message":"The package name for this client changed in version 0.1.5. If you were using an older, pre-0.1.5 version of the Pinterest Python SDK (possibly named differently), your import paths will need to be updated to `pinterest_generated_client`.","severity":"breaking","affected_versions":"<0.1.5"},{"fix":"If you encounter validation errors related to Pydantic, ensure it's installed as `pip install 'pydantic<2'` or add `'pydantic<2'` to your project's `requirements.txt`.","message":"This library explicitly depends on `pydantic < 2`. Installing `pydantic` version 2.x will cause breaking changes and runtime errors due to its major API overhaul. Ensure Pydantic is pinned to a 1.x version.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always check the official Pinterest API documentation and the client's changelog for endpoint deprecations and replacements before upgrading major versions or when encountering unexpected API errors.","message":"Specific API endpoints or parameters may become deprecated or change between versions. For instance, the 'Get catalog product groups' endpoint was deprecated in version 0.1.8.","severity":"deprecated","affected_versions":"0.1.8+"},{"fix":"Explicitly set `configuration.host = \"https://api.pinterest.com/v5\"` for production use.","message":"The quickstart examples often use the sandbox API host (`https://api-sandbox.pinterest.com/v5`). Remember to change this to the production host (`https://api.pinterest.com/v5`) when moving your application to a production environment.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Run `pip install pinterest-generated-client` to install the package. If previously installed, verify the current import paths match the new package name.","cause":"The package is either not installed or was installed under an older, different name. Also, ensure you are running in the correct Python environment.","error":"ModuleNotFoundError: No module named 'pinterest_generated_client'"},{"fix":"Ensure the `PINTEREST_ACCESS_TOKEN` environment variable is correctly set with a valid and unexpired Pinterest access token, or pass it directly via `configuration.access_token`.","cause":"Your Pinterest access token is either missing, expired, or invalid. The API client requires a valid OAuth2 access token to authenticate requests.","error":"pinterest_generated_client.rest.ApiException: (401) Unauthorized"},{"fix":"Manually convert `datetime` objects to ISO 8601 strings (e.g., `my_datetime.isoformat()`) before passing them to API methods if the client does not handle it automatically for your specific use case.","cause":"While the client handles most date/time serialization, custom objects or specific date inputs might not be automatically converted to the expected ISO 8601 string format.","error":"TypeError: 'datetime.datetime' object is not JSON serializable"},{"fix":"Uninstall Pydantic V2 (`pip uninstall pydantic`) and then install Pydantic V1: `pip install 'pydantic<2'`.","cause":"You have Pydantic V2 installed, but this library requires Pydantic V1 (due to the `pydantic < 2` dependency). Pydantic V2 introduced breaking API changes.","error":"pydantic.v1.error_wrappers.ValidationError: ... (or similar Pydantic V1/V2 mismatch errors)"}]}