REST API Reference¶
Interactive API documentation
Interactive Explorer¶
The API provides interactive documentation via Swagger UI and ReDoc:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
Authentication¶
All endpoints (except /api/health) require the X-API-Key header:
Public Endpoints¶
Query¶
POST /api/query
Submit a natural language query about Australian environmental regulations.
Request:
{
"query": "What are the emissions reporting thresholds under NGER?",
"lga_name": "City of Adelaide",
"state": "SA",
"max_sources": 5,
"min_confidence": 0.7,
"document_types": ["legislation", "guidelines"],
"max_tokens": 1000,
"include_metadata": true
}
Response:
{
"query": "What are the emissions reporting thresholds under NGER?",
"answer": "Under the NGER Act, facilities must report if...",
"sources": [
{
"title": "NGER Guidelines 2024",
"page_number": 15,
"section": "3.2.1",
"citation": "DCCEEW (2024), NGER Technical Guidelines, Page 15",
"confidence_score": 0.92,
"chunk_id": "abc123",
"document_type": "guidelines",
"jurisdiction": "Federal"
}
],
"trust_score": 0.88,
"response_time_ms": 1234.56,
"total_sources_found": 15,
"cache_hit": false
}
List Documents¶
GET /api/documents
List all available regulatory documents.
Query Parameters:
jurisdiction(optional): Filter by jurisdiction (Federal, NSW, VIC, etc.)document_type(optional): Filter by type (legislation, guidelines, etc.)skip(optional): Pagination offsetlimit(optional): Results per page (default: 100)
Response:
{
"documents": [
{
"id": "epbc-act-2024",
"title": "EPBC Act 1999",
"jurisdiction": "Federal",
"document_type": "legislation",
"last_updated": "2024-01-15",
"chunk_count": 1523
}
],
"total": 42,
"skip": 0,
"limit": 100
}
Analytics¶
GET /api/analytics
Get usage statistics and analytics.
Response:
{
"total_queries": 1523,
"avg_response_time_ms": 1234.56,
"cache_hit_rate": 0.65,
"top_queries": [
{"query": "emissions reporting", "count": 45}
],
"queries_by_lga": {
"City of Adelaide": 120
},
"avg_trust_score": 0.82
}
Health Check¶
GET /api/health
Check system health (no authentication required).
Response:
Admin Endpoints¶
All admin endpoints require admin-level API key.
System Health¶
GET /api/admin/system/health
Detailed system health metrics.
Cache Management¶
GET /api/admin/cache/metrics - Cache performance metrics
POST /api/admin/cache/clear - Clear cache
DELETE /api/admin/cache/{key} - Delete specific cache entry
Document Management¶
POST /api/admin/documents/reprocess - Reprocess all documents
DELETE /api/admin/documents/{document_id} - Delete document
Rate Limiting¶
Default rate limits:
- Public endpoints: 30 requests/minute
- Admin endpoints: 100 requests/minute
Rate limit headers:
Error Responses¶
400 Bad Request¶
401 Unauthorized¶
422 Validation Error¶
{
"detail": [
{
"loc": ["body", "query"],
"msg": "field required",
"type": "value_error.missing"
}
]
}
429 Too Many Requests¶
500 Internal Server Error¶
OpenAPI Specification¶
Download the full OpenAPI specification:
See Also¶
- Querying Guide - Detailed query examples
- Authentication - API key setup
- Rate Limiting - Configure limits