Skip to main content

Official Doppler client for Python

Project description

DEPRECATED

The new Doppler CLI is exceptionally light and fast, and is provided as a binary to support environments without python. Migrate today by visiting our installation documentation.

Doppler Python Library

contributions welcome image Codacy Badge

The Doppler Python library provides convenient access to the Doppler API from applications written for only server-side code.

Installation

Install the package with:

pip install -U doppler-client

Usage

The package needs to be configured with your account's api key which is available in your Doppler account, pipeline identifier and the environment name:

Environment Variables Required

Please add these environment variables to your .env file in the root directory or on your infra provider.

DOPPLER_API_KEY = <API Key>
DOPPLER_PIPELINE = <Pipeline ID>
DOPPLER_ENVIRONMENT = <Environment Name>

Lookup Priority

Doppler will look for these variables in 3 places with the following priority:

  1. Passed in as initialization arguments
  2. Read from environment variables
  3. Read from .env file

Install with Environment Variables

This installation method will expect the DOPPLER_API_KEY, DOPPLER_PIPELINE, DOPPLER_ENVIRONMENT as environment variables.

from doppler_client import Doppler
Doppler()


# Rest of Application
example_variable = os.getenv("EXAMPLE_VARIABLE")

Install with ENV File

This installation method will expect the DOPPLER_API_KEY, DOPPLER_PIPELINE, DOPPLER_ENVIRONMENT in a .env file.

from doppler_client import Doppler
Doppler({
  "env_filepath": ".env"   # Defaults to ".env"
})


# Rest of Application
example_variable = os.getenv("EXAMPLE_VARIABLE")

Install with Arguments

This installation method will expect the api_key, pipeline, environment as arguments.

from doppler_client import Doppler

Doppler({
  "api_key": os.getenv("DOPPLER_API_KEY"),
  "pipeline": os.getenv("DOPPLER_PIPELINE"),
  "environment": os.getenv("DOPPLER_ENVIRONMENT")
})


# Rest of Application
example_variable = os.getenv("EXAMPLE_VARIABLE")

Key Best Practices

So if Doppler stores my environment variables, where should I keep my Doppler API keys?

That is a great question! We recommend storing your DOPPLER_API_KEY, DOPPLER_PIPELINE, and DOPPLER_ENVIRONMENT in a .env file or with your infra provider. That means the only variables you should be storing in your local environment are the Doppler keys. All other variables should be be fetched by the Doppler client.

Disable Overriding Environment Variables

If you would like to disable overriding environment variables, use this follow field.

from doppler_client import Doppler

doppler = Doppler({
  "override": False
})


# Rest of Your Application
example_variable = doppler.get("EXAMPLE_VARIABLE")

Ignoring Specific Variables

In the case you would want to ignore specific variables from Doppler, say a port set by Heroku, you can add it the ignore_variables field.

from doppler_client import Doppler

Doppler({
  "ignore_variables": ["PORT"]
})

Fallback to Backup

The Doppler client accepts a backup_filepath on init. If provided the client will write the Doppler variables to a backup file. If the Doppler client fails to connect to our API endpoint (very unlikely), the client will fallback to the keys provided in the backup file.

from doppler_client import Doppler

Doppler({
  "backup_filepath": "./backup.env"
})

Extra Information

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for doppler-client, version 1.0.9
Filename, size File type Python version Upload date Hashes
Filename, size doppler_client-1.0.9-py3-none-any.whl (8.4 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size doppler-client-1.0.9.tar.gz (4.3 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page