Documents

Read one document in full, or list the articles of a law or regulation.

Retrieve Document

GET/v1.1/document/retrieve_document
Retrieve full document content and metadata by identifier.

Parameters

DocumentIdentifierstringrequired

Unique identifier of the document to retrieve.

e.g. 32019L0001
markdownbooleandefault: false

When true, converts the document's HTML to Markdown and includes it in the `markdown` response field. The `html` field is omitted from the response to save bandwidth.

internal_linksbooleandefault: false

When false (default), links to other Moonlit documents are removed from the HTML and only their text is kept. When true, those links are kept.

html_startintegerdefault: 0

First character of the HTML to return (0-based). Pair with `html_end` to page through large documents.

min 0
html_endinteger | null

Character position to stop at (exclusive). When a span is requested the response also carries the full HTML length. The cut is by character and can land inside a tag.

min 0

Example request

curl "https://api.moonlit.ai/v1.1/document/retrieve_document?DocumentIdentifier=32019L0001" \
  -H "Authorization: Bearer YOUR_API_KEY"

Try it

GET/v1.1/document/retrieve_documentNot run yet
Region

The key stays in this browser tab and is sent only to api.moonlit.ai. Every request counts against your plan like any other call.

Response

Full document with text content and metadata. Fields without a value are left out.

identifierstring

Unique document identifier.

secondaryIdentifierstring | null

Secondary document identifier.

tertiaryIdentifierstring | null

Tertiary document identifier.

languagestring | null

Document language code.

datestring | null

Primary document date in YYYY-MM-DD format (falls back to the end date when no primary date is known).

decisionDatestring | null

Date the decision was rendered or the act adopted, in YYYY-MM-DD format.

enactmentDatestring | null

Date the act was enacted, in YYYY-MM-DD format.

publicationDatestring | null

Date the document was officially published, in YYYY-MM-DD format.

entryIntoForceDatestring | null

Date the document entered into force, in YYYY-MM-DD format.

validFromstring | null

Start of the document's validity period, in YYYY-MM-DD format.

validTostring | null

End of the document's validity period, in YYYY-MM-DD format.

proceedingsStartDatestring | null

Date the proceedings started, in YYYY-MM-DD format.

titlestring | null

Document title.

sourcestring | null

Issuing entity name (e.g. court or legislative body).

jurisdictionstring | null

Jurisdiction name for the document.

portalstring | null

Portal domain the document originates from.

sourceUrlstring | null

Source URL to the original document.

sourcePdfstring | null

Original publisher PDF URL. Archived attachments are available through pdfs[].url.

pdfsobject[] | null

Ordered PDF attachments. Each archived attachment has an authenticated API path.

sasUrlstring | null

Short-lived read-only URL for this archived PDF; null when unavailable.

ttlinteger | null

SAS URL lifetime in seconds from issuance; null when no SAS URL is available.

sourceUrlstring | null

Original publisher PDF URL.

fileNamestring | null

Original attachment filename.

isPrimaryboolean

Whether this is the primary PDF.

urlstring | null

Authenticated API path for this archived PDF, when available.

sourcesobject[] | null

Hierarchical list of source entries.

idstring

Unique identifier.

parentIdstring | null

Parent node identifier.

namestring | null

Full display name.

documentTypesobject[] | null

Hierarchical list of document-type classification entries.

idstring

Unique identifier.

parentIdstring | null

Parent node identifier.

namestring | null

Full display name.

textstring | null

Full text content of the document.

htmlstring | null

HTML rendition of the full document.

htmlLengthinteger | null

Length in characters of the full HTML. Only present when `html_start` / `html_end` were used, so the rest can be requested.

markdownstring | null

Markdown rendition of the document (only present when markdown=true).

yearinteger | null

Year of `date` (primary date, falling back to the end date).

inForceboolean | null

Whether the document is currently in force.

referencedinteger | null

Number of documents that reference this document.

summarystring | null

AI-generated summary of the document.

metadataobject | null

Source-specific metadata; keys vary per portal.

publicAccessboolean | null

Whether the document is publicly accessible.

