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(...)
  • client-level scoped defaults with client.set_scope(project_name, config_name)
  • 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)

Scoped Defaults

If you are repeatedly targeting the same project and config, set a client scope once and omit them from later secrets calls.

from better_python_doppler import Doppler

client = Doppler(service_token="dp.st.example-token").set_scope(
    "my-project",
    "dev",
)

print(client.secrets.list_names())
print(client.secrets.get_raw("API_KEY"))
client.secrets.set("API_KEY", "next-value")

client.clear_scope()

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.1.0.tar.gz (19.8 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.1.0-py3-none-any.whl (16.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: better_python_doppler-2.1.0.tar.gz
  • Upload date:
  • Size: 19.8 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.1.0.tar.gz
Algorithm Hash digest
SHA256 600755a298fea5786cdf9f33cda55442197098ad5cf1f640d6a9acb47ebf3507
MD5 9acfa926c535ab132f434737070fe80f
BLAKE2b-256 14ba34c05798080dc4017e43ac145a33b108cbb18946e998f71021e52e925dbd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for better_python_doppler-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a15d5d9958da310431cfaaabad0f1f8c476ace5dce8688424ae2f3d88ac1e7ab
MD5 6586a5b319b5e9630f77335ac8a9a3af
BLAKE2b-256 3ff4f7d533cb638b1c71b784f3b1ff84fee31c7167a8d8126861f2c74b9c42f9

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