API Reference
Endpoint reference for the Moonlit Data API, generated from the live OpenAPI spec: search, filter values, document retrieval, and the Luna research assistant.
Try requests live in the interactive Swagger docs.
Base URL
https://api.moonlit.ai/v1.1Authentication
Ocp-Apim-Subscription-KeyRate limits
Quotas are managed per subscription; a 429 means the monthly quota is exhausted. See Get access.
Response Format
JSON
Authentication
All API requests must include your subscription key in the Ocp-Apim-Subscription-Key header. Access is provisioned by our team; see Get access.
Keep your subscription key secret. Do not expose it in client-side code or public repositories. If your key is compromised, contact our team immediately.
curl -X POST "https://api.moonlit.ai/v1.1/search/keyword_search" \
-H "Content-Type: application/json" \
-H "Ocp-Apim-Subscription-Key: YOUR_SUBSCRIPTION_KEY" \
-d '{"query": "huurrecht opzegging", "jurisdictions": ["Netherlands"]}'Base URL
All API endpoints are relative to the following base URL:
https://api.moonlit.ai/v1.1For example, the keyword search endpoint is available at https://api.moonlit.ai/v1.1/search/keyword_search.
Errors
When a request fails, the API returns a JSON body with a single detail field describing what went wrong:
{
"detail": "Invalid or missing API key."
}The exception is 422: FastAPI validation errors return a structured detail array listing each invalid field and the reason. These statuses appear across the API; the errors each endpoint can return are listed on its endpoint page.
| Status Code | Description |
|---|---|
400 | Invalid filter value or page out of range. |
401 | Missing or invalid subscription key. |
403 | Forbidden by role or jurisdiction scope. |
422 | Request validation error. Returns the FastAPI validation detail structure instead of a plain string. |
500 | Internal server error. |
504 | Search timed out. Only returned by the hybrid and reranked search routes. |
Gateway errors
A 429 is returned by the API gateway before the request reaches the API, when the monthly quota for your subscription is exhausted. It has a different body shape: {"statusCode": 429, "message": "..."}. Gateway-level errors are not part of the OpenAPI spec.
Choosing the right search
| Endpoint | Searches by | Use when |
|---|---|---|
| keyword_search | Exact terms, Boolean operators, wildcards | You know exact terms, citations, or need date or citation sorting |
| hybrid_search | Keyword + semantic, fused | Default for natural-language questions |
| hybrid_search_reranked | Hybrid + reranking pass | Highest precision; slower |
| semantic_search | Meaning only | Concept discovery when wording is unknown |
| semantic_search_reranked | Semantic + reranking | Higher precision concept discovery; slower |
| reference_search | The citation graph | Documents citing or cited by a given document |
| ask_question | Agentic research, streamed | A synthesized answer with sources instead of a result list |
hybrid_search. Drop to keyword_search for exact terms, and add reranking when precision matters more than latency.Endpoints
Search
Query the corpus by keyword, by meaning, or through the citation graph.
| Method | Endpoint | Description |
|---|---|---|
| POST | keyword_search | Keyword Search |
| POST | semantic_search | Semantic Search |
| POST | semantic_search_reranked | Semantic Search with Reranking |
| POST | hybrid_search | Hybrid Search |
| POST | hybrid_search_reranked | Hybrid Search with Reranking |
| POST | reference_search | Reference Search |
Filters
Canonical filter values to scope search requests.
| Method | Endpoint | Description |
|---|---|---|
| GET | documenttypes | List Document Types |
| GET | jurisdictions_portals | List Jurisdictions and Portals |
| GET | trees | List Fields-of-Law Tree |
| GET | sources | List Sources |
| GET | semantic_portals | List Semantic Portals |
Documents
Retrieve full documents and their article-level structure.
| Method | Endpoint | Description |
|---|---|---|
| GET | retrieve_document | Retrieve Document |
| GET | articles | List Document Articles |
Luna AI
Initialize a research chat and stream answers over Server-Sent Events.
| Method | Endpoint | Description |
|---|---|---|
| POST | initialize_chat | Initialize a Luna research chat session |
| POST | ask_question | Ask a research question (SSE stream) |