A Python client for the Caddy API
Project description
Caddy API Client
A Python client for managing Caddy server configurations through its API.
Installation
- Clone the repository:
git clone https://github.com/migetapp/caddy-api-client.git
cd caddy-api-client
- Install the package in development mode:
pip install -e .
Usage
from caddy_api_client import CaddyAPIClient
# Initialize the client
client = CaddyAPIClient("http://localhost:2019") # Default Caddy admin endpoint
# Add a domain with automatic TLS (Let's Encrypt)
client.add_domain_with_auto_tls(
domain="example.org",
target="nginx",
target_port=80
)
# Add a domain with TLS certificates using PEM data
with open('cert.pem', 'r') as f:
certificate = f.read()
with open('key.pem', 'r') as f:
private_key = f.read()
client.add_domain_with_tls(
domain="example.net",
target="192.168.10.101",
target_port=80,
certificate=certificate,
private_key=private_key
)
# Get domain configuration
config = client.get_domain_config("example.com")
print(config)
# Update domain configuration
client.update_domain(
domain="example.com",
target="172.16.0.2",
target_port=8080
)
# Delete domain
client.delete_domain("example.com")
Features
- Add domains with TLS certificates using PEM data
- Add domains with automatic TLS (Let's Encrypt/ZeroSSL)
- Delete domain configurations
- Get domain configurations
- Update domain configurations
Error Handling
The client includes basic error handling for API requests. All methods will raise exceptions with descriptive messages if something goes wrong during the API calls.
License
This project is licensed under the Apache License, Version 2.0 - see the LICENSE file for details.
Copyright 2025 Krzysztof Taraszka and The Miget Authors.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file caddy_api_client-0.1.0.tar.gz.
File metadata
- Download URL: caddy_api_client-0.1.0.tar.gz
- Upload date:
- Size: 14.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.10.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f6f7911023f4aacc58c6be85ddd6a3f94502036a78d97644e38a16faf14abbc
|
|
| MD5 |
dcde31c4a88964b031bfb38d7bf3e9bb
|
|
| BLAKE2b-256 |
7d0ac10ce8933b15a29969f589e6fcee14a4fd8191f6909628eb9a92b756e2f8
|
File details
Details for the file caddy_api_client-0.1.0-py3-none-any.whl.
File metadata
- Download URL: caddy_api_client-0.1.0-py3-none-any.whl
- Upload date:
- Size: 13.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.10.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d87615206a9fc50c1a2ae1b33739daccfb88bf4080069e307a9e0ad2815e897f
|
|
| MD5 |
5be56145c08cf7c4a6f6ad38bbf6f58a
|
|
| BLAKE2b-256 |
3fe2ac2468e168bfafc9a1397be2ad311815bfdc81ba986192d3caee4c2be737
|