{
  "identifier": "32019L0001",
  "secondaryIdentifier": "dir/2019/1/oj",
  "tertiaryIdentifier": "MNLT:EU:EUEURLEX:2019:32019L0001",
  "language": "EN",
  "date": "2018-12-11",
  "decisionDate": "2018-12-11",
  "enactmentDate": "2018-12-11",
  "publicationDate": "2019-01-14",
  "entryIntoForceDate": "2019-02-03",
  "validFrom": "2019-02-03",
  "title": "Council of the European Union and European Parliament 11 December 2018, Directive (EU) 2019/1 of the European Parliament and of the Council of 11 December 2018 ...",
  "source": "Council of the European Union and European Parliament",
  "jurisdiction": "European Union",
  "portal": "eur-lex.europa.eu",
  "sourceUrl": "https://eur-lex.europa.eu/legal-content/EN/TXT/?uri=CELEX:32019L0001",
  "sourcePdf": "http://publications.europa.eu/resource/cellar/1609a9fc-17cc-11e9-8d04-01aa75ed71a1.0006.01/DOC_1",
  "sources": [
    {
      "id": "b49c23adeaa6a345aa815e401c6d194b",
      "parentId": null,
      "name": "Legislative bodies"
    },
    {
      "id": "05bd5d5f816e9836f8ffac5cbfed674c",
      "parentId": "b49c23adeaa6a345aa815e401c6d194b",
      "name": "Council of the European Union and European Parliament"
    }
  ],
  "documentTypes": [
    {
      "id": "87a86c141d2c0649a699745ba63e4c6b",
      "parentId": "18fead608f1a4dcb5671b9fc8aeab4d1",
      "name": "European law"
    },
    {
      "id": "f01159d4ed0dc13c024b743d514e1401",
      "parentId": "8dba0d10dfdf2460a34ddf4eeb7b6584",
      "name": "EU directives"
    }
  ],
  "text": "14.1.2019 EN Official Journal of the European Union L 11/3 DIRECTIVE (EU) 2019/1 OF THE EUROPEAN PARLIAMENT AND OF THE COUNCIL of 11 December 2018 to empower th ...",
  "html": "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"> <col width=\"10%\"> <col width=\"10%\"> <col width=\"60%\"> <col width=\"20%\"> <tbody> <tr> <td> <p cla ...",
  "year": 2018,
  "inForce": true,
  "referenced": 629,
  "metadata": {
    "author_uris": [
      "http://publications.europa.eu/resource/authority/corporate-body/CONSIL",
      "http://publications.europa.eu/resource/authority/corporate-body/EP"
    ],
    "content_kind": "xhtml",
    "deadline_dates": "2024-12-12",
    "in_force": true,
    "langs_present": "DEU|ENG|FRA|ITA|NLD|SPA",
    "primary_lang": "ENG",
    "resource_types": "DIR",
    "sector": "3",
    "transposition_date": "2021-02-04"
  },
  "publicAccess": true
}

Errors

401Missing or invalid API key. Sent by the API gateway: the body is {statusCode, message} instead of detail.
403Forbidden by role or jurisdiction scope
404No document with this identifier
422Request validation error
429Monthly quota exhausted. Sent by the API gateway; the body is {"statusCode": 429, "message": "..."}.
500Internal server error

Retrieve an archived PDF

GET/v1.1/document/retrieve_pdf

Parameters

DocumentIdentifierstringrequired

Identifier of the parent document.

pdfIndexinteger | null

Zero-based attachment index; omitted selects the primary PDF.

min 0

Example request

curl "https://api.moonlit.ai/v1.1/document/retrieve_pdf?DocumentIdentifier=62018CJ0311" \
  -H "Authorization: Bearer YOUR_API_KEY"

Try it

GET/v1.1/document/retrieve_pdfNot run yet
Region

The key stays in this browser tab and is sent only to api.moonlit.ai. Every request counts against your plan like any other call.

Response

Successful Response

Errors

206Partial Content
422Validation Error
429Monthly quota exhausted. Sent by the API gateway; the body is {"statusCode": 429, "message": "..."}.

List Document Articles

