extract_by_schema — Extract Records by Declarative CSS Schema

Deterministic CSS-selector record extractor supporting descendant/child/attribute/group selectors, relative URL resolution against baseUrl, numeric currency/comma coercion, boolean flags, inner HTML serialization, and multi-value arrays.

Why buy vs. DIY: Eliminates brittle ad-hoc cheerio/regex glue code and runs identically at the Cloudflare edge in <10ms for $0.001.

Pricing: $0.001 USD per declarative CSS-schema extraction (x402 instant micropayment) · REST: POST https://dom-harvest.apikeg.com/v1/extract-by-schema · MCP: https://dom-harvest.apikeg.com/mcp

Input Parameters

FieldTypeRequired / DefaultDescription & Constraints
html string Required Raw HTML page or fragment. (minLength: 1, maxLength: 4000000)
baseUrl string Optional Optional page URL used to resolve relative URLs when field type is 'url'. (maxLength: 2048)
itemSelector string Required CSS selector matching each repeating record element (or 'body' / 'html' for single-object page extraction). (minLength: 1, maxLength: 512)
fields object Required Map of output property names to declarative CSS selector + type coercion rules.

REST Example (curl)

curl -X POST "https://dom-harvest.apikeg.com/v1/extract-by-schema" \
  -H "Content-Type: application/json" \
  -d '{
  "baseUrl": "https://store.example.com/deals/",
  "itemSelector": "article.product-card",
  "fields": {
    "sku": {
      "selector": ":scope",
      "attribute": "data-sku",
      "type": "string"
    },
    "title": {
      "selector": "h3.title",
      "type": "string"
    },
    "url": {
      "selector": "a.card-link",
      "attribute": "href",
      "type": "url"
    },
    "price": {
      "selector": ".price-current",
      "type": "number"
    },
    "inStock": {
      "selector": ".badge-in-stock",
      "type": "boolean"
    },
    "tags": {
      "selector": "ul.tags > li",
      "type": "string",
      "multiple": true
    }
  },
  "html": "<div class='grid'><article class='product-card' data-sku='SKU-9'><a class='card-link' href='../p/sku-9'><h3 class='title'>Pro Dock</h3></a><span class='price-current'>$189.99</span><span class='badge-in-stock'>In Stock</span><ul class='tags'><li>USB4</li><li>100W PD</li></ul></article></div>"
}'

MCP tools/call Payload

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "extract_by_schema",
    "arguments": {
      "baseUrl": "https://store.example.com/deals/",
      "itemSelector": "article.product-card",
      "fields": {
        "sku": {
          "selector": ":scope",
          "attribute": "data-sku",
          "type": "string"
        },
        "title": {
          "selector": "h3.title",
          "type": "string"
        },
        "url": {
          "selector": "a.card-link",
          "attribute": "href",
          "type": "url"
        },
        "price": {
          "selector": ".price-current",
          "type": "number"
        },
        "inStock": {
          "selector": ".badge-in-stock",
          "type": "boolean"
        },
        "tags": {
          "selector": "ul.tags > li",
          "type": "string",
          "multiple": true
        }
      },
      "html": "<div class='grid'><article class='product-card' data-sku='SKU-9'><a class='card-link' href='../p/sku-9'><h3 class='title'>Pro Dock</h3></a><span class='price-current'>$189.99</span><span class='badge-in-stock'>In Stock</span><ul class='tags'><li>USB4</li><li>100W PD</li></ul></article></div>"
    }
  }
}