Data API quickstart
From your API key to a first search result and a full document, in two requests.
Before you start
An Owner or Developer of your organization generates the key under Integrations, Data API; see API keys. Send it on every request as a Bearer token in the Authorization header:
Authorization: Bearer YOUR_API_KEYExisting integrations that send the key in the Ocp-Apim-Subscription-Key header keep working.
1. Search
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 400. Document type, field-of-law and source ids are not checked: an unknown id returns no results instead of an error.
curl -X POST "https://api.moonlit.ai/v1.1/search/keyword_search" \
-H "Authorization: Bearer YOUR_API_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 filters and merges keyword and semantic results into one ranking; it has no sorting or facets. 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, HTML and metadata.
curl "https://api.moonlit.ai/v1.1/document/retrieve_document?DocumentIdentifier=62018CJ0311" \
-H "Authorization: Bearer YOUR_API_KEY"Abbreviated response. Fields without a value are left out; the full field list is under retrieve_document:
{
"identifier": "62018CJ0311",
"title": "Court of Justice (Grand Chamber) 16 July 2020, C-311/18 (Data Protection Commissioner v Facebook Ireland Limited and Maximillian Schrems.)",
"date": "2020-07-16",
"jurisdiction": "European Union",
"source": "Court of Justice (Grand Chamber)",
"referenced": 2808,
"sourceUrl": "https://eur-lex.europa.eu/legal-content/EN/TXT/?uri=CELEX:62018CJ0311",
"text": "JUDGMENT OF THE COURT (Grand Chamber) 16 July 2020 ..."
}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 three things to build and the endpoints each one combines.
- A
401means a missing or invalid key; a429means the monthly quota is used up. See Errors.