Skip to main content

Lightweight, secrets-first Python SDK for the Doppler API.

Project description

Better Python Doppler

Better Python Doppler is a lightweight, sync, secrets-first Python SDK for the Doppler API.

The supported public surface today is secrets management. This repo is not yet documenting or claiming first-class public support for projects, configs, or environments.

Related repo docs:

Installation

This project currently requires Python 3.12 or newer.

The package name is better-python-doppler.

pip install better-python-doppler

Runtime dependencies are declared in pyproject.toml, including requests and python-dotenv.

For a source checkout, the verified local install path is:

pip install -e .[test]

Current Scope

Supported and documented today:

  • direct token auth with Doppler(service_token="...")
  • explicit environment lookup with Doppler(service_token_environ_name="...")
  • explicit .env loading with Doppler.from_env(...)
  • secrets access through client.secrets
  • compatibility access through client.Secrets
  • top-level compatibility exports: Secrets and SecretsClient
  • SDK exception types exported from better_python_doppler

Supported secrets workflows:

  • list
  • list_names
  • get
  • get_raw
  • as_dict
  • set
  • set_many
  • update as a compatibility wrapper
  • delete
  • update_note
  • download

Not documented as supported public SDK surface yet:

  • projects client
  • configs client
  • environments client

Authentication

Direct Token

from better_python_doppler import Doppler

client = Doppler(service_token="dp.st.example-token")

Explicit Environment Lookup

from better_python_doppler import Doppler

client = Doppler(service_token_environ_name="DOPPLER_SERVICE_TOKEN")

This reads the named environment variable directly. It does not implicitly load .env.

Explicit .env Workflow

from better_python_doppler import Doppler

client = Doppler.from_env(
    "DOPPLER_SERVICE_TOKEN",
    dotenv_path=".env",
    override=False,
)

Use from_env(...) when you want .env loading to be explicit instead of hidden in the base constructor.

Secrets Usage

Recommended usage goes through client.secrets.

from better_python_doppler import Doppler

client = Doppler(service_token="dp.st.example-token")

secret = client.secrets.get("my-project", "dev", "API_KEY")
print(secret.name)
print(secret.value.raw)

raw_value = client.secrets.get_raw("my-project", "dev", "API_KEY")
print(raw_value)

Single Secret Set/Get

updated = client.secrets.set(
    "my-project",
    "dev",
    "API_KEY",
    "next-value",
)

print(updated.value.raw)
print(client.secrets.get_raw("my-project", "dev", "API_KEY"))

Multi-Secret Set/Update

updated = client.secrets.set_many(
    "my-project",
    "dev",
    {
        "API_KEY": "next-value",
        "TIMEOUT": "30",
    },
)

compatibility_result = client.Secrets.update(
    "my-project",
    "dev",
    secrets={
        "API_KEY": "rotated-value",
        "TIMEOUT": "60",
    },
)

set and set_many are the preferred write methods. update(...) remains available for compatibility.

Download

as_json = client.secrets.download("my-project", "dev", format="json")
as_env = client.secrets.download(
    "my-project",
    "dev",
    format="env",
    secrets=["API_KEY", "TIMEOUT"],
)

download(..., format="json") and download(..., format="dotnet-json") return dictionaries. Text formats such as env, yaml, docker, and env-no-quotes return strings.

Compatibility

These compatibility paths are still preserved:

  • client.Secrets returns the same cached object as client.secrets
  • Secrets remains a top-level compatibility alias
  • SecretsClient remains a top-level export

Example:

from better_python_doppler import Doppler

client = Doppler(service_token="dp.st.example-token")
assert client.Secrets is client.secrets

Exceptions

The SDK exports its own exception types:

  • DopplerError
  • DopplerConfigError
  • DopplerTransportError
  • DopplerResponseError
  • DopplerAPIError
  • DopplerAuthError
  • DopplerNotFoundError
  • DopplerValidationError

Offline Examples

The scripts in examples/ are intentionally offline. They use a fake transport so they do not call the live Doppler API.

License

This project is licensed under the Apache 2.0 License. See the LICENSE file for details.

Project details


Download files

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

Source Distribution

better_python_doppler-2.0.0.tar.gz (18.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

better_python_doppler-2.0.0-py3-none-any.whl (15.8 kB view details)

Uploaded Python 3

File details

Details for the file better_python_doppler-2.0.0.tar.gz.

File metadata

  • Download URL: better_python_doppler-2.0.0.tar.gz
  • Upload date:
  • Size: 18.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for better_python_doppler-2.0.0.tar.gz
Algorithm Hash digest
SHA256 c4b0de878eb0a46e46136b0281e2122a76db90b647952418a819335bf8066acb
MD5 dab97682882c2323cbbe1db8807ea238
BLAKE2b-256 7901491811bf31c7b3bb67db7905a86747f84bee3eb40339450f728e1b5930f8

See more details on using hashes here.

File details

Details for the file better_python_doppler-2.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for better_python_doppler-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5e144df8a46565f107067d489e0fb4b4abe5e1d4abc7f4a628b58ee6858d6ba7
MD5 e40fe2549e5e21f902f3f74c28af29ae
BLAKE2b-256 20749e2cc1debdeb44ee903f04392e170fcfb0f84ecf3db78018a479fbe4a2a6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page