Metadata-Version: 2.5
Name: pandex
Version: 0.1.0
Summary: Python client for Pandex: official law and case law from 25 countries and the EU, for AI agents and apps
Project-URL: Homepage, https://www.pandex.io
Project-URL: Documentation, https://docs.pandex.io
Project-URL: Repository, https://github.com/pandex-io/pandex-python
Project-URL: API reference, https://api.pandex.io/openapi.json
Project-URL: Free key, https://www.pandex.io/key
Author-email: Pandex <vasco@pandex.io>
License-Expression: MIT
License-File: LICENSE
Keywords: ai agents,api,case law,ecli,eur-lex,law,legal,legislation,rag
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Legal Industry
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Software Development :: Libraries
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: httpx>=0.24
Description-Content-Type: text/markdown

# pandex

Python client for [Pandex](https://www.pandex.io): official law and case law from 25 countries and the EU, for AI agents and apps. Search legislation and court decisions, read an article as it stood on any date, follow citations, and see what changed.

- Docs: https://docs.pandex.io
- API reference: https://api.pandex.io/openapi.json
- Free key: https://www.pandex.io/key (without a key: 50 calls a day)
- MCP server: `https://api.pandex.io/mcp`

```
pip install pandex
export PANDEX_API_KEY=px_...
```

## Quick start

```python
from pandex import Pandex

px = Pandex()  # or Pandex(api_key="px_...")

found = px.search("right to erasure personal data", jurisdiction="eu", kind="legislation", limit=3)
for hit in found["hits"]:
    print(hit["id"], hit["element"], hit["path"])
```

```
eu.legislation:32016R0679 art_17 III Rights of the data subject › 3 Rectification and erasure › 17 Right to erasure ('right to be forgotten')
eu.legislation:32016R0679 art_15 III Rights of the data subject › 2 Information and access to personal data › 15 Right of access by the data subject
eu.legislation:32018R1725 art_19 III RIGHTS OF THE DATA SUBJECT › 3 Rectification and erasure › 19 Right to erasure
```

Every method returns the API's JSON as a typed dict (see `pandex.types`). Pass `text=True` to get the answer written for a model to read instead, the same text the MCP tools return.

## Read a law as it stood on a date

`document` takes an id from a result, or a citation as people write it: `"BGB"`, `"art. 6:162 BW"`, a CELEX number, an ECLI.

```python
doc = px.document("Code civil", "1382", at="2015-01-01", history=True, cases=False)
article = doc["elements"][0]
print(doc["id"], article["valid_from"], article["valid_to"])
print(article["text"])
print(doc["history"])
```

```
fr.dila_legi:LEGITEXT000006070721 1804-03-21 2016-10-01
Tout fait quelconque de l'homme, qui cause à autrui un dommage, oblige celui par la faute duquel il est arrivé à le réparer.
[['1804-03-21', '2016-10-01'], ['2016-10-01', None]]
```

One article of a law comes with its leading decisions, those cited most by the other decisions on it:

```python
doc = px.document("art. 6:162 BW")
for line in doc["leading"][:3]:
    print(line["id"], line["cited_by"])
```

```
nl.rechtspraak:ECLI:NL:HR:2014:2627 389
nl.rechtspraak:ECLI:NL:HR:2011:BU4204 62
nl.rechtspraak:ECLI:NL:HR:2014:1204 77
```

## Citations

```python
cites = px.citations("32016R0679", "art_17", limit=3)
print(cites["total"])
for line in cites["held"]:
    print(line["date"], line["id"])
```

```
73
2022-02-24 eu.caselaw:62020CJ0175
2019-09-24 eu.caselaw:62017CJ0136
2022-12-08 eu.caselaw:62020CJ0460
```

`direction="out"` lists what a document cites instead.

## Outline, changes, sources

```python
px.outline("32016R0679", under="chp_iii", lang="en")      # chapters and articles with element ids
px.changes("Awb", limit=3)                                 # amended, inserted, repealed articles, newest first
px.changes(jurisdiction="de", since="2026-11-01")          # or for a whole country or source
px.sources("lu")                                           # what is held, per source, as of which day
```

```python
for c in px.changes("Awb", limit=3)["changes"]:
    print(c["from"], c["change"], c["label"])
```

```
2026-11-10 amended 2 Beroep bij de Afdeling bestuursrechtspraak van de Raad van State
2026-08-15 amended 7 Beroep bij de rechtbank Rotterdam
2026-08-15 amended 11 Hoger beroep bij het College van Beroep voor het bedrijfsleven
```

## Text for a model

```python
print(px.document("BGB", "823", text=True))
```

```
Bürgerliches Gesetzbuch
federal law · 1896-08-18 · in force 2026-11-20– · de · cited by 24787
id de.gii:BJNR001950896 · abbr:de=BGB
https://www.gesetze-im-internet.de/bgb/

Buch 2 Recht der Schuldverhältnisse › Abschnitt 8 Einzelne Schuldverhältnisse › Titel 27 Unerlaubte Handlungen
[art_823] 823 Schadensersatzpflicht (wording in force since 2026-11-20)
§ 823
(1) Wer vorsätzlich oder fahrlässig ...
```

## Async

```python
import asyncio
from pandex import AsyncPandex

async def main():
    async with AsyncPandex() as px:
        found = await px.search("§ 823 BGB", limit=1)
        print(found["hits"][0]["id"])

asyncio.run(main())
```

## Errors

A refused call raises `PandexError` with the HTTP `status` and a `message` that says what to pass instead:

```python
from pandex import PandexError

try:
    px.document("nonexistent-xyz")
except PandexError as e:
    print(e.status, e.message)
# 400 No document found for "nonexistent-xyz". Use search to find it, or pass an id from a search result.
```

401 means the key is unknown, 429 that its limit is reached.

## Frameworks

- LangChain: [`langchain-pandex`](https://github.com/pandex-io/langchain-pandex)
- More examples (OpenAI Agents, Claude Agent SDK, LlamaIndex, Vercel AI SDK): [legal-agent-examples](https://github.com/pandex-io/legal-agent-examples)

## Licence

MIT. The texts themselves come from official publishers under their own terms; `px.sources()` gives each one's licence.
