EU law · 24 official languagesArticle-level JSON · typed citation graphMCP server · Claude, Cursor, VS CodeSDKs · Python, TypeScriptFree plan · 500 credits to start
Brussels · CET
Vol. II·Section S — Solutions Desk
lexapi-client · PyPI · sync and async

§ Python client — For developers

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.

Create a free accountQuickstart

§ 01 — Install

One package, one import.

You need: Python 3.9 or newer and an API key

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.

§ 02 — Read

One article, as an object.


Documents are read by CELEX number. This reads Article 5 of the AI Act.

Python
from 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)
It prints
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: 1
  • resp.document is a typed object: celex, title, content.articles. The raw JSON is on .raw.
  • article_id takes 5, art_5 or Article 5.
  • units_charged is what the call cost: 1 credit when LexAPI already holds the document, 4 or 5 when it is fetched from the source first.

Python SDK reference

§ 03 — Citations

What amends an act, in one call.


The citation graph is under client.citations. This lists the acts that amend the AI Act.

Python
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)
It prints
amendment 32026R1744

A short or empty list is not proof that nothing amends the act. Costs 1 credit.

The citation graph, edge by edge

§ 04 — Errors

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.

Python
from 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)
It prints
404 NOT_FOUND

The client retries a rate-limited call for you. The errors a first call meets.

§ 05 — Scope

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-of has 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.
§ 06 — FAQ

Asked & answered.

N° 01Is there a Python client for EUR-Lex?+
LexAPI publishes lexapi-client on PyPI. It is a client for the LexAPI REST API, which returns EUR-Lex legislation and Court of Justice case law as JSON, and it needs a LexAPI API key. It is not a client of EUR-Lex itself: LexAPI is not affiliated with EUR-Lex or the Publications Office.
N° 02Which Python versions does lexapi-client support?+
Python 3.9 or newer. Its only dependency is httpx.
N° 03Are the responses typed?+
Yes. Methods return typed objects with attributes such as document.celex, the package ships its type hints (py.typed), and every object keeps the raw JSON on .raw.
N° 04Is there an async client?+
Yes. The same package has AsyncLexAPI, an async client.
§ 07 — Next

Keep building.


  • 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.