The Query Interface module provides a secure and efficient way for users and applications to interact with the DataHive legal data ecosystem. This interface allows for querying legal documents, metadata, and insights generated from the processing pipeline. The Query Interface is designed to support both RESTful API calls and WebSocket connections for real-time data retrieval.
-
Document Retrieval: Access legal documents stored within the DataHive network based on various search criteria.
-
Metadata Access: Fetch associated metadata for documents, including authorship, jurisdiction, document type, and timestamps.
-
Search Functionality: Perform complex queries to find relevant legal documents using keywords, phrases, or specific fields.
-
Real-Time Updates: Receive notifications and updates on document status changes or new submissions through WebSocket connections.
https://api.datahive.com/v1/query
All API requests require authentication using an API key:
Authorization: Bearer YOUR_API_KEY
GET /documents/{documentId}
Authorization: Bearer <token>
Response Format
{
"status": "success",
"data": {
"id": "string",
"title": "string",
"content": "string",
"metadata": {
"jurisdiction": "string",
"type": "string",
"created_at": "ISO8601"
}
}
}
GET /documents/search?query={searchTerm}&limit={number}
Authorization: Bearer <token>
Query Parameters
query
: The search term or phrase.limit
: The maximum number of results to return.
Response Format
{
"status": "success",
"data": [
{
"id": "string",
"title": "string",
"snippet": "string"
}
],
"pagination": {
"currentPage": 1,
"totalPages": 10,
"totalItems": 100,
"itemsPerPage": 10
}
}
GET /documents/{documentId}/metadata
Authorization: Bearer <token>
Response Format
{
"status": "success",
"data": {
"id": "string",
"metadata": {
"jurisdiction": "string",
"type": "string",
"author": "string",
"created_at": "ISO8601"
}
}
}
To receive real-time updates about document status or new submissions:
const ws = new WebSocket('wss://api.datahive.com/v1/query/ws');
ws.onopen = () => {
console.log('WebSocket connection established');
};
ws.onmessage = (event) => {
const data = JSON.parse(event.data);
console.log('Received update:', data);
};
To subscribe to updates for specific documents:
{
"action": "subscribe",
"documentId": "{documentId}"
}
- Each API key is limited to 1000 requests per hour.
- Rate limit headers are included in responses to help monitor usage.
Common error codes include:
- 400: Bad Request - Invalid parameters.
- 401: Unauthorized - Invalid API key.
- 403: Forbidden - Insufficient permissions.
- 404: Not Found - Document does not exist.
- 429: Too Many Requests - Rate limit exceeded.
- 500: Internal Server Error - Server-side issue.
{
"status": "error",
"error": {
"code": "string",
"message": "string"
}
}
The Query Interface is a powerful tool for accessing and interacting with legal data within the DataHive ecosystem. By providing both RESTful and WebSocket capabilities, it allows users to efficiently retrieve documents, access metadata, and receive real-time updates. For further details on implementation and best practices, please refer to the API Documentation and Integration Guide.