Skip to main content

Python SDK for the CLE Engine API - Continuing Legal Education deadline computation

Project description

CLE Engine Python SDK

A Python client library for the CLE Engine API, providing easy access to continuing legal education (CLE) deadline computation across all US jurisdictions.

Installation

pip install cle-engine

Quick Start

from cle_engine import CLEEngineClient

# Initialize the client
client = CLEEngineClient(api_key="your-api-key")

# Compute CLE due date for a California attorney
result = client.compute_due_date(
    jurisdiction="CA",
    admission_date="2020-01-15"
)

print(f"Due date: {result.due_date}")
print(f"Credits required: {result.credits_required}")
print(f"Cycle: {result.cycle_start} to {result.cycle_end}")

Configuration

API Key

You can provide your API key in two ways:

  1. Direct initialization:

    client = CLEEngineClient(api_key="your-api-key")
    
  2. Environment variable:

    export CLE_ENGINE_API_KEY="your-api-key"
    
    client = CLEEngineClient()  # Reads from environment
    

Custom Base URL

For testing or self-hosted instances:

client = CLEEngineClient(
    api_key="your-api-key",
    base_url="https://your-instance.example.com"
)

Or via environment variable:

export CLE_ENGINE_BASE_URL="https://your-instance.example.com"

Usage Examples

Computing Due Dates

Basic computation:

from cle_engine import CLEEngineClient
from datetime import date

client = CLEEngineClient(api_key="your-api-key")

# Using string dates
result = client.compute_due_date(
    jurisdiction="CA",
    admission_date="2020-01-15"
)

# Using date objects
result = client.compute_due_date(
    jurisdiction="NY",
    admission_date=date(2018, 5, 1),
    last_name="Smith"  # Used for surname-based reporting groups
)

With all optional parameters:

result = client.compute_due_date(
    jurisdiction="TX",
    profession="lawyer",
    last_name="Johnson",
    birth_date="1985-03-20",
    admission_date="2015-07-01",
    reporting_category="Group1",
    reporting_period_end="2025-03-31",
    renewal_year=2025
)

# Access response fields
print(f"Due date: {result.due_date}")
print(f"CLE required: {result.cle_required}")
print(f"Credits required: {result.credits_required}")
print(f"Reporting group: {result.reporting_group}")
print(f"Missing fields: {result.missing_fields}")
print(f"Notes: {result.notes}")

Health Check

client = CLEEngineClient(api_key="your-api-key")
health = client.health_check()
print(f"API status: {health.status}")  # "ok"

Getting Jurisdictions

client = CLEEngineClient(api_key="your-api-key")
jurisdictions = client.get_jurisdictions()

for j in jurisdictions:
    print(f"{j.code}: {j.name}")
    print(f"  CLE required: {j.cle_required}")
    if j.cle_required:
        print(f"  Credits per cycle: {j.credits_per_cycle}")
        print(f"  Cycle length: {j.cycle_years} years")

Using Context Manager

with CLEEngineClient(api_key="your-api-key") as client:
    result = client.compute_due_date(jurisdiction="CA")
    print(result.due_date)
# Connection is automatically closed

Error Handling

The SDK provides specific exception classes for different error types:

from cle_engine import CLEEngineClient
from cle_engine.exceptions import (
    CLEEngineError,
    AuthenticationError,
    RateLimitError,
    ValidationError,
    ServerError,
    NetworkError,
)

client = CLEEngineClient(api_key="your-api-key")

try:
    result = client.compute_due_date(jurisdiction="INVALID")
except AuthenticationError as e:
    print(f"Authentication failed: {e}")
    # Invalid or expired API key
except RateLimitError as e:
    print(f"Rate limited. Retry after {e.retry_after} seconds")
except ValidationError as e:
    print(f"Invalid request: {e}")
    print(f"Details: {e.response_body}")
except ServerError as e:
    print(f"Server error: {e}")
except NetworkError as e:
    print(f"Network error: {e}")
except CLEEngineError as e:
    # Catch-all for any API error
    print(f"API error [{e.status_code}]: {e.message}")

Exception Hierarchy

All exceptions inherit from CLEEngineError:

  • AuthenticationError - Invalid or missing API key (401/403)
  • RateLimitError - Rate limit exceeded (429)
  • ValidationError - Invalid request parameters (400/422)
  • ServerError - Server-side errors (5xx)
  • NetworkError - Connection/timeout issues

Response Models

ComputeResponse

Field Type Description
due_date date | None The CLE compliance deadline
cycle_start date | None Start of the reporting cycle
cycle_end date | None End of the reporting cycle
credits_required int | None Total credits required
reporting_group str | None Assigned reporting group
cle_required bool | None Whether CLE is mandatory
required_fields list[str] Fields needed for computation
missing_fields list[str] Required fields not provided
citations list[Citation] Source documentation
notes str | None Additional information

Citation

Field Type Description
source_id str Identifier for the source
excerpt_id str | None Specific excerpt reference
url str | None Link to source documentation

Development

Running Tests

# Install dev dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Run with coverage
pytest --cov=cle_engine --cov-report=term-missing

# Type checking
mypy cle_engine

# Linting
ruff check cle_engine

Building

pip install build
python -m build

Requirements

  • Python 3.8+
  • requests >= 2.25.0
  • pydantic >= 2.0.0

License

MIT License - see LICENSE file for details.

Support

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

cle_engine-0.1.0.tar.gz (14.6 kB view details)

Uploaded Source

Built Distribution

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

cle_engine-0.1.0-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: cle_engine-0.1.0.tar.gz
  • Upload date:
  • Size: 14.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for cle_engine-0.1.0.tar.gz
Algorithm Hash digest
SHA256 0ec927d43f626d71f3ab14e62f21300c080671275fda123e0e324ca8305206f0
MD5 a72d0d3324f863be5bc94e1ef556758f
BLAKE2b-256 1b7e238105cf7676b86e6abc40e1ad2e1698e90e504b8224018d21d907bb49b7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cle_engine-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for cle_engine-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6191656463bac8228d3deecd3c72c95464ddff0ee019227dad72337de09f8733
MD5 43d5394f85d19ce0edc7779a44501545
BLAKE2b-256 ba2fa005965441774414ef600a97eb0c29b675561369d084cc6e62ed61fb1da5

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