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
Search · Read · Cite

§ European legal RAG — For developers

Retrieval over EU law for an LLM that has to cite.

Three calls make the retrieval step for EU legislation: find articles by meaning, read the article with its provenance, follow its citations. LexAPI returns the source text; your model writes the answer.

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 — Retrieve

Find the article by meaning.

You need: curl in bash or zsh, and an API key

Legislation is indexed at article level. Send the user’s question as query; run this with your key in place of lex_your_key.

curl
curl -X POST "https://lex-api.com/api/v1/legislation/semantic" \
  -H "x-api-key: lex_your_key" \
  -H "Content-Type: application/json" \
  -d '{"query":"right to erasure of personal data","limit":3}'
You get (abridged)
{
  "success": true,
  "searchType": "semantic-legislation",
  "resultCount": 3,
  "results": [
    {
      "law_id": "32018R1725",
      "law_title": "Regulation (EU) 2018/1725 … on the protection of natural persons with regard to the processing of personal data by the Union institutions, bodies, offices and agencies …",
      "article_ref": "art_19",
      "score": 0.753812,
      "inForce": true,
      …
    },
    {
      "law_id": "32016R0679",
      "law_title": "Regulation (EU) 2016/679 … (General Data Protection Regulation) …",
      "article_ref": "art_17",
      "language": "en",
      "score": 0.7511648,
      "snippet": "1. The data subject shall have the right to obtain from the controller the erasure of personal data concerning him or her without undue delay …",
      "inForce": true,
      "provenance": {
        "sourceUrl": "https://eur-lex.europa.eu/legal-content/EN/TXT/HTML/?uri=CELEX:32016R0679",
        "versionIdentifier": "32016R0679",
        "retrievedAt": null,
        "contentHash": null,
        …
      },
      …
    },
    …
  ],
  "credits": { "operation_weight": 5, … }
}
  • law_id is the act’s CELEX number and article_ref the article: the two arguments of the next call.
  • Each hit carries the inForce label of its act when the status is known.
  • Send inForce: true to keep only hits whose act is known to be in force today. Hits of unknown status are removed too.

Costs 5 credits, on every credit plan including the free one. limit is capped by plan: 10 results on the free plan, 20 on Starter, 50 on the plans above.

Legislation search reference

§ 02 — Read

The article, with its provenance.


Read the matched article in full and keep where it came from next to the text you put in the prompt.

curl
curl -X POST "https://lex-api.com/api/v1/documentContent" \
  -H "x-api-key: lex_your_key" \
  -H "Content-Type: application/json" \
  -d '{"celexNumber":"32016R0679","articleId":"art_17","include":["articles"]}'
You get (abridged)
{
  "success": true,
  "document": {
    "celex": "32016R0679",
    "language": "en",
    "version": 1,
    "inForce": true,
    "provenance": {
      "publisher": "Publications Office of the European Union",
      "sourceUrl": "https://eur-lex.europa.eu/legal-content/EN/TXT/HTML/?uri=CELEX:32016R0679",
      "sourceIdentifier": "32016R0679",
      "retrievedAt": "2026-11-17T18:14:22.344Z",
      "contentHash": "3c91009d05bbda7b9717678970c2d4d680cee402b00f8f0df92510f9bab42543",
      "versionIdentifier": "32016R0679",
      "language": "en",
      "licence": "Commission reuse policy (Decision 2011/833/EU)"
    },
    "content": {
      "articles": [
        {
          "id": "art_17",
          "number": "Article 17",
          "title": "Right to erasure (‘right to be forgotten’)",
          "content": "1. The data subject shall have the right to obtain from the controller the erasure of personal data concerning him or her without undue delay …"
        }
      ]
    },
    "fieldProvenance": {
      "official_source_text": ["content.articles[].content"],
      "machine_extracted_structure": ["inForce", "content.articles"]
    },
    …
  },
  "credits": { "operation_weight": 1, … }
}
  • provenance.sourceUrl is the document’s page at EUR-Lex and versionIdentifier the text you were served.
  • contentHash covers the whole document, not the article. A different value means the document’s text changed, at the source or by a re-parse: re-read the articles you indexed from it.
  • fieldProvenance says which fields are the publisher’s wording and which are LexAPI’s parsing.

Costs 1 credit when LexAPI already holds the document, 4 or 5 when it is fetched from the source first. credits.operation_weight is what you were charged.

Search, then read, with the SDKs

Install with pip install lexapi-client or npm install @lexapi/client. The snippets read the top hit.

Python
from lexapi import LexAPI

client = LexAPI(api_key="lex_your_key")

search = client.semantic_legislation_search("right to erasure of personal data", limit=3)
if not search.results:
    raise SystemExit("no article matched")
hit = search.results[0]

resp = client.get_document(hit.law_id, include=["articles"], article_id=hit.article_ref)
article = resp.document.content.articles[0]

print(resp.document.celex, "-", article.number, "-", article.title)
print(article.content[:120])
TypeScript
import { LexAPI } from "@lexapi/client";

const client = new LexAPI({ apiKey: "lex_your_key" });

const search = await client.semanticLegislationSearch({
  query: "right to erasure of personal data",
  limit: 3,
});
const hit = search.results[0];
if (!hit?.law_id || !hit.article_ref) throw new Error("no article matched");

const resp = await client.getDocument({
  celexNumber: hit.law_id,
  include: ["articles"],
  articleId: hit.article_ref,
});
const article = resp.document.content?.articles?.[0];

console.log(resp.document.celex, "-", article?.number, "-", article?.title);
console.log(article?.content?.slice(0, 120));
Both print
32018R1725 - Article 19 - Right to erasure (‘right to be forgotten’)
1. The data subject shall have the right to obtain from the controller the erasure of personal data concerning him or he

