Skip to main content

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/api/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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

law4devs-0.1.0.tar.gz (15.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

law4devs-0.1.0-py3-none-any.whl (17.5 kB view details)

Uploaded Python 3

File details

Details for the file law4devs-0.1.0.tar.gz.

File metadata

  • Download URL: law4devs-0.1.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

Hashes for law4devs-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6eb20c8e3bbd9b594ba9e0821b18b94109f56cc3698e76432b11055d2e842f92
MD5 d2b74bdff3efd5bb3c5cd95da2bbd945
BLAKE2b-256 fac9a57412ba79aa563e2e2baefca9ea9f3603496867b80af57eceffde52c321

See more details on using hashes here.

File details

Details for the file law4devs-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: law4devs-0.1.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

Hashes for law4devs-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 abbce8901b3295c0dff0b04ea260f206b63963ca65ce67bd0a9bedf7b2266a66
MD5 c0bb5ec83b26fd3a53b57b534c25e151
BLAKE2b-256 3f110dce78a51dc7bab88b379b2688b71b4d69944f9b153fc83279fdc0db67b3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page