AnrakLegal Developer Playbook
API v1 • 588,024+ docsREST API & MCP Integration
AnrakLegal provides a branded interface to Indian legal case law. Authenticate once, access 588,024+ Supreme Court and High Court judgments, statutes, and tribunals—all without revealing upstream infrastructure to your users.
From Zero to Legal Research
Get your API key
Visit /console and generate a new API key. Save it securely—you'll only see the full key once.
Search for cases
Returns 10 results per page with insights: top courts, year distribution, popular tags.
Retrieve full judgment
Get complete case text (50-200KB), metadata, citations, and case history.
Monitor usage
Or visit /usage for a visual dashboard with per-key stats, endpoint distribution, and recent activity.
Authentication
Every request requires your AnrakLegal API key. We support multiple header formats for flexibility across different client integrations:
Preferred
x-anrak-key: YOUR_KEYAlternative
x-api-key: YOUR_KEYBearer Token
Authorization: Bearer YOUR_KEYLegacy
x-lexsight-key: YOUR_KEYSecurity
Keys are SHA-256 hashed server-side. Never commit keys to version control, share in Slack/email, or expose in client-side code. Rotate immediately if compromised.
REST API Endpoints
Base URL: https://anraklegal.fly.dev
Full-text search across 588,024+ Indian legal documents with AI-powered insights.
Parameters
qstringrequiredSearch query (keywords, phrases, field filters)
pageNumnumberPage number (default: 0, starts at 0)
maxPagesnumberFetch multiple pages in one call (max: 1000)
doctypesstringFilter by: judgments, laws, tribunals, supremecourt
fromyearnumberStart year for temporal filtering
toyearnumberEnd year for temporal filtering
forumstringFilter by court/forum name
statestringFilter district courts by state (e.g., maharashtra)
Retrieve complete judgment text with metadata, citations, and case history.
Parameters
docIdstringrequiredDocument ID from search results (tid field)
maxCitesnumberNumber of citations to include (max: 50)
maxCitedbynumberNumber of citing cases to include (max: 50)
Lightweight metadata for dashboards—no full text, ~2KB response.
Parameters
docIdstringrequiredDocument ID from search results
Get context snippets where query terms appear in the document.
Parameters
docIdstringrequiredDocument ID from search results
qstringrequiredQuery terms to search within document
Download original court-filed document (PDF/HTML/DOC) as base64.
Parameters
docIdstringrequiredDocument ID from search results
View usage statistics for your API key (requests, endpoints, status codes).
Response Examples
Search Response
Document Response
Usage Response
Original Document Response
Error Responses
Verify the document ID (tid) from search results. Some very old documents may be unavailable.
Retry with exponential backoff. If errors persist, contact support. We cache responses (5-min TTL) to minimize upstream issues.
Rate Limiting & Caching
Rate Limits
- •3 API keys per email (request more via support)
- •No per-minute throttling—subject to plan limits
- •Monitor usage at /usage
- •Deactivate unused keys to prevent abuse
Caching
- •LRU in-memory cache: 200 entries, 5-minute TTL
- •Repeated queries return in <50ms
- •Reduces API quota consumption
- •Cache-Control headers indicate cache hits
Performance Characteristics
Based on production testing with 588,024+ documents (cached responses significantly faster):
| Operation | Response Size | Time (uncached) | Best Use Case |
|---|---|---|---|
| Search | ~50KB | 1-2s | Initial discovery |
| Document | 50-200KB | 2-4s | Full analysis |
| Metadata | ~2KB | 0.5s | Quick reference |
| Fragment | 5-20KB | 1s | Targeted lookup |
| Original | 100KB-5MB | 3-10s | Official record |
Code Examples
Node.js / TypeScript
Python
cURL
MCP Integration for AI Assistants
Model Context Protocol (MCP) allows AI assistants like Claude, Cursor, and other LLMs to directly access AnrakLegal tools. Instead of copy-pasting API responses, your AI can search cases, retrieve judgments, and analyze legal documents autonomously.
Installation
Configure Claude Desktop:
Open your Claude Desktop configuration file:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
Restart Claude Desktop:
- macOS: Press Cmd+Q then reopen
- Windows: Close all windows, ensure process exits, then reopen
Verify installation:
Ask Claude: "What AnrakLegal tools do you have access to?" Should list 5 tools below.
NPX Installation
The npx command automatically downloads and runs the latest MCP server. No manual installation or updates required. Requires Node.js 18+ on your system.
Available MCP Tools
anraklegalSearchSearch Indian legal documents
anraklegalDocumentRetrieve full judgment text
anraklegalMetadataGet lightweight case metadata
anraklegalFragmentGet snippets matching query
anraklegalOriginalDownload original PDF/HTML
Example MCP Workflow
User to Claude:
"Can a third party who wasn't a signatory invoke an arbitration agreement?"
Claude's Actions:
- Calls
anraklegalSearch("arbitration third party non-signatory") - Receives 50 relevant cases with insights
- Calls
anraklegalDocument("63240555")for leading case - Analyzes 117KB judgment text
- Synthesizes answer with proper citations: "Yes, under certain conditions established in My Preferred Transformation vs Sumithra Inn (2021)..."
Why MCP?
MCP enables agentic workflows: AI assistants can autonomously search, retrieve, analyze, and cite legal documents without manual API calls. Perfect for legal research, brief generation, and case analysis.
Troubleshooting
❌ "Unauthorised" or 401 errors
- Verify API key is active in /console
- Check for typos—keys are case-sensitive
- Ensure header format:
x-anrak-key: YOUR_KEY - Key must start with
ANRAK-
🔍 No search results or "Document not found"
- Try broader search terms (e.g., "arbitration" instead of "arbitration section 11(6)(a)")
- Check document ID format—must be numeric string from search results (
tidfield) - Very old documents (<1990) may have limited availability
- Use filters:
?doctypes=supremecourt&fromyear=2020
⏱️ Slow responses or timeouts
- First request is slower (~2-4s), subsequent requests cached (<50ms)
- Large documents (200KB+) take longer—use
/metaendpoint for quick checks - Original PDFs (5MB+) can take 10s—download once and cache client-side
- If errors persist, upstream service may be overloaded—retry with exponential backoff
🤖 MCP tools not showing in Claude/Cursor
- Restart Claude Desktop completely (not just close window)
- Verify
dist/mcpServer.jsexists—runnpm run mcp:build - Check absolute path in config—no
~or relative paths - Ensure
ANRAKLEGAL_KEYenv var is set correctly - Check Claude logs:
~/Library/Logs/Claude/mcp*.log
📊 Usage stats not updating
- Usage updates in real-time but may take 1-2 seconds to reflect
- Cached requests still count toward usage
- Verify requests are successful (200 status) in /usage dashboard
- Failed requests (401, 404, 500) are logged but don't increment your quota
Enterprise & Support
Need higher rate limits, custom SLAs, audit logging, or white-label deployment? Email us at support@anraklegal.com or open an issue on GitHub.