Your First API Call
Make your first request to the Moonlit API and retrieve European legal data in under a minute.
What you'll build
The fastest way to understand the Moonlit API is to make a real request. In this guide you will use a single cURL command to search across European case law and see structured results come back with ECLI identifiers, court metadata, and relevance scores. The hybrid search endpoint is the recommended starting point because it combines keyword matching with semantic understanding. You send a natural-language query and get back the most relevant documents from courts like the CJEU, Hoge Raad, and Bundesgerichtshof. By the end of this one-minute exercise you will have a working API call that you can adapt into any programming language or workflow.
Architecture
┌────────────────┐ ┌──────────────────┐ ┌────────────────┐ │ Your Terminal │───▶│ Moonlit API │───▶│ JSON Response │ │ (cURL) │ │ Hybrid Search │ │ ECLI + scores │ └────────────────┘ └──────────────────┘ └────────────────┘
Prerequisites
- A Moonlit API key (book a call at moonlit.ai/book-a-call to get yours)
- A terminal with cURL installed (macOS, Linux, or Windows WSL)
Step-by-step
Set your API key
Export your API key as an environment variable so you can reuse it across requests. Replace the placeholder with the key from your Moonlit dashboard.
export MOONLIT_API_KEY="your-api-key-here"Make a hybrid search request
Run this cURL command to search for GDPR case law across the EU and the Netherlands. The hybrid endpoint combines keyword matching and semantic understanding for the best overall results.
curl -X POST "https://api.moonlit.ai/v1.1/search/hybrid_search" \
-H "Ocp-Apim-Subscription-Key: $MOONLIT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"query": "right to data portability under GDPR",
"jurisdictions": ["European Union", "Netherlands"],
"num_results": 5
}'Understand the response
The API returns a JSON object with a result envelope containing count and an array of results. Each result includes an identifier (e.g. ECLI:EU:C:2023:456), the court (source), date, a score between 0 and 1, and a short summary. You can use the identifier from any result to retrieve the full document text via the /v1.1/document/retrieve_document endpoint.
Complete Code
# Set your API key
export MOONLIT_API_KEY="your-api-key-here"
# Search for GDPR data portability case law
curl -s -X POST "https://api.moonlit.ai/v1.1/search/hybrid_search" \
-H "Ocp-Apim-Subscription-Key: $MOONLIT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"query": "right to data portability under GDPR",
"jurisdictions": ["European Union", "Netherlands"],
"num_results": 5
}' | python3 -m json.tool