Enhancements for REST API Responses and Headers
Response Body Enhancements
Unique Identifier for Query Execution
- Include a
query_id
orexecution_id
for debugging and tracking specific requests.
- Include a
Performance Metrics
- Query Execution Time: Time taken to execute the SQL query (in ms or seconds).
- Data Processing Time: Time taken to process or transform data.
- Total Response Time: End-to-end time from request receipt to response generation.
Pagination Information
total_records
: Total number of records in the result set.page_size
: Number of records in the current response.current_page
: Current page number.total_pages
: Total number of pages.
Data Summary
- Row Count: Number of rows returned in the response.
- Aggregates: Optional aggregates like sums, averages, or counts.
Request Metadata
- Echo relevant parts of the request (e.g., query parameters, filters, sorting).
Error Details (if applicable)
1
2
3
4
5
6
7
8
9{
"errors": [
{
"code": "DB_TIMEOUT",
"message": "The database query timed out.",
"timestamp": "2025-01-26T12:34:56Z"
}
]
}Data Source Metadata
source_db
: Name of the database or schema.query_type
: Type of query executed (e.g., SELECT, UPDATE).rows_scanned
: Number of rows scanned to produce the result.
Response Headers Enhancements
Performance Metrics
X-Query-Execution-Time
: Time taken for the SQL query execution.X-Processing-Time
: Time taken to process the data.X-Total-Response-Time
: Total time for the request.
Rate Limiting
X-RateLimit-Limit
: Maximum number of requests allowed.X-RateLimit-Remaining
: Remaining requests in the current window.X-RateLimit-Reset
: Time when the rate limit resets.
Request ID
X-Request-ID
: Unique identifier for the request.
Cache Control
Cache-Control
: Specify cache duration or indicate no-cache.ETag
: Unique hash for cache validation.
Pagination
X-Total-Records
: Total records in the data set.X-Page-Size
: Number of records per page.X-Current-Page
: Current page number.X-Total-Pages
: Total number of pages.
Security
X-Content-Type-Options
:nosniff
to prevent MIME type sniffing.X-Frame-Options
:DENY
to prevent clickjacking.Content-Security-Policy
: Define secure data handling policies.
Custom Headers
X-Query-ID
: Unique query identifier.X-Data-Checksum
: Hash or checksum of the returned data for integrity verification.