Overview
Allows administrators to run SELECT queries against the RaidHub database or explain query execution plans. Includes automatic cost analysis to prevent expensive queries from running.Endpoint
Authentication
Requires admin JWT token obtained from/authorize/admin.
Request Body
The SQL query to execute. Must be a SELECT statement.
Type of query execution. One of:
SELECT: Execute the query and return resultsEXPLAIN: Return the query execution plan without executing
Skip cost analysis and execute the query regardless of estimated cost. Use with caution.
Response
The response structure varies based on the query type and cost:SELECT Response (Low Cost)
SELECTArray of result rows (limited to 50 rows). Each row is an object with column names as keys.
SELECT Response (High Cost)
Returned when estimated query cost exceeds 1,000,000 andignoreCost is false:
HIGH COSTAlways null for high cost queries
Estimated query cost from PostgreSQL query planner
Estimated query duration in seconds
EXPLAIN Response
EXPLAINArray of query plan lines as strings
Example Requests
Execute a Query
Explain Query Execution
Example Responses
Successful SELECT
High Cost Warning
Explain Plan
Error Responses
Admin Query Syntax Error - Invalid SQL syntax or database error
Insufficient Permissions - Not authorized as admin
Safety Features
- Result Limit: All queries are automatically wrapped to limit results to 50 rows
- Cost Analysis: Queries with estimated cost > 1,000,000 require
ignoreCost: true - Read-Only: Only SELECT and EXPLAIN queries are supported
- Semicolon Stripping: Trailing semicolons are removed to prevent injection
Caching
This endpoint is cached for 5 seconds.Use Cases
- Debug data issues
- Analyze query performance
- Extract custom reports
- Investigate leaderboard calculations