diff_tables — Compare Two Structured CSV or JSON Tables by Primary Key

Compares two JSON object arrays or RFC 4180 CSV strings keyed by a single or composite primaryKey, returning exact summary counts, added rows, removed rows, and cell-level modified diffs with exact decimal numericDelta.

Why buy vs. DIY: Avoids row-order false positives in line-based diffs and floating-point drift on price/inventory catalogs; supports composite keys like ['sku', 'region'] in <10ms.

Pricing: $0.002 USD per structured table or catalog diff (x402 instant micropayment) · REST: POST https://doc-redline.apikeg.com/v1/diff-tables · MCP: https://doc-redline.apikeg.com/mcp

Input Parameters

FieldTypeRequired / DefaultDescription & Constraints
before any Required Table dataset passed either as a JSON array of row objects (e.g. [{"sku":"A1","region":"US","price":49.99}]) or an RFC 4180 CSV string with a header row.
after any Required Table dataset passed either as a JSON array of row objects (e.g. [{"sku":"A1","region":"US","price":49.99}]) or an RFC 4180 CSV string with a header row.
primaryKey any Required Single primary-key column name (e.g. "sku") or composite primary-key column list (e.g. ["sku", "region"]).
ignoreFields array Optional Optional column names (such as "updated_at" or "etag") to exclude from cell comparison. (maxItems: 64)
csvDelimiter string Default: "," Single-character column delimiter used when before or after is a CSV string (default ','). (minLength: 1, maxLength: 1)
coerceCsvTypes boolean Default: true Automatically parse unquoted numeric and boolean literals in CSV cells while preserving leading-zero identifiers.
numericTolerance number Default: 0 Optional non-negative tolerance; numeric cell differences with |delta| <= numericTolerance are treated as unchanged. (min: 0, max: 1000000)

REST Example (curl)

curl -X POST "https://doc-redline.apikeg.com/v1/diff-tables" \
  -H "Content-Type: application/json" \
  -d '{
  "primaryKey": [
    "sku",
    "region"
  ],
  "csvDelimiter": ",",
  "coerceCsvTypes": true,
  "numericTolerance": 0,
  "before": "sku,region,price,stock\nPRO-100,US,49.99,120\nPRO-100,EU,54.99,80\nLEGACY-1,US,19.00,10",
  "after": "sku,region,price,stock\nPRO-100,US,59.99,95\nPRO-100,EU,54.99,80\nNEW-200,US,99.00,250"
}'

MCP tools/call Payload

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "diff_tables",
    "arguments": {
      "primaryKey": [
        "sku",
        "region"
      ],
      "csvDelimiter": ",",
      "coerceCsvTypes": true,
      "numericTolerance": 0,
      "before": "sku,region,price,stock\nPRO-100,US,49.99,120\nPRO-100,EU,54.99,80\nLEGACY-1,US,19.00,10",
      "after": "sku,region,price,stock\nPRO-100,US,59.99,95\nPRO-100,EU,54.99,80\nNEW-200,US,99.00,250"
    }
  }
}