GET/v1.1/document/articles
Returns the list of articles/elements within a composite document (e.g. a law or regulation). Each article includes its identifier, title, hierarchy level, and the number of documents that reference it. Use the `elementIdentifier` from the response as the `article_reference_id` parameter in reference search to narrow results to a specific article. Set `hierarchy=true` to receive a nested tree structure where child articles are nested under their parent elements based on the `level` field.

Parameters

DocumentIdentifierstringrequired

Unique identifier of the document to list articles for.

e.g. 32016R0679
hierarchybooleandefault: true

When true (default), returns articles as a nested tree structure based on hierarchy levels. When false, returns a flat list.

includeHtmlbooleandefault: false

When true, includes the HTML content of each article/element in the response. When false (default), the elementHtml field is omitted.

pageinteger | null

1-based page. When set, the response is `{total, page, num_results, articles}` with one page of elements in document order. Omit it for the whole document as a plain list (deprecated: large codes have tens of thousands of elements).

min 1
num_resultsintegerdefault: 200

Elements per page (1-1000). Only used with `page`.

1 to 1000

Example request

curl "https://api.moonlit.ai/v1.1/document/articles?DocumentIdentifier=32016R0679" \
  -H "Authorization: Bearer YOUR_API_KEY"

Try it

GET/v1.1/document/articlesNot run yet
Region

The key stays in this browser tab and is sent only to api.moonlit.ai. Every request counts against your plan like any other call.

Response

Without `page`: every article in the document as a list (empty if not a composite document). With `page`: one page plus the total.

elementIdentifierstring

Unique article/element identifier. Use as article_reference_id in reference search.

elementTitlestring | null

Article title (e.g. 'Article 1').

elementSubTitlestring | null

Article subtitle.

elementHtmlstring | null

HTML content of the article/element.

referenceCountinteger

Number of documents referencing this article.

levelinteger

Hierarchy level within the document.

globalOrderinteger

Sort order within the document.

childrenobject[] | null

Nested child articles/elements. Only populated when hierarchy=true.

array of the same shape

The response is a JSON array; each item has the fields below.

[
  {
    "elementIdentifier": "32016R0679_PREAMBLE",
    "elementTitle": null,
    "elementSubTitle": null,
    "elementHtml": null,
    "referenceCount": 0,
    "level": 0,
    "globalOrder": 0,
    "children": null
  },
  {
    "elementIdentifier": "32016R0679_CHAPTER_I",
    "elementTitle": "CHAPTER I",
    "elementSubTitle": "General provisions",
    "elementHtml": null,
    "referenceCount": 0,
    "level": 0,
    "globalOrder": 1,
    "children": [
      {
        "elementIdentifier": "32016R0679_ART-001",
        "elementTitle": "Article 1",
        "elementSubTitle": "Subject-matter and objectives",
        "elementHtml": null,
        "referenceCount": 2227,
        "level": 1,
        "globalOrder": 2,
        "children": [
          {
            "elementIdentifier": "32016R0679_ART-001_PAR-1",
            "elementTitle": null,
            "elementSubTitle": null,
            "elementHtml": null,
            "referenceCount": 0,
            "level": 2,
            "globalOrder": 3,
            "children": null
          },
          {
            "elementIdentifier": "32016R0679_ART-001_PAR-2",
            "elementTitle": null,
            "elementSubTitle": null,
            "elementHtml": null,
            "referenceCount": 0,
            "level": 2,
            "globalOrder": 4,
            "children": null
          }
        ]
      },
      {
        "elementIdentifier": "32016R0679_ART-002",
        "elementTitle": "Article 2",
        "elementSubTitle": "Material scope",
        "elementHtml": null,
        "referenceCount": 2679,
        "level": 1,
        "globalOrder": 6,
        "children": [
          {
            "elementIdentifier": "32016R0679_ART-002_PAR-1",
            "elementTitle": null,
            "elementSubTitle": null,
            "elementHtml": null,
            "referenceCount": 0,
            "level": 2,
            "globalOrder": 7,
            "children": null
          },
          {
            "elementIdentifier": "32016R0679_ART-002_PAR-2",
            "elementTitle": null,
            "elementSubTitle": null,
            "elementHtml": null,
            "referenceCount": 0,
            "level": 2,
            "globalOrder": 8,
            "children": null
          }
        ]
      }
    ]
  }
]

