Official Python SDK for the Law4Devs EU Regulatory Compliance API
Project description
law4devs
Official Python SDK for the Law4Devs EU Regulatory Compliance API.
Access structured, developer-friendly data for EU regulations — GDPR, Cyber Resilience Act, NIS2, AI Act, and more.
Installation
pip install law4devs
Python 3.9+ required. Zero runtime dependencies (stdlib urllib only).
Quick Start
from law4devs import Law4DevsClient
client = Law4DevsClient()
# List all frameworks
page = client.frameworks.list()
for fw in page:
print(fw.slug, fw.name)
# Get framework detail
cra = client.frameworks.get("cra")
print(cra.name, cra.requirement_count)
# Fetch a specific article
article = client.articles.get("cra", 13)
print(article.title, article.content)
Authentication
The public API tier does not require authentication. Authenticated tiers provide higher rate limits:
client = Law4DevsClient(api_key="your-api-key")
Resources
Frameworks
page = client.frameworks.list(page=1, per_page=10)
print(page.meta.total, page.meta.pages)
cra = client.frameworks.get("cra")
for fw in client.frameworks.iter():
print(fw.slug)
Articles
page = client.articles.list("cra", per_page=20)
art = client.articles.get("cra", 13)
related = client.articles.related("cra", 13)
for art in client.articles.iter("cra"):
print(art.article_number, art.title)
Recitals
page = client.recitals.list("cra")
recital = client.recitals.get("cra", 10)
for recital in client.recitals.iter("cra"):
print(recital.recital_number, recital.content[:80])
Requirements
page = client.requirements.list()
page = client.requirements.list(framework_slug="cra")
for req in client.requirements.iter(framework_slug="cra"):
print(req.requirement_type, req.requirement_text[:60])
Compliance Deadlines
page = client.compliance.deadlines()
page = client.compliance.deadlines(framework_slug="nis2")
for d in client.compliance.iter_deadlines(framework_slug="nis2"):
print(d.deadline_date, d.description)
Tags
page = client.tags.list()
tag = client.tags.get("security")
for tag in client.tags.iter():
print(tag.slug, tag.name)
Annexes
page = client.annexes.list("cra")
annex = client.annexes.get("cra", "I")
for annex in client.annexes.iter("cra"):
print(annex.annex_number, annex.title)
Search
results = client.search.query("vulnerability reporting")
results = client.search.query("audit", framework="gdpr")
results = client.search.query("encryption", result_type="requirement")
Auto-Pagination
All list resources support iter() which automatically fetches all pages:
all_articles = list(client.articles.iter("cra"))
for art in client.articles.iter("cra", per_page=50):
process(art)
Error Handling
from law4devs import Law4DevsClient, NotFoundError, RateLimitError, Law4DevsError
client = Law4DevsClient()
try:
fw = client.frameworks.get("nonexistent")
except NotFoundError as e:
print(f"Not found: {e} (status {e.status_code})")
except RateLimitError:
print("Rate limited — slow down requests")
except Law4DevsError as e:
print(f"API error: {e}")
Exception Hierarchy
| Exception | HTTP Status | Description |
|---|---|---|
Law4DevsError |
any | Base exception |
NotFoundError |
404 | Resource not found |
ValidationError |
400 | Invalid request parameters |
RateLimitError |
429 | Rate limit exceeded |
ServerError |
5xx | Server-side error |
Configuration
| Parameter | Default | Description |
|---|---|---|
base_url |
https://api.law4devs.eu/v1 |
API base URL |
api_key |
None |
API key for authenticated tiers |
timeout |
30 |
Request timeout in seconds |
max_retries |
3 |
Retries on 429/5xx with exponential backoff |
Available Frameworks
| Slug | Name | CELEX | Status |
|---|---|---|---|
cra |
Cyber Resilience Act | 32024R2847 | active |
nis2 |
NIS2 Directive | 32022L2555 | active |
dora |
Digital Operational Resilience Act | 32022R2554 | active |
gdpr |
General Data Protection Regulation | 32016R0679 | active |
ai_act |
AI Act | 32024R1689 | active |
eidas |
eIDAS Regulation | 32014R0910 | active |
dsa |
Digital Services Act | 32022R2065 | active |
dma |
Digital Markets Act | 32022R1925 | active |
data_act |
Data Act | 32023R2854 | active |
dga |
Data Governance Act | 32022R0868 | active |
eidas2 |
European Digital Identity Regulation | 32024R1183 | active |
cer |
Critical Entities Resilience Directive | 32022L2557 | active |
psd2 |
Payment Services Directive 2 | 32015L2366 | active |
mica |
Markets in Crypto-Assets Regulation | 32023R1114 | active |
cybersecurity_act |
Cybersecurity Act | 32019R0881 | active |
eprivacy |
ePrivacy Directive | 32002L0058 | active |
red |
Radio Equipment Directive | 32014L0053 | active |
csrd |
Corporate Sustainability Reporting Dir. | 32022L2464 | active |
nis1 |
NIS Directive (Original) | 32016L1148 | superseded |
License
MIT License. See LICENSE for details.
Links
Project details
Release history Release notifications | RSS feed
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 law4devs-1.0.0.tar.gz.
File metadata
- Download URL: law4devs-1.0.0.tar.gz
- Upload date:
- Size: 15.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
831d2eba5a586becea08cd24bf6b895b8e13d446c3f5a198cdde7a8f76ebe0ed
|
|
| MD5 |
225898c3247abfa8435c611ed365289a
|
|
| BLAKE2b-256 |
5e82861bc9ab9fb7a990a40fa87029856905cbc412ca27d8d68f7b390bdb7821
|
File details
Details for the file law4devs-1.0.0-py3-none-any.whl.
File metadata
- Download URL: law4devs-1.0.0-py3-none-any.whl
- Upload date:
- Size: 17.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
19dd126cfc9bac5b8933ef7b30b4318ba9d945969ebc1b669ad980b8e093a4ec
|
|
| MD5 |
9b33d5756231b39bdcf4e22b9ba001a7
|
|
| BLAKE2b-256 |
244fb8efa39e38bc043da0b719dee35a175a921b4d8ea5c3b4ddebf0aadfbd28
|