Metadata-Version: 2.4
Name: ai-law-tracker
Version: 0.1.0
Summary: Official Python SDK for the AI Law Tracker API — audited AI-regulation data (US state + federal, EU, global) in three lines.
Project-URL: Homepage, https://ai-law-tracker.com
Project-URL: Documentation, https://ai-law-tracker.com/developers
Project-URL: API Reference, https://ai-law-tracker.com/api/v1/openapi.json
Project-URL: Source, https://github.com/Awesome28208/ai-law-tracker/tree/main/sdk/python
Project-URL: Issues, https://github.com/Awesome28208/ai-law-tracker/issues
Author-email: AI Law Tracker <hello@ai-law-tracker.com>
License: MIT
License-File: LICENSE
Keywords: ai law,ai regulation,api,compliance,eu ai act,legal,sdk
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
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: Typing :: Typed
Requires-Python: >=3.8
Requires-Dist: requests>=2.20
Provides-Extra: dev
Requires-Dist: pytest>=7; extra == 'dev'
Requires-Dist: responses>=0.23; extra == 'dev'
Requires-Dist: ruff>=0.4; extra == 'dev'
Description-Content-Type: text/markdown

# AI Law Tracker — Python SDK

[![PyPI](https://img.shields.io/pypi/v/ai-law-tracker.svg)](https://pypi.org/project/ai-law-tracker/)
[![Python](https://img.shields.io/pypi/pyversions/ai-law-tracker.svg)](https://pypi.org/project/ai-law-tracker/)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](./LICENSE)

Official Python client for the [AI Law Tracker](https://ai-law-tracker.com) API —
the audited dataset of AI regulation across **US state + federal, the EU, and
global** jurisdictions. Laws, news, changelogs, obligations, penalties,
compliance assessment, deadlines, and webhooks.

```bash
pip install ai-law-tracker
```

## Quick start (3 lines)

```python
from ai_law_tracker import Client

alt = Client()                          # anonymous tier; no key required
laws = alt.laws.list(scope="federal")   # -> a Page of records
```

```python
for law in laws:
    print(law["identifier"], "—", law["title"])
```

## Authentication

The API has a free **anonymous** tier (rate-limited by IP). For higher limits,
richer fields, and the changelog/webhook endpoints, use a **free API key** (no
card required):

```python
from ai_law_tracker import Client

# 1) Issue a free key by email (anonymous call is fine)
Client().account.create_key("you@example.com")   # emails you a key

# 2) Use it — explicitly, or via the ALT_API_KEY env var
alt = Client(api_key="alt_live_...")
print(alt.account.get())   # your tier, limits, and live usage
```

Set `ALT_API_KEY` in your environment and `Client()` picks it up automatically.
Paid tiers ($29 / $99 / $299 a month) raise quotas and unlock Pro-only endpoints
— see <https://ai-law-tracker.com/pricing>.

## Pagination

List endpoints return a `Page` you can iterate, index, and `len()`, plus
`.total`, `.limit`, `.offset`, and `.has_more`:

```python
page = alt.laws.list(scope="state", jurisdiction="colorado", limit=50)
print(page.total, "records match;", len(page), "on this page")
```

To sweep every matching record without managing offsets yourself, use
`.iterate(...)` — it pages transparently and yields one record at a time:

```python
for law in alt.laws.iterate(scope="eu", in_force=True):
    ...

for hit in alt.search.iterate("facial recognition", scope="state"):
    ...
```

## Endpoints

Grouped as resources on the client:

| Resource | Methods |
| --- | --- |
| `alt.laws` | `list`, `iterate`, `get(id)`, `history(id)`, `sources(id)`, `citations(id)` |
| `alt.search` | `query(q, ...)`, `iterate(q, ...)` |
| `alt.news` | `list`, `iterate` |
| `alt.changes` | `list`, `iterate` (poll `since=` for what changed) |
| `alt.feed` | `list` (lean recent-changes stream) |
| `alt.jurisdictions` | `list`, `countries`, `states` |
| `alt.sectors` | `list`, `get(sector)` |
| `alt.compliance` | `obligations`, `penalties`, `assess`, `report` |
| `alt.deadlines` | `list` (JSON or iCal via `format="ical"`) |
| `alt.bills` | `list`, `get(slug)` |
| `alt.webhooks` | `list`, `get(id)`, `create`, `delete` (Pro+) |
| `alt.account` | `get`, `revoke`, `create_key(email)`, `create_token(email)` |
| top level | `alt.health()`, `alt.accuracy()`, `alt.categories()`, `alt.openapi()` |

Examples:

```python
# Poll the changelog for everything that moved since a timestamp
changes = alt.changes.list(since="2026-07-01T00:00:00Z", scope="federal")

# Compliance obligations for a sector + jurisdiction
obs = alt.compliance.obligations(jurisdiction="colorado", sector="hr")

# Risk assessment from a company profile
result = alt.compliance.assess(state="CA", sector="hr", aiUse="resume_screening")

# Upcoming compliance deadlines as an iCal feed (text/calendar)
ics = alt.deadlines.list(scope="eu", format="ical")
```

## Error handling

Every non-2xx response raises a typed exception carrying `.status`, `.code`,
`.message`, and `.docs`:

```python
from ai_law_tracker import NotFoundError, RateLimitError, AuthenticationError

try:
    alt.laws.get("does-not-exist")
except NotFoundError as e:
    print(e.code, e.message)
except RateLimitError as e:
    print("retry after", e.retry_after, "seconds")
```

All inherit from `ALTError`. Transient failures (timeouts, 5xx, 429) on
`GET`/`DELETE` are retried automatically with exponential backoff (configurable
via `Client(max_retries=...)`).

## Configuration

```python
Client(
    api_key=None,        # or set ALT_API_KEY
    base_url="https://ai-law-tracker.com/api/v1",
    timeout=30.0,        # seconds
    max_retries=2,       # transient GET/DELETE retries
)
```

`Client` is a context manager (`with Client() as alt: ...`) and has `.close()`
to release the connection pool.

## Responsible use

This SDK is designed to be a well-behaved API citizen and does **not** provide
any way to bypass the server's tier gating or rate limits:

- Requests are **sequential** with a single connection — no parallel fan-out or
  concurrent request flooding.
- Retries are **conservative**: a small default (`max_retries=2`), exponential
  backoff with jitter, and only on idempotent `GET`/`DELETE`. Writes/POSTs are
  never retried automatically.
- `429` responses and their `Retry-After` header are **respected**; a persisted
  rate limit surfaces as a `RateLimitError` (with `.retry_after`) rather than
  being retried away.
- `iterate(...)` pages **one page at a time, in order**, through the same
  rate-limited transport. It is a convenience for legitimate paging, not a bulk
  scraper — please honour your tier's quotas.

If you need high-volume or bulk access, use an appropriate paid tier or contact
<hello@ai-law-tracker.com> rather than working around the limits.

## Links

- API docs & playground: <https://ai-law-tracker.com/developers>
- OpenAPI 3.1 spec: <https://ai-law-tracker.com/api/v1/openapi.json>
- Get a free key: <https://ai-law-tracker.com>
- Node/TypeScript SDK: [`ai-law-tracker` on npm](https://www.npmjs.com/package/ai-law-tracker)

## License

MIT (SDK code). API **data** is CC BY 4.0 — attribution required, informational
only, not legal advice.