Errors

401Missing or invalid API key. Sent by the API gateway: the body is {statusCode, message} instead of detail.
403Forbidden by role or jurisdiction scope
422Request validation error
429Monthly quota exhausted. Sent by the API gateway; the body is {"statusCode": 429, "message": "..."}.
500Internal server error

List Document Versions

GET/v1.1/document/versions
Returns the versions of a document, most recent first, with the validity window of each. Pass the identifier of the document or of any of its versions: both return the same lineage. `validTo` is exclusive and equals the next version's `validFrom`. `inForce` is true when today falls inside that window. Use the `identifier` of a version as the `Identifier` parameter of /v1.1/document/version to retrieve its full content.

Parameters

DocumentIdentifierstringrequired

Identifier of a document, or of any one of its versions. Either way the response is that document's whole lineage, and `documentIdentifier` says which document it is.

e.g. 11957E/TXT
pageintegerdefault: 1

1-based index of the page to return.

min 1
num_resultsintegerdefault: 200

Number of versions per page.

1 to 1000
as_ofstring | null

Return the version in force on this date (YYYY-MM-DD) in each language: validFrom on or before it, and validTo after it or null.

e.g. 2015-01-01
in_forceboolean | null

Return only versions whose inForce flag matches this value.

Example request

curl "https://api.moonlit.ai/v1.1/document/versions?DocumentIdentifier=11957E%2FTXT" \
  -H "Authorization: Bearer YOUR_API_KEY"

Try it

GET/v1.1/document/versionsNot run yet
Region

The key stays in this browser tab and is sent only to api.moonlit.ai. Every request counts against your plan like any other call.

Response

A page of versions (empty when the document has none)

documentIdentifierstring

The document this lineage belongs to: the one requested, or the document of the version requested.

totalinteger

Total number of versions matching the request.

pageinteger

1-based index of the returned page.

num_resultsinteger

Page size used for this response.

versionsobject[]

Versions on this page, ordered by validFrom descending.

identifierstring

Unique version identifier. Pass as Identifier to /v1.1/document/version.

languagestring | null

Version language code.

titlestring | null

Version title.

datestring | null

Version date in YYYY-MM-DD format — the day this version took effect.

validFromstring

First day this version is valid, in YYYY-MM-DD format.

validTostring | null

First day this version is no longer valid, in YYYY-MM-DD format. Exclusive, and equal to the next version's validFrom. Null on the last version of a chain, unless the source gives an end date.

publicationDatestring | null

Publication date in YYYY-MM-DD format.

lastScrapedDatestring | null

When this version was last fetched from its source.

inForceboolean | null

Whether today falls inside this version's validFrom-validTo window.

isOriginalboolean

Whether this is the originally adopted text rather than a later rendition.

consolidationStatusstring

Whether this version is the adopted text or a consolidation.

sourceUrlstring | null

Source URL to this version at the original portal.

Errors

401Missing or invalid API key. Sent by the API gateway: the body is {statusCode, message} instead of detail.
403Forbidden by role or jurisdiction scope
404Document not found
422Request validation error
429Monthly quota exhausted. Sent by the API gateway; the body is {"statusCode": 429, "message": "..."}.
500Internal server error

Retrieve Document Version

GET/v1.1/document/version
Retrieve one version of a document by its version identifier, with the same content and metadata as retrieve_document plus the version's validity window. Jurisdiction, source and document-type classification belong to the document rather than the version, and are returned from it.

Parameters

Identifierstringrequired

Unique identifier of the version, as returned by /v1.1/document/versions.

e.g. 12012E/TXT-eng
markdownbooleandefault: false

When true, converts the version's HTML to Markdown and includes it in the `markdown` response field. The `html` field is omitted from the response to save bandwidth.

internal_linksbooleandefault: false

When false (default), links to other Moonlit documents are removed from the HTML and only their text is kept. When true, those links are kept.

html_startintegerdefault: 0

