ComplianceLayer Python SDK
Official Python SDK for the ComplianceLayer security scanning and compliance monitoring API.
Scan any domain and get a complete security posture report -- DNS, SSL/TLS, open ports, HTTP headers, email authentication, breach exposure, and compliance mapping (SOC 2, PCI DSS, HIPAA, NIST, ISO 27001) -- all from a single API call.
Installation
pip install compliancelayer
Quick start
from compliancelayer import ComplianceLayer
client = ComplianceLayer(api_key="cl_your_key_here")
# Scan a domain (blocks until complete, typically 30-60s)
report = client.scan("example.com")
print(f"Grade: {report.grade}") # "A"
print(f"Score: {report.score}") # 92
print(f"Issues: {report.total_issues}")
for issue in report.findings:
print(f" [{issue.severity}] {issue.finding}")
Async scanning
If you do not want to block, submit the job and poll manually:
job = client.scan_async("example.com")
while not job.is_complete:
job.refresh()
report = job.get_report()
print(report.grade)
Batch scanning
jobs = client.scan_batch(["example.com", "test.com", "demo.org"])
# Wait for all to finish
for job in jobs:
while not job.is_complete:
job.refresh()
report = job.get_report()
print(f"{report.domain}: {report.grade} ({report.score})")
Domain monitoring
# Add a domain for continuous monitoring
domain = client.domains.add("example.com", scan_interval="weekly")
# List all monitored domains
domain_list = client.domains.list()
for d in domain_list.domains:
print(f"{d.domain}: {d.last_grade} (scanned {d.last_scanned_at})")
# Check alerts
alerts = client.domains.alerts(unread_only=True)
for alert in alerts:
print(f"[{alert.severity}] {alert.title}")
# Remove monitoring
client.domains.remove(domain.id)
Account usage
usage = client.usage()
print(f"Plan: {usage.plan}")
print(f"Scans: {usage.scans_used}/{usage.scans_limit}")
print(f"Remaining this month: {usage.scans_remaining}")
print(f"Domain limit: {usage.domains_limit}")
# /v1/auth/me does not report domains in use; read it from the domain list.
print(f"Domains: {client.domains.list().limit_used}/{usage.domains_limit}")
Scan history
history = client.scan_history(limit=10)
for entry in history:
print(f"{entry.domain}: {entry.grade} ({entry.scanned_at})")
Error handling
from compliancelayer import (
ComplianceLayer,
AuthenticationError,
QuotaExceededError,
RateLimitError,
ScanTimeoutError,
)
client = ComplianceLayer(api_key="cl_your_key_here")
try:
report = client.scan("example.com")
except AuthenticationError:
print("Invalid API key")
except QuotaExceededError:
print("Monthly scan quota exceeded -- upgrade your plan")
except RateLimitError as e:
print(f"Rate limited, retry after {e.retry_after}s")
except ScanTimeoutError:
print("Scan took too long -- try again or increase poll_timeout")
Configuration
client = ComplianceLayer(
api_key="cl_your_key_here",
base_url="https://api.compliancelayer.net", # default
timeout=30.0, # HTTP request timeout (seconds)
poll_interval=3.0, # Seconds between status polls
poll_timeout=120.0, # Max seconds to wait for scan completion
max_retries=3, # Auto-retries on 429/5xx errors
)
Requirements
- Python 3.9+
- httpx >= 0.24.0
Links
- Homepage: https://compliancelayer.net
- API Docs: https://compliancelayer.net/docs
- Source: https://github.com/ChainKings/compliancelayer (SDK lives under
sdk/python) - Issues: https://github.com/ChainKings/compliancelayer/issues
License
MIT
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 compliancelayer-0.1.1.tar.gz.
File metadata
- Download URL: compliancelayer-0.1.1.tar.gz
- Upload date:
- Size: 20.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8b2a929b751004f7268c2a44fd64c5c5656e01a0101ef1e3cecc6e54d68eb89d
|
|
| MD5 |
ffd6caaed9a470d6f00ff439964b1e56
|
|
| BLAKE2b-256 |
4bf1e8f8800d0bdca216eb7f11977e0df6749536652c46e1e7c1b5ea5cf05f2f
|
File details
Details for the file compliancelayer-0.1.1-py3-none-any.whl.
File metadata
- Download URL: compliancelayer-0.1.1-py3-none-any.whl
- Upload date:
- Size: 20.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d3beed3c2dda02ffff01a9785f636e198d4db127df9b8a1ccab95be9ba745589
|
|
| MD5 |
fde4225e0b4407e2f908149ba9eba6dd
|
|
| BLAKE2b-256 |
3ed141e92e293289d9ddc750ca0afb2c11b4e91b18f62cb6615b9cad23a0f0b8
|