{
  "x402Version": 2,
  "service": "sheet-sql",
  "title": "Sheet SQL & Multi-Tab XLSX Engine API",
  "version": "1.0.0",
  "mcpEndpoint": "https://sheet-sql.apikeg.com/mcp",
  "freeDiscovery": [
    "https://sheet-sql.apikeg.com/llms.txt",
    "https://sheet-sql.apikeg.com/llms-full.txt",
    "https://sheet-sql.apikeg.com/openapi.json",
    "https://sheet-sql.apikeg.com/.well-known/mcp.json",
    "https://sheet-sql.apikeg.com/.well-known/api-catalog"
  ],
  "resources": [
    {
      "name": "query_tabular_data",
      "title": "Query CSV & JSON Tables with SQLite",
      "url": "https://sheet-sql.apikeg.com/v1/query-tabular-data",
      "method": "POST",
      "description": "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 call instead of 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). Pass ?dry_run=true on REST to validate schema free.",
      "accepts": [
        {
          "scheme": "upto",
          "network": "eip155:8453",
          "amount": "10000",
          "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
          "payTo": "0x000000000000000000000000000000000000dEaD",
          "maxTimeoutSeconds": 60,
          "extra": {
            "priceUsd": "0.002",
            "maxPriceUsd": "0.01",
            "unitDescription": "$0.002 base + $0.001 per 1,000 total input rows (capped at $0.01)",
            "dryRunQueryParam": "?dry_run=true"
          }
        }
      ],
      "extensions": {
        "bazaar": {
          "discoverable": true,
          "category": [
            "data-analytics",
            "spreadsheets",
            "business-ops",
            "developer-tools"
          ],
          "info": {
            "input": {
              "type": "http",
              "method": "POST",
              "bodyType": "json",
              "example": {
                "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"
              }
            },
            "output": {
              "type": "json",
              "summary": "Returns typed rows (Acme Corp total_spend=2000, spend_rank=1), GFM markdownPreview, inferredSchemas showing amount coerced to REAL, and base64 .xlsx."
            }
          },
          "schema": {
            "inputSchema": {
              "type": "object",
              "properties": {
                "tables": {
                  "type": "object",
                  "additionalProperties": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 3800000,
                    "description": "Raw RFC 4180 CSV/TSV string (auto-detecting ',', ';', or '\\t') or serialized JSON row-array string."
                  },
                  "description": "Map of 1 to 10 SQL table names (e.g. 'orders', 'customers') to CSV/TSV or JSON row-array payloads."
                },
                "sql": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 32768,
                  "description": "Read-only SQLite SELECT or WITH (CTE) query supporting JOIN, GROUP BY, HAVING, and window functions (ROW_NUMBER() OVER (...), SUM, AVG)."
                },
                "coerceCurrencyNumbers": {
                  "type": "boolean",
                  "default": true,
                  "description": "Automatically strip $, €, £, ¥ symbols, thousands commas, and accounting parentheses (e.g. '$1,250.50' -> 1250.5) when an entire column is numeric."
                },
                "maxRows": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 5000,
                  "default": 1000,
                  "description": "Maximum result rows returned in `rows` (1–5000, default 1000)."
                },
                "markdownPreviewRows": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 100,
                  "default": 20,
                  "description": "Maximum rows rendered in `markdownPreview` (1–100, default 20)."
                },
                "exportXlsx": {
                  "type": "boolean",
                  "default": false,
                  "description": "When true, also exports the query result set as a styled OpenXML .xlsx workbook in `xlsxBase64`."
                },
                "xlsxSheetName": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 64,
                  "description": "Optional worksheet tab name when `exportXlsx` is true (default 'Query Results')."
                },
                "xlsxSummaryRowFormulas": {
                  "type": "object",
                  "additionalProperties": {
                    "type": "string",
                    "enum": [
                      "SUM",
                      "AVERAGE",
                      "MIN",
                      "MAX",
                      "COUNT",
                      "COUNTA"
                    ],
                    "description": "Spreadsheet summary aggregation function (SUM, AVERAGE, MIN, MAX, COUNT, COUNTA)."
                  },
                  "description": "Optional summary row formulas keyed by output column name when `exportXlsx` is true (e.g. { total_revenue: 'SUM' })."
                }
              },
              "required": [
                "tables",
                "sql"
              ],
              "additionalProperties": false
            },
            "outputSchema": {
              "type": "object",
              "required": [
                "ok",
                "data",
                "_meta"
              ],
              "properties": {
                "ok": {
                  "type": "boolean",
                  "const": true
                },
                "data": {
                  "type": "object",
                  "description": "Deterministic structured tool result payload."
                },
                "_meta": {
                  "type": "object",
                  "required": [
                    "requestId",
                    "durationMs",
                    "chargedUsd",
                    "dryRun"
                  ],
                  "properties": {
                    "requestId": {
                      "type": "string"
                    },
                    "durationMs": {
                      "type": "number"
                    },
                    "chargedUsd": {
                      "type": "string"
                    },
                    "dryRun": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    {
      "name": "build_xlsx_workbook",
      "title": "Build Styled Multi-Sheet XLSX Workbook",
      "url": "https://sheet-sql.apikeg.com/v1/build-xlsx-workbook",
      "method": "POST",
      "description": "Compiles 1–20 structured JSON datasets into a genuine Office Open XML (.xlsx) workbook with bold shaded headers, frozen top rows, auto-sized columns, numeric formatting, formula-injection protection, and live Excel summary formulas (SUM, AVERAGE, MIN, MAX, COUNT). Why call instead of DIY: Generates compliant PKZIP/OpenXML spreadsheets at the edge in <15ms without Python, openpyxl, SheetJS bloat, or broken CSV exports. Pricing: $0.003 USD per multi-sheet .xlsx workbook generation (x402 instant micropayment). Pass ?dry_run=true on REST to validate schema free.",
      "accepts": [
        {
          "scheme": "exact",
          "network": "eip155:8453",
          "amount": "3000",
          "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
          "payTo": "0x000000000000000000000000000000000000dEaD",
          "maxTimeoutSeconds": 60,
          "extra": {
            "priceUsd": "0.003",
            "unitDescription": "per multi-sheet .xlsx workbook generation",
            "dryRunQueryParam": "?dry_run=true"
          }
        }
      ],
      "extensions": {
        "bazaar": {
          "discoverable": true,
          "category": [
            "data-analytics",
            "spreadsheets",
            "business-ops",
            "developer-tools"
          ],
          "info": {
            "input": {
              "type": "http",
              "method": "POST",
              "bodyType": "json",
              "example": {
                "fileName": "q4-revenue-summary.xlsx",
                "sheets": [
                  {
                    "name": "Regional Revenue",
                    "freezeHeader": true,
                    "coerceCurrencyNumbers": true,
                    "allowCellFormulas": false,
                    "summaryRowFormulas": {
                      "q4_revenue": "SUM",
                      "win_rate": "AVERAGE"
                    },
                    "rows": [
                      {
                        "region": "North America",
                        "q4_revenue": 125000.5,
                        "win_rate": 0.34
                      },
                      {
                        "region": "Europe",
                        "q4_revenue": 84500.25,
                        "win_rate": 0.29
                      }
                    ]
                  }
                ]
              }
            },
            "output": {
              "type": "json",
              "summary": "Returns base64-encoded OpenXML .xlsx archive with frozen headers, auto-sized columns, numeric formatting, and =SUM(B2:B3) / =AVERAGE(C2:C3) summary row."
            }
          },
          "schema": {
            "inputSchema": {
              "type": "object",
              "properties": {
                "fileName": {
                  "type": "string",
                  "default": "workbook.xlsx",
                  "minLength": 1,
                  "maxLength": 128,
                  "description": "Output .xlsx filename metadata (automatically suffixed with .xlsx if omitted)."
                },
                "sheets": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "name": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 64,
                        "description": "Worksheet tab name (sanitized and capped at Excel's 31-character limit)."
                      },
                      "columns": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 128
                        },
                        "minItems": 1,
                        "maxItems": 200,
                        "description": "Optional explicit column order. If omitted, column keys are inferred from `rows` in insertion order."
                      },
                      "headers": {
                        "type": "object",
                        "additionalProperties": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 128
                        },
                        "description": "Optional human-friendly header display labels keyed by column name (e.g. { mrr_usd: 'MRR (USD)' })."
                      },
                      "rows": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {},
                          "additionalProperties": true,
                          "description": "Row object mapping column names to typed cell values (number, string, boolean, or null)."
                        },
                        "minItems": 0,
                        "maxItems": 10000,
                        "description": "Structured JSON rows to populate on this worksheet."
                      },
                      "freezeHeader": {
                        "type": "boolean",
                        "default": true,
                        "description": "Freeze top header row (`<pane ySplit=\"1\" state=\"frozen\"/>`)."
                      },
                      "coerceCurrencyNumbers": {
                        "type": "boolean",
                        "default": false,
                        "description": "Coerce currency-formatted string cells (e.g. '$1,250.50') into typed numeric Excel cells."
                      },
                      "allowCellFormulas": {
                        "type": "boolean",
                        "default": false,
                        "description": "When true, string cells starting with '=' (e.g. '=B2*C2') emit native OpenXML <f> formulas; when false, they stay literal strings to prevent formula injection."
                      },
                      "summaryRowFormulas": {
                        "type": "object",
                        "additionalProperties": {
                          "type": "string",
                          "enum": [
                            "SUM",
                            "AVERAGE",
                            "MIN",
                            "MAX",
                            "COUNT",
                            "COUNTA"
                          ],
                          "description": "Spreadsheet summary aggregation function (SUM, AVERAGE, MIN, MAX, COUNT, COUNTA)."
                        },
                        "description": "Optional summary row formulas keyed by column name (e.g. { revenue: 'SUM', deal_size: 'AVERAGE' })."
                      },
                      "summaryRowLabel": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 64,
                        "description": "Optional label placed in column A of the summary row (default 'Total')."
                      }
                    },
                    "required": [
                      "name",
                      "rows"
                    ],
                    "additionalProperties": false,
                    "description": "Worksheet definition for an OpenXML .xlsx workbook."
                  },
                  "minItems": 1,
                  "maxItems": 20,
                  "description": "1 to 20 worksheets to compile into the multi-tab .xlsx archive."
                }
              },
              "required": [
                "sheets"
              ],
              "additionalProperties": false
            },
            "outputSchema": {
              "type": "object",
              "required": [
                "ok",
                "data",
                "_meta"
              ],
              "properties": {
                "ok": {
                  "type": "boolean",
                  "const": true
                },
                "data": {
                  "type": "object",
                  "description": "Deterministic structured tool result payload."
                },
                "_meta": {
                  "type": "object",
                  "required": [
                    "requestId",
                    "durationMs",
                    "chargedUsd",
                    "dryRun"
                  ],
                  "properties": {
                    "requestId": {
                      "type": "string"
                    },
                    "durationMs": {
                      "type": "number"
                    },
                    "chargedUsd": {
                      "type": "string"
                    },
                    "dryRun": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  ]
}