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 G — Developer Guides
REST · MCP · Python · TypeScript

§ Quickstart — For developers

Your first article of EU law, four ways.

One request returns Article 17 of the GDPR as JSON, with the identifiers to cite it by. Pick a path, paste one snippet.

First, create a free account and confirm your email: your API key is then on the dashboard. The free plan starts with 500 credits, no card.

Create a free account

§ 01 — REST

One curl call.

You need: curl in bash or zsh (macOS, Linux, WSL) and an API key

  1. Copy your key from Dashboard → API keys.
  2. Run this with your key in place of lex_your_key.
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":"17","include":["metadata","articles"]}'
You get (abridged)
{
  "success": true,
  "document": {
    "celex": "32016R0679",
    "language": "en",
    "title": "Regulation (EU) 2016/679 … (General Data Protection Regulation) …",
    "urls": {
      "html": "https://eur-lex.europa.eu/legal-content/EN/TXT/HTML/?uri=CELEX:32016R0679",
      …
    },
    "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 …"
        }
      ]
    },
    …
  },
  "credits": { "operation_weight": 1, "remaining": 499, … }
}

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.

Document endpoint reference

§ 02 — MCP

Connect Claude Code.

You need: Claude Code and a LexAPI account — no API key

  1. Run this in your terminal.
  2. In Claude Code, run /mcp, choose lexapi, then Authenticate. Sign in to LexAPI in the browser and approve.
  3. Ask: Using LexAPI, quote Article 17 of the GDPR (CELEX 32016R0679) and cite it.
claude mcp add --transport http lexapi https://mcp.lex-api.com/v1

No browser sign-in? Use your API key instead:

claude mcp add --transport http lexapi https://mcp.lex-api.com/v1 --header "Authorization: Bearer lex_your_key"
Claude typically calls lex_get_document and gets (abridged)
{
  "celex": "32016R0679",
  "title": "Regulation (EU) 2016/679 … (General Data Protection Regulation) …",
  …
  "url": "https://eur-lex.europa.eu/legal-content/EN/TXT/HTML/?uri=CELEX:32016R0679",
  "source": "corpus",
  "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 …"
      }
    ]
  },
  …
}

Tool calls use your plan’s credits, like the REST call above.

claude.ai, Cursor, VS Code, or an API key

§ 03 — Python

The Python SDK.

You need: Python 3.9 or newer and an API key

  1. Install: pip install lexapi-client
  2. Save this as quickstart.py with your key in place of lex_your_key.
  3. Run: python quickstart.py
from lexapi import LexAPI

client = LexAPI(api_key="lex_your_key")

resp = client.get_document("32016R0679", include=["metadata", "articles"], article_id="17")
article = resp.document.content.articles[0]

print(resp.document.celex, "-", article.number, "-", article.title)
print(article.content[:200])
print("credits charged:", resp.units_charged, "| remaining:", resp.credits_remaining)
It prints
32016R0679 - Article 17 - 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 her without undue delay and the controller shall have the obligation to erase pers
credits charged: 1 | remaining: 499

Python SDK reference

§ 04 — TypeScript

The TypeScript SDK.

You need: Node.js 18 or newer and an API key

  1. Install: npm install @lexapi/client
  2. Save this as quickstart.mjs with your key in place of lex_your_key. The same code is valid TypeScript in an ES module: in a CommonJS project, name the file .mts or set "type": "module".
  3. Run: node quickstart.mjs
import { LexAPI } from "@lexapi/client";

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

const resp = await client.getDocument({
  celexNumber: "32016R0679",
  include: ["metadata", "articles"],
  articleId: "17",
});
const article = resp.document.content?.articles?.[0];

console.log(resp.document.celex, "-", article?.number, "-", article?.title);
console.log(article?.content?.slice(0, 200));
console.log("credits charged:", resp.credits?.operation_weight, "| remaining:", resp.credits?.remaining);
It prints
32016R0679 - Article 17 - 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 her without undue delay and the controller shall have the obligation to erase pers
credits charged: 1 | remaining: 499

Server-side only: keep the key out of browser code.

TypeScript SDK reference

§ 05 — What you got

Source text, citable.

The text of Article 17 from EUR-Lex, with the act’s CELEX number (32016R0679) and its EUR-Lex link to cite it by.

CELEX numbers that start with 0 are consolidated texts: documentation, without legal force. LexAPI returns source texts; it does not assess compliance.

Next: turn an ECLI, an ELI or a link into a CELEX number, or list what cites or amends an act.

§ 06 — If it fails

Three errors a first call meets.

StatusWhy, and what to do
401The x-api-key header is missing, or the key is wrong. Send the key in the x-api-key header. A wrong key answers {"error":"Invalid API key"}.{"error":"API key required","message":"Please provide your API key in the x-api-key header"}
402Fewer credits left than the call reserves. A document read reserves 5 and refunds the difference. The pool refills on details.resetsAt.{"success":false,"error":{"code":"CREDITS_EXHAUSTED","message":"Credit pool exhausted","details":{"operation":"document_fetch","weight":5,"available":2,"included":500,"topup":0,"used":498,"resetsAt":"2026-12-17T15:57:07.011Z"}}}
429More requests in a minute than the plan allows: 15 on the free plan. Wait retryAfter seconds (also the Retry-After header). The SDKs retry a 429 for you.{"success":false,"code":"RATE_LIMITED","error":"Rate limit exceeded","message":"You can make up to 15 requests per minute on your current plan","retryAfter":60}

All error codes

Snippets verified with lexapi-client 0.4.0, @lexapi/client 0.4.0, @lexapi/mcp 0.5.1.