Documentation Index
Fetch the complete documentation index at: https://docs.datris.ai/llms.txt
Use this file to discover all available pages before exploring further.
The Query API provides REST endpoints for querying PostgreSQL and MongoDB databases, plus natural language queries and AI-powered answers. These endpoints mirror the MCP tools, making the same retrieval capabilities available via HTTP.
Query PostgreSQL
Execute a read-only SQL SELECT query against PostgreSQL.
POST /api/v1/query/postgres
Request
| Field | Type | Required | Default | Description |
|---|
sql | string | Yes | | SQL SELECT query to execute |
database | string | No | datris | PostgreSQL database name to connect to |
limit | integer | No | 100 | Maximum rows to return. Pass -1 for unlimited (tap scripts use this to read every row). Omit for the preview default of 100; any positive value is honored with no cap. |
Example
curl -X POST http://localhost:8080/api/v1/query/postgres \
-H "Content-Type: application/json" \
-d '{
"sql": "SELECT symbol, date, close FROM test.stock_price WHERE volume > 1000000",
"database": "datris",
"limit": 10
}'
Response
{
"results": [
{
"symbol": "AAPL",
"date": "2024-01-15",
"close": 185.92
}
],
"count": 1
}
Safety
The endpoint enforces multiple layers of protection:
- SELECT-only — only queries starting with
SELECT are allowed
- Read-only connection — the JDBC connection is set to read-only mode
- Statement blocklist — queries containing
INSERT, UPDATE, DELETE, DROP, ALTER, CREATE, TRUNCATE, GRANT, REVOKE, COPY, CALL, EXECUTE, or EXEC are rejected
- No stacked queries — semicolons are not allowed
- No SQL comments —
-- and /* */ are rejected to prevent obfuscation
- LIMIT enforcement — if no
LIMIT is present in the SQL, one is appended automatically using the request’s limit value (or the default 100). Pass limit: -1 to bypass the automatic append entirely — the caller’s SQL runs as-is.
Query MongoDB
Query a MongoDB collection with optional filter and projection.
POST /api/v1/query/mongodb
Request
| Field | Type | Required | Default | Description |
|---|
collection | string | Yes | | MongoDB collection name |
filter | object | No | {} | MongoDB query filter |
projection | object | No | all fields | Fields to include/exclude |
limit | integer | No | 20 | Maximum documents to return. Pass -1 for unlimited (tap scripts use this to read every document). Omit for the preview default of 20; any positive value is honored with no cap. |
Example
curl -X POST http://localhost:8080/api/v1/query/mongodb \
-H "Content-Type: application/json" \
-d '{
"collection": "orders",
"filter": {"status": "active"},
"projection": {"name": 1, "_id": 0},
"limit": 10
}'
Response
{
"results": [
{
"name": "Order-001"
}
],
"count": 1
}
Safety
- Blocked operators — filters containing
$where, $function, or $accumulator are rejected, as these allow arbitrary JavaScript execution
- Standard MongoDB query operators (
$eq, $gt, $in, $regex, etc.) are safe and fully supported
Kill Job
Kill a running pipeline job by its pipeline token. The job thread is interrupted and the job is marked as cancelled.
Request
| Field | Type | Required | Description |
|---|
pipelineToken | string | Yes | Pipeline token of the running job to kill |
Example
curl -X POST http://localhost:8080/api/v1/job/kill \
-H "Content-Type: application/json" \
-d '{
"pipelineToken": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
}'
Response
{
"status": "cancelled",
"pipelineToken": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
}
Error Cases
- Job not found for the given pipeline token
- Job is not in
PROCESSING state (already completed or cancelled)
- Job thread is no longer alive