EU law in Python: one import, typed responses.
lexapi-client is LexAPI’s own Python client, on PyPI. It needs a LexAPI API key, and LexAPI is not affiliated with EUR-Lex or the Publications Office. It reads EUR-Lex legislation and Court of Justice case law through the LexAPI REST API and returns typed objects.
The free plan starts with 500 credits, no card. Your API key is on the dashboard once you confirm your email.
One package, one import.
Terminal
pip install lexapi-client
The package is lexapi-client; the import is lexapi. The examples below were run with version 0.4.0. Put your key in place of lex_your_key, or leave api_key out and set the LEXAPI_API_KEY environment variable.
In a framework: EU law in LangChain · EU law in LlamaIndex.
One article, as an object.
Documents are read by CELEX number. This reads Article 5 of the AI Act.
Pythonfrom lexapi import LexAPI
client = LexAPI(api_key="lex_your_key")
resp = client.get_document("32024R1689", include=["metadata", "articles"], article_id="5")
article = resp.document.content.articles[0]
print(resp.document.celex, "-", article.number, "-", article.title)
print(article.content[:120])
print("credits charged:", resp.units_charged)32024R1689 - Article 5 - Prohibited AI practices
1. The following AI practices shall be prohibited: (a) the placing on the market, the putting into service or the use of
credits charged: 1resp.documentis a typed object:celex,title,content.articles. The raw JSON is on.raw.article_idtakes5,art_5orArticle 5.units_chargedis what the call cost: 1 credit when LexAPI already holds the document, 4 or 5 when it is fetched from the source first.
What amends an act, in one call.
The citation graph is under client.citations. This lists the acts that amend the AI Act.
from lexapi import LexAPI
client = LexAPI(api_key="lex_your_key")
resp = client.citations.cited_by("32024R1689", citation_type="amendment", limit=20)
for group in resp.cited_by:
for edge in group.citations:
print(edge.citation_type, group.celex_number)amendment 32026R1744A short or empty list is not proof that nothing amends the act. Costs 1 credit.
Errors you can catch by type.
A response that is not a success raises a typed exception; most are named after the API’s error code. This resolves an ECLI that does not exist.
Pythonfrom lexapi import LexAPI, NotFoundError
client = LexAPI(api_key="lex_your_key")
try:
client.resolve("ECLI:EU:C:1900:1")
except NotFoundError as err:
print(err.status, err.code)404 NOT_FOUNDThe client retries a rate-limited call for you. The errors a first call meets.
What the client covers.
- Search, documents, identifiers, citations, semantic search, webhooks and bulk export, each as a method. An async client,
AsyncLexAPI, is in the same package. - Not yet:
POST /legislation/as-ofhas no method in this version. Call it over HTTP: EU law on a date. - It is a client for LexAPI, not for EUR-Lex: every call goes to the LexAPI REST API with your key and is billed like the endpoint it calls.
Asked & answered.
N° 01Is there a Python client for EUR-Lex?+
N° 02Which Python versions does lexapi-client support?+
N° 03Are the responses typed?+
N° 04Is there an async client?+
Keep building.
- Legal data API for AI agentsThe MCP server, hosted or local, the REST API and the SDKs, all on the same credit pool.
- European legal RAGSemantic search to article text with provenance, citations and the text for a date.
- EUR-Lex SPARQL alternativeAn act’s metadata and relations by REST, and what the Cellar SPARQL endpoint does that LexAPI does not.
- QuickstartA first request by curl, MCP, Python and TypeScript.
- API referenceEvery endpoint, parameter, response field and error.
- MCP serverSetup for Claude, Cursor and VS Code, and the tool list.
- PricingPlans, credit pools and what each call costs.
LexAPI returns source texts and their identifiers. It does not assess compliance and gives no legal advice.