Welcome to Nyay Setu API! This guide helps you get started with our 100+ API endpoints in minutes.
docker-compose up -d# Save token
TOKEN=$(curl -s -X POST http://localhost:8080/auth/login \
-H "Content-Type: application/json" \
-d '{"email":"test@example.com","password":"SecurePass123"}' | jq -r '.token')
echo "Token: $TOKEN"curl -X GET http://localhost:8080/cases \
-H "Authorization: Bearer $TOKEN"β Success! You're connected to the API.
| File | Purpose | Best For |
|---|---|---|
| openapi.yaml | Complete API specification | Swagger/OpenAPI tools |
| API_TESTING_GUIDE.md | Comprehensive testing guide | Learning to test APIs |
| API_ENDPOINTS_COMPREHENSIVE.md | Detailed endpoint documentation | Finding specific endpoints |
| API_QUICK_REFERENCE.md | Quick lookup by role | Quick answers |
| API_INTEGRATION_CHECKLIST.md | Integration checklist | Building features |
| Nyay_Setu_API_Collection.postman_collection.json | Postman collection | Interactive testing |
# Login
curl -X POST http://localhost:8080/auth/login \
-d '{"email":"user@example.com","password":"pass"}'
# Use token in requests
curl -H "Authorization: Bearer TOKEN" http://localhost:8080/cases# List cases
curl http://localhost:8080/cases -H "Authorization: Bearer $TOKEN"
# Create case
curl -X POST http://localhost:8080/cases \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"title":"Case Title","court":"District Court","caseType":"CIVIL"}'
# Get case
curl http://localhost:8080/cases/{caseId} -H "Authorization: Bearer $TOKEN"# Upload document
curl -X POST http://localhost:8080/documents/upload \
-H "Authorization: Bearer $TOKEN" \
-F "caseId={caseId}" \
-F "documentType=COMPLAINT" \
-F "file=@document.pdf"
# Analyze document (AI)
curl -X POST http://localhost:8080/documents/{documentId}/analyze \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"analysisType":"LEGAL_REVIEW"}'# Generate Affidavit
curl -X POST http://localhost:8000/lawgpt/generate \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"documentType":"AFFIDAVIT",
"caseId":"{caseId}",
"context":{"deponentName":"John","statements":["I own property"]},
"language":"EN"
}'# Analyze with legal reasoning (streaming)
curl -X POST http://localhost:8001/nlp/analyze \
-H "Authorization: Bearer $TOKEN" \
-H "Accept: text/event-stream" \
-d '{"caseId":"{caseId}","query":"What are legal implications?"}'- Open Postman
- Import
Nyay_Setu_API_Collection.postman_collection.json - Click "Login" request
- Click "Send"
- All endpoints ready to use
# See "Quick API Reference" aboveimport requests
# Login
response = requests.post('http://localhost:8080/auth/login',
json={'email':'user@example.com', 'password':'pass'})
token = response.json()['token']
# List cases
cases = requests.get('http://localhost:8080/cases',
headers={'Authorization': f'Bearer {token}'})
print(cases.json())// Login
const login = await fetch('http://localhost:8080/auth/login', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({email:'user@example.com', password:'pass'})
});
const {token} = await login.json();
// List cases
const cases = await fetch('http://localhost:8080/cases', {
headers: {'Authorization': `Bearer ${token}`}
});
console.log(await cases.json());ββ Backend (Port 8080) βββββββββββββββββββββ
β Cases, Documents, Evidence, Hearings, etc β
ββββββββββββββββββββββββββββββββββββββββββββ
ββ LawGPT (Port 8000) ββββββββββββββββββββββ
β AI Document Generation β
β (Affidavit, RTI, Complaint, etc) β
ββββββββββββββββββββββββββββββββββββββββββββ
ββ NLP Orchestrator (Port 8001) ββββββββββββ
β Legal Reasoning, Forensics, Modi OCR β
ββββββββββββββββββββββββββββββββββββββββββββ
ββ Signaling Server (Port 3001) ββββββββββββ
β WebRTC Communication β
ββββββββββββββββββββββββββββββββββββββββββββ
# 1. Login (get token first)
# 2. Create case
CASE=$(curl -X POST http://localhost:8080/cases \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"title":"Smith vs Johnson",
"court":"District Court",
"caseType":"CIVIL",
"parties":[
{"name":"John Smith","role":"PLAINTIFF"},
{"name":"Jane Johnson","role":"DEFENDANT"}
]
}')
CASE_ID=$(echo $CASE | jq '.id')
# 3. Upload document
curl -X POST http://localhost:8080/documents/upload \
-H "Authorization: Bearer $TOKEN" \
-F "caseId=$CASE_ID" \
-F "documentType=COMPLAINT" \
-F "file=@complaint.pdf"
# 4. Generate affidavit
curl -X POST http://localhost:8000/lawgpt/generate \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"documentType":"AFFIDAVIT",
"caseId":"'$CASE_ID'",
"context":{
"deponentName":"John Smith",
"statements":["I own the property"]
}
}'# For SSE streaming, pipe to line handler
curl -X POST http://localhost:8001/nlp/analyze \
-H "Authorization: Bearer $TOKEN" \
-H "Accept: text/event-stream" \
-d '{"caseId":"'$CASE_ID'","query":"Legal implications?"}' | grep -o 'data:.*'# Check all services
curl http://localhost:8080/actuator/health # Backend
curl http://localhost:8000/health # LawGPT
curl http://localhost:8001/health # NLP Orchestrator
# View all running services
docker-compose ps| Problem | Solution |
|---|---|
| 401 Unauthorized | Get new token: curl -X POST .../auth/login |
| Connection refused | Start services: docker-compose up -d |
| 404 Not found | Check endpoint path in documentation |
| CORS error | Use backend as proxy or check CORS config |
| Timeout | Check service logs: docker-compose logs -f [service] |
- Full Testing Guide β API_TESTING_GUIDE.md
- All Endpoints β API_ENDPOINTS_COMPREHENSIVE.md
- Quick Lookup β API_QUICK_REFERENCE.md
- OpenAPI Spec β openapi.yaml
- Integration Checklist β API_INTEGRATION_CHECKLIST.md
- Import Postman Collection - Easiest way to explore APIs
- Read API_TESTING_GUIDE.md - Learn comprehensive testing
- Try Sample Workflows - Create a case end-to-end
- Review Authentication - Understand JWT token flow
- Integrate in Code - Use Python/JavaScript examples
- Save token in environment variable:
export TOKEN="your-token" - Use
jqfor JSON formatting:curl ... | jq '.' - Check service logs for errors:
docker-compose logs [service] - Set base URL environment variable:
export BASE_URL="http://localhost:8080" - Copy exact commands from Postman for cURL equivalents
Q: How do I authenticate?
A: POST /auth/login with email/password to get JWT token, then use in Authorization: Bearer <token> header.
Q: Can I test without Postman? A: Yes! Use cURL, Python, JavaScript, or any HTTP client. See examples above.
Q: How long is token valid? A: Tokens expire in 24 hours. Use refresh token to get new token.
Q: What are streaming endpoints?
A: /nlp/analyze returns Server-Sent Events (SSE). Use Accept: text/event-stream header.
Q: How is evidence secured? A: Evidence is hashed with SHA-256 and stored on blockchain for immutability verification.
Q: Can I generate legal documents?
A: Yes! Use LawGPT service (/lawgpt/generate) for affidavits, RTI, complaints, etc.
Q: How do I upload files?
A: Use multipart form-data with /documents/upload endpoint (max 10MB).
- Issues? Check API_TESTING_GUIDE.md
- Stuck? Review API_QUICK_REFERENCE.md
- Questions? Create GitHub issue
- Help? Email: support@nyaysetu.in
Happy coding! π