Python SDK
The official Python SDK for the Generator Labs API v4.0. Includes full type hints with mypy strict mode support.
| Package | generatorlabs (PyPI) |
| Minimum version | Python 3.8+ |
| HTTP client | requests |
| GitHub | generator-labs/python-sdk |
Installation
pip install generatorlabs
Usage
import generatorlabs
client = generatorlabs.Client("your_account_sid", "your_auth_token")
# Get a single host
host = client.rbl.hosts.get("host_id")
# List all hosts with automatic pagination
hosts = client.rbl.hosts.get_all()
# Create a certificate monitor
monitor = client.cert.monitors.create({
"name": "example.com",
})
# Responses support dict-like access
print(host["data"]["name"])
Configuration
config = generatorlabs.Config(
timeout=45,
max_retries=5,
retry_backoff=2.0,
)
client = generatorlabs.Client("your_account_sid", "your_auth_token", config)
| Option | Default | Description |
|---|---|---|
timeout | 30 | Total request timeout in seconds |
connect_timeout | 5 | TCP connection timeout in seconds |
max_retries | 3 | Maximum number of retry attempts |
retry_backoff | 1.0 | Backoff multiplier between retries |
base_url | — | Override the default API base URL |
Webhook Verification
from generatorlabs import Webhook
Webhook.verify(body, signature_header, secret, tolerance)
See Using Web Hooks for more details on webhook payloads and signature verification.
Error Handling
The Python SDK raises generatorlabs.Exception errors that you can catch with standard try / except:
import generatorlabs
try:
host = client.rbl.hosts.get("host_id")
except generatorlabs.Exception as e:
print(e)
Rate Limit Information
Rate limit details are available on every response:
print(response.rate_limit_info.remaining)
print(response.rate_limit_info.reset)
See What Are the API Rate Limits? for more information.