Data API quickstart

From your subscription key to a first search result and a full document, in two requests.

Before you start

Our team provisions your subscription key; see Get access. Send it on every request as a header:

Ocp-Apim-Subscription-Key: YOUR_SUBSCRIPTION_KEY
Keep the key out of client-side code and public repositories.

Keyword search takes a query and returns matching documents in the jurisdictions you name. Jurisdiction names must come from jurisdictions_portals; any other spelling returns an empty result.

curl -X POST "https://api.moonlit.ai/v1.1/search/keyword_search" \
  -H "Ocp-Apim-Subscription-Key: YOUR_SUBSCRIPTION_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "query": "data protection",
    "jurisdictions": ["European Union"],
    "num_results": 5
  }'

For a question in plain language, use hybrid_search instead. It takes the same parameters and merges keyword and semantic results into one ranking. Keyword search is best when the citation or exact wording is known.

2. Read a document

Take the identifier of a result and ask for the document in full: text, metadata and summary.

curl "https://api.moonlit.ai/v1.1/document/retrieve_document?DocumentIdentifier=62018CJ0311" \
  -H "Ocp-Apim-Subscription-Key: YOUR_SUBSCRIPTION_KEY"

Abbreviated response; the full field list is under retrieve_document:

{
  "title": "Data Protection Commissioner v Facebook Ireland (Schrems II)",
  "text": "In those circumstances, the referring court...",
  "summary": "The Court of Justice invalidated the EU-US Privacy Shield...",
  "referenced": 165,
  "inForce": true,
  "sourceUrl": "https://curia.europa.eu/..."
}

Where next

  • The reference documents every endpoint, parameter and response field, and runs requests with your key from a Try it panel.
  • Integration patterns shows four things to build and the endpoints each one combines.
  • A 401 means a missing or invalid key; a 429 means the monthly quota is used up. See Errors.
esc
↑↓ navigateenter openesc close