In a framework: EU law in LangChain · EU law in LlamaIndex.

Provenance reference

§ 03 — Expand

Follow the citations.


To widen the context, ask what the act cites. Each group in cites[] is a document with its celexNumber and title; each edge has a citationType. The list holds the edges LexAPI has so far, and can be empty.

curl
curl "https://lex-api.com/api/v1/citations/cites/32016R0679?limit=20" \
  -H "x-api-key: lex_your_key"

Costs 1 credit. For what corrects or amends an act, see the example on GDPR API; for case law on a question, European case law API.

§ 04 — Time

The text in force on a date.


Add asOf to the search above and each hit answers with the version listed for that date: the newest consolidated version dated on or before it, or the act as published. It does not say whether an individual provision applied on that date; see POST /legislation/as-of.

curl
curl -X POST "https://lex-api.com/api/v1/legislation/semantic" \
  -H "x-api-key: lex_your_key" \
  -H "Content-Type: application/json" \
  -d '{"query":"right to erasure of personal data","limit":3,"asOf":"2017-01-01"}'
You get (abridged)
{
  "success": true,
  "asOf": "2017-01-01",
  "resultCount": 3,
  "results": [
    {
      "law_id": "32018R1725",
      "article_ref": "art_19",
      "score": 0.753812,
      "asOfResolved": false,
      "asOfReason": "not_yet_adopted",
      "inForce": true,
      …
    },
    {
      "law_id": "02016R0679-20160504",
      "article_ref": "art_17",
      "score": 0.7511648,
      "consolidated": true,
      "consolidatedAsOf": "2016-05-04",
      "baseCelex": "32016R0679",
      "consolidatedNote": "The act as amended, consolidated as of 2016-05-04; not the authentic text. Only the act as published in the Official Journal is authentic (32016R0679).",
      "asOfResolved": true,
      "asOfVersion": { "celex": "02016R0679-20160504", "date": "2016-05-04", "kind": "consolidated" },
      "matchedVersion": { "law_id": "32016R0679", … },
      "inForce": true,
      …
    },
    {
      "law_id": "02001R0045-20010201",
      "article_ref": "art_16",
      "score": 0.7292255,
      "consolidated": true,
      "baseCelex": "32001R0045",
      "asOfResolved": true,
      "asOfVersion": { "celex": "02001R0045-20010201", "date": "2001-02-01", "kind": "consolidated" },
      "inForce": false,
      "notInForceReason": "no_longer_in_force",
      "endOfValidity": "2018-12-10",
      …
    }
  ],
  …
}
  • Use only hits with asOfResolved: true. A hit that cannot be answered for the date keeps its indexed text and says why in asOfReason.
  • asOfVersion names the version that answered.
  • A consolidated version is documentation without legal force: baseCelex is the authentic act to cite.
  • inForce stays about today: the third hit has asOfResolved: true, and its act is no longer in force today.
  • The search costs 5 credits. A version LexAPI does not hold yet is fetched first and charged like a document read, so the same request can cost more the first time; asOfSummary.liveFetches counts those fetches.

One act on a date, without a search: EU law on a date.

§ 05 — Limits

What it does not do.


TopicWhat to know
AnswersLexAPI retrieves source text and its identifiers. It does not write answers and does not assess compliance: that part is your model and your review.
In forceinForce is about today and is left out when the status is unknown. It does not cover amendments: for the wording on a date, use asOf and keep only hits with asOfResolved: true.
Consolidated textsA hit labelled consolidated: true is documentation without legal force. baseCelex names the authentic act.
Scoresscore is a similarity between 0 and 1. Without min_score a default floor applies; a best-effort response below it carries a hint.
Hit idsThe id of a hit can change when the index is rebuilt. Key your store on law_id and article_ref.
CitationsThe citation graph grows as documents are extracted. A short or empty list is not proof that nothing cites an act.
§ 06 — FAQ

Asked & answered.

N° 01How do I ground an LLM answer in EU law?+
Search by meaning with POST /api/v1/legislation/semantic, then read each hit that is an article (article_ref starts with art_) with POST /api/v1/documentContent: the hit’s law_id is the celexNumber and its article_ref the articleId. A recital hit (rct_…) is not read this way. Put the article text in the prompt with its CELEX number, article number and EUR-Lex link, and have the model cite them. LexAPI returns the source text; your model writes the answer.
N° 02What does asOf do in a semantic search?+
It asks for the law on a date. A hit with asOfResolved: true carries the text for that date: the act as published, or the consolidated version listed for that date. Use only those hits; a hit that cannot be answered for the date keeps its indexed text and says why in asOfReason. For one known act, POST /api/v1/legislation/as-of answers without a search.
N° 03How do I cite a search hit that is a consolidated text?+
Cite the act it consolidates, which baseCelex names. A hit labelled consolidated: true is the act with its amendments integrated, published as documentation without legal force; only the act as published in the Official Journal is authentic. If you quote the consolidated wording, say that it is consolidated.
N° 04Do the ids of search hits stay the same?+
No. The id of a hit can change when the index is rebuilt. Key what you store on law_id and article_ref, which name the act and the part matched.
§ 07 — Next

Keep building.


  • GDPR APIRead the GDPR by article or recital, cite it, and list what corrects or amends it.
  • European case law APISearch Court of Justice case law by meaning, resolve an ECLI, read the judgment.
  • Legal data API for AI agentsThe MCP server, hosted or local, the REST API and the SDKs, all on the same credit pool.
  • 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.