Metadata-Version: 2.4
Name: compliancelayer
Version: 0.1.1
Summary: Python SDK for the ComplianceLayer security scanning and compliance monitoring API
Project-URL: Homepage, https://compliancelayer.net
Project-URL: Documentation, https://compliancelayer.net/docs
Project-URL: Source, https://github.com/ChainKings/compliancelayer
Project-URL: Issues, https://github.com/ChainKings/compliancelayer/issues
Author-email: Robert Capel <robert@compliancelayer.net>
License-Expression: MIT
License-File: LICENSE
Keywords: api,compliance,infosec,scanning,sdk,security
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: System Administrators
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Security
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.9
Requires-Dist: httpx>=0.24.0
Provides-Extra: dev
Requires-Dist: mypy>=1.8.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
Requires-Dist: pytest>=7.0; extra == 'dev'
Requires-Dist: respx>=0.21.0; extra == 'dev'
Requires-Dist: ruff>=0.3.0; extra == 'dev'
Description-Content-Type: text/markdown

# ComplianceLayer Python SDK

Official Python SDK for the [ComplianceLayer](https://compliancelayer.net) 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

```bash
pip install compliancelayer
```

## Quick start

```python
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:

```python
job = client.scan_async("example.com")

while not job.is_complete:
    job.refresh()

report = job.get_report()
print(report.grade)
```

## Batch scanning

```python
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

```python
# 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

```python
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

```python
history = client.scan_history(limit=10)
for entry in history:
    print(f"{entry.domain}: {entry.grade} ({entry.scanned_at})")
```

## Error handling

```python
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

```python
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