First character of the HTML to return (0-based). Pair with `html_end` to page through large versions.

min 0
html_endinteger | null

Character position to stop at (exclusive). When a span is requested the response also carries the full HTML length. The cut is by character and can land inside a tag.

min 0

Example request

curl "https://api.moonlit.ai/v1.1/document/version?Identifier=12012E%2FTXT-eng" \
  -H "Authorization: Bearer YOUR_API_KEY"

Try it

GET/v1.1/document/versionNot run yet
Region

The key stays in this browser tab and is sent only to api.moonlit.ai. Every request counts against your plan like any other call.

Response

Full version with text content and metadata

identifierstring

Unique document identifier.

secondaryIdentifierstring | null

Secondary document identifier.

tertiaryIdentifierstring | null

Tertiary document identifier.

languagestring | null

Document language code.

datestring | null

Primary document date in YYYY-MM-DD format (falls back to the end date when no primary date is known).

decisionDatestring | null

Date the decision was rendered or the act adopted, in YYYY-MM-DD format.

enactmentDatestring | null

Date the act was enacted, in YYYY-MM-DD format.

publicationDatestring | null

Publication date in YYYY-MM-DD format.

entryIntoForceDatestring | null

Date the document entered into force, in YYYY-MM-DD format.

validFromstring

First day this version is valid, in YYYY-MM-DD format.

validTostring | null

First day this version is no longer valid, in YYYY-MM-DD format. Exclusive, and equal to the next version's validFrom. Null on the last version of a chain, unless the source gives an end date.

proceedingsStartDatestring | null

Date the proceedings started, in YYYY-MM-DD format.

titlestring | null

Document title.

sourcestring | null

Issuing entity name (e.g. court or legislative body).

jurisdictionstring | null

Jurisdiction name for the document.

portalstring | null

Portal domain the document originates from.

sourceUrlstring | null

Source URL to the original document.

sourcePdfstring | null

Original publisher PDF URL. Archived attachments are available through pdfs[].url.

pdfsobject[] | null

Ordered PDF attachments. Each archived attachment has an authenticated API path.

sasUrlstring | null

Short-lived read-only URL for this archived PDF; null when unavailable.

ttlinteger | null

SAS URL lifetime in seconds from issuance; null when no SAS URL is available.

sourceUrlstring | null

Original publisher PDF URL.

fileNamestring | null

Original attachment filename.

isPrimaryboolean

Whether this is the primary PDF.

urlstring | null

Authenticated API path for this archived PDF, when available.

sourcesobject[] | null

Hierarchical list of source entries.

idstring

Unique identifier.

parentIdstring | null

Parent node identifier.

namestring | null

Full display name.

documentTypesobject[] | null

Hierarchical list of document-type classification entries.

idstring

Unique identifier.

parentIdstring | null

Parent node identifier.

namestring | null

Full display name.

textstring | null

Full text content of the document.

htmlstring | null

HTML rendition of the full document.

htmlLengthinteger | null

Length in characters of the full HTML. Only present when `html_start` / `html_end` were used, so the rest can be requested.

markdownstring | null

Markdown rendition of the document (only present when markdown=true).

yearinteger | null

Year of `date` (primary date, falling back to the end date).

inForceboolean | null

Whether the document is currently in force.

referencedinteger | null

Number of documents that reference this document.

summarystring | null

AI-generated summary of the document.

metadataobject | null

Source-specific metadata; keys vary per portal.

publicAccessboolean | null

Whether the document is publicly accessible.

documentIdentifierstring

Identifier of the document this is a version of.

lastScrapedDatestring | null

When this version was last fetched from its source.

isOriginalboolean

Whether this is the originally adopted text rather than a later rendition.

consolidationStatusstring

Whether this version is the adopted text or a consolidation.

Errors

401Missing or invalid API key. Sent by the API gateway: the body is {statusCode, message} instead of detail.
403Forbidden by role or jurisdiction scope
404Version not found
422Request validation error
429Monthly quota exhausted. Sent by the API gateway; the body is {"statusCode": 429, "message": "..."}.
500Internal server error
esc
↑↓ navigateenter openesc close