query_tabular_data — Query CSV & JSON Tables with SQLite

Ingests 1–10 named RFC 4180 CSV/TSV or JSON row-array datasets into an ephemeral zero-retention SQLite sandbox, coerces currency columns (e.g. '$1,250.50' -> 1250.5), runs read-only SQL (JOIN, GROUP BY, CTEs, window functions), and returns typed rows, Markdown preview, inferred schemas, and optional .xlsx export.

Why buy vs. DIY: Replaces fragile regex CSV parsers, LLM mental math errors, and heavy container sandboxes; runs real SQLite in <25ms with guaranteed ephemeral wipe.

Pricing: $0.002 base (up to $0.01 max $0.002 base + $0.001 per 1,000 total input rows (capped at $0.01), x402 variable settlement) · REST: POST https://sheet-sql.apikeg.com/v1/query-tabular-data · MCP: https://sheet-sql.apikeg.com/mcp

Input Parameters

FieldTypeRequired / DefaultDescription & Constraints
tables object Required Map of 1 to 10 SQL table names (e.g. 'orders', 'customers') to CSV/TSV or JSON row-array payloads.
sql string Required Read-only SQLite SELECT or WITH (CTE) query supporting JOIN, GROUP BY, HAVING, and window functions (ROW_NUMBER() OVER (...), SUM, AVG). (minLength: 1, maxLength: 32768)
coerceCurrencyNumbers boolean Default: true Automatically strip $, €, £, ¥ symbols, thousands commas, and accounting parentheses (e.g. '$1,250.50' -> 1250.5) when an entire column is numeric.
maxRows integer Default: 1000 Maximum result rows returned in `rows` (1–5000, default 1000). (min: 1, max: 5000)
markdownPreviewRows integer Default: 20 Maximum rows rendered in `markdownPreview` (1–100, default 20). (min: 1, max: 100)
exportXlsx boolean Default: false When true, also exports the query result set as a styled OpenXML .xlsx workbook in `xlsxBase64`.
xlsxSheetName string Optional Optional worksheet tab name when `exportXlsx` is true (default 'Query Results'). (minLength: 1, maxLength: 64)
xlsxSummaryRowFormulas object Optional Optional summary row formulas keyed by output column name when `exportXlsx` is true (e.g. { total_revenue: 'SUM' }).

REST Example (curl)

curl -X POST "https://sheet-sql.apikeg.com/v1/query-tabular-data" \
  -H "Content-Type: application/json" \
  -d '{
  "coerceCurrencyNumbers": true,
  "maxRows": 100,
  "markdownPreviewRows": 10,
  "exportXlsx": true,
  "tables": {
    "orders": "order_id,customer_id,amount\n101,c1,\"$1,250.50\"\n102,c1,\"$749.50\"\n103,c2,\"$500.00\"",
    "customers": "[{\"id\":\"c1\",\"name\":\"Acme Corp\",\"region\":\"US\"},{\"id\":\"c2\",\"name\":\"Globex\",\"region\":\"EU\"}]"
  },
  "sql": "SELECT c.name, c.region, SUM(o.amount) AS total_spend, ROW_NUMBER() OVER (ORDER BY SUM(o.amount) DESC) AS spend_rank FROM customers c LEFT JOIN orders o ON c.id = o.customer_id GROUP BY c.id, c.name, c.region ORDER BY total_spend DESC"
}'

MCP tools/call Payload

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "query_tabular_data",
    "arguments": {
      "coerceCurrencyNumbers": true,
      "maxRows": 100,
      "markdownPreviewRows": 10,
      "exportXlsx": true,
      "tables": {
        "orders": "order_id,customer_id,amount\n101,c1,\"$1,250.50\"\n102,c1,\"$749.50\"\n103,c2,\"$500.00\"",
        "customers": "[{\"id\":\"c1\",\"name\":\"Acme Corp\",\"region\":\"US\"},{\"id\":\"c2\",\"name\":\"Globex\",\"region\":\"EU\"}]"
      },
      "sql": "SELECT c.name, c.region, SUM(o.amount) AS total_spend, ROW_NUMBER() OVER (ORDER BY SUM(o.amount) DESC) AS spend_rank FROM customers c LEFT JOIN orders o ON c.id = o.customer_id GROUP BY c.id, c.name, c.region ORDER BY total_spend DESC"
    }
  }
}