Doppler Python SDK

1.3.0 · active · verified Thu Apr 16

Doppler's SDK provides convenient access to the Doppler API from applications written in Python. It allows developers to manage and synchronize secrets and configuration across environments, with features like collaboration, access controls, and versioning. The current version is 1.3.0, released in April 2024, with a release cadence that includes minor and patch updates based on new API features and bug fixes.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart initializes the DopplerSDK client using an access token, preferably sourced from an environment variable like `DOPPLER_TOKEN`. It then demonstrates how to list available projects. For local development, Doppler recommends using `doppler run` or the `doppler-env` package for secure secret injection without manual token handling.

import os
from pprint import pprint
from dopplersdk import DopplerSDK

# Ensure your Doppler Service Token is set as an environment variable (e.g., DOPPLER_TOKEN)
# For local development, it's recommended to use `doppler run -- python your_app.py`
# or the doppler-env package for IDE integration.
# Alternatively, you can set it directly from an environment variable for server-side use.
DOPPLER_TOKEN = os.environ.get('DOPPLER_TOKEN', '')

if not DOPPLER_TOKEN:
    print("Error: DOPPLER_TOKEN environment variable not set.")
    print("Please ensure you have authenticated the Doppler CLI (doppler login, doppler setup) ")
    print("or set the DOPPLER_TOKEN environment variable.")
else:
    try:
        doppler = DopplerSDK(access_token=DOPPLER_TOKEN)
        # Example: List all projects
        results = doppler.projects.list()
        print("Successfully fetched Doppler projects:")
        pprint(results.to_dict()) # Use .to_dict() to convert the object to a dictionary for pprint
    except Exception as e:
        print(f"An error occurred: {e}")

view raw JSON →