Skip to main content

Spring Config Client for Python

A lightweight Python client for Spring Cloud Config Server. Load your centralized configuration into Python applications at startup.

Why This Exists

Spring Cloud Config Server is great for centralized configuration management, but Python clients were either outdated or overcomplicated. This library does one thing well: fetch configuration from your Spring Config Server and load it into your application's environment.

Installation

pip install spring-config-client-python

Quick Start

from spring_config_client import SpringConfigClient
import os

# Initialize and load config at application startup
client = SpringConfigClient(
    server_url="https://config.example.com",
    app_name="my-python-service",
    profile="production",
    username="config-admin",  # optional, for basic auth
    password="secret"          # optional
)

# Fetch and load all configuration into os.environ
config = client.fetch_and_load()

# Access your configuration
db_host = os.environ.get('DB_HOST')
api_key = os.environ.get('API_KEY')

How It Works

  1. Fetches configuration from Spring Config Server using the standard API endpoint: /{application}/{profile}
  2. Merges multiple property sources with correct precedence (profile-specific overrides defaults)
  3. Interpolates property placeholders like ${DB_HOST} from existing environment variables
  4. Loads everything into os.environ as-is (including dotted keys like spring.datasource.url)

Configuration Keys

Your Spring Config Server can return keys in any format:

  • Environment variable style: DATABASE_URL, API_KEY
  • Spring property style: spring.datasource.url, logging.level.root
  • Mixed: Whatever you configure in your .properties or .yml files

All keys are loaded as-is into os.environ. No transformation, no magic.

Property Interpolation

The client supports Spring-style property placeholders:

# In your Spring Config Server
DATABASE_URL=postgresql://${DB_HOST}:${DB_PORT}/mydb

The client will resolve ${DB_HOST} and ${DB_PORT} from your existing environment variables.

Features

  • ✅ Loads configuration at startup (no runtime refresh)
  • ✅ Basic authentication support
  • ✅ Property placeholder interpolation (${VAR})
  • ✅ Correct property source precedence
  • ✅ Zero dependencies except requests
  • ✅ Works with Spring Cloud Config Server 2025.0.0

What This Library Does NOT Do

  • ❌ Runtime configuration refresh - load once at startup only
  • ❌ Encryption/decryption - use Spring Config Server's encryption features
  • ❌ Advanced retry logic - fails fast if server is unreachable
  • ❌ Configuration validation - that's your application's responsibility

This is intentional. Keep it simple.

Example with Docker

FROM python:3.11-slim

ENV CONFIG_SERVER_URL=https://config.example.com
ENV CONFIG_APP_NAME=my-service
ENV CONFIG_PROFILE=production

COPY . /app
WORKDIR /app

RUN pip install spring-config-client-python

CMD python app.py
# app.py
import os
from spring_config_client import SpringConfigClient

# Load config from environment
client = SpringConfigClient(
    server_url=os.environ['CONFIG_SERVER_URL'],
    app_name=os.environ['CONFIG_APP_NAME'],
    profile=os.environ['CONFIG_PROFILE']
)

client.fetch_and_load()

# Your application code here

Error Handling

The client fails fast if the config server is unreachable. This is by design - your service shouldn't start without proper configuration.

try:
    client.fetch_and_load()
except requests.RequestException as e:
    print(f"Failed to load configuration: {e}")
    sys.exit(1)

Requirements

  • Python 3.9+
  • Spring Cloud Config Server 2025.0.0 (or compatible versions)

License

MIT

Contributing

Found a bug? Have a feature request? Open an issue on GitHub.

Keep it simple. This library does one thing well and that's enough.

Release files for spring-config-client-python 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for spring-config-client-python 0.1.3
File Size Uploaded
spring_config_client_python-0.1.3.tar.gz 12.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for spring-config-client-python 0.1.3
File Interpreter ABI Platform
spring_config_client_python-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 17.0 kB

Release files / spring_config_client_python-0.1.3.tar.gz

Download URL spring_config_client_python-0.1.3.tar.gz
Size 12.0 kB
Tags Source
SHA-256 checksum
How to use checksums
e1f01d5dda8ab8acf91143760caf1453d84439d455a174aa65cc75814f9519a2
BLAKE2b-256 checksum
How to use checksums
8551fb85d84e68fa337670b90d3e44934f2bd8e378834f1ef21da3f2417d2359
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 11, 2025.

Transparency log

Release files / spring_config_client_python-0.1.3-py3-none-any.whl

Download URL spring_config_client_python-0.1.3-py3-none-any.whl
Size 5.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
39100c41a9da675e15c6dd19bb2caaf4bcaa05a05e511d60296570e7a206387f
BLAKE2b-256 checksum
How to use checksums
3f597a3bc861da954d08a41655d8c32819a404b827d7145506c8e91de2417fe7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 11, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page