Data API quickstart
The Data API is REST access to Moonlit's legal corpus: search, retrieval, references, and filters. This page takes you from a provisioned subscription key to your first search result and full document.
Before you start
Data API access is provisioned by our team; see Get access. Useful to have ready for that conversation: what you are building, the jurisdictions you need, and your expected monthly call volume. Once provisioned, you receive a subscription key. Include it in every request as a header:
Ocp-Apim-Subscription-Key: YOUR_SUBSCRIPTION_KEYKeep the subscription key secret. Do not expose it in client-side code or public repositories.
Step 1: Search European law
Make your first search request. Keyword search accepts a query string and returns matching legal documents in the jurisdictions you name. Jurisdiction values must come from jurisdictions_portals; other spellings return empty results.
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 most integrations, hybrid_search is the recommended default: it takes the same parameters and combines keyword and semantic retrieval in one ranked list. Keyword search is best when the citation or exact wording is already known.
Step 2: Retrieve a full document
Use the identifier from your search results to retrieve the 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 documented at 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,
"sourceUrl": "https://curia.europa.eu/..."
}Next steps
- The API reference documents every endpoint, parameter, and response field, generated from the live OpenAPI spec.
- Integration patterns shows what to build and which endpoints combine for each shape.
- A
401response means a missing or invalid subscription key; a429means the monthly quota is exhausted. Both are documented under Errors. - For a Claude-native flow instead of REST, see the MCP server.