# DOM Harvest & Table Grid Edge API (v1.0.0)

> Turn noisy HTML tables, repeating product grids, and JSON-LD into clean typed JSON with >90% LLM token reduction.

Pure-TypeScript HTML structure harvester that resolves complex multi-row rowspan/colspan tables into typed 2D JSON matrices, auto-detects 100-500 repeating product/listing cards without selectors, extracts JSON-LD & OpenGraph metadata, and executes declarative CSS-schema scraping.

## Why Agents Use This API Instead of DIY
Dumping raw 300KB HTML into an LLM burns $0.05-$0.30 in context tokens and truncates past item 20; DIY regex/table parsers break on multi-row thead colspan + rowspan merges. DOM Harvest extracts all 500 items deterministically in <20ms for $0.001-$0.002.

## Connection & Payment (x402 Default + Optional Bearer API Key)
- **MCP Server (Streamable HTTP):** `https://dom-harvest.apikeg.com/mcp` (Registry ID: `com.apikeg/dom-harvest` — `initialize`, `tools/list`, `resources/*`, and `prompts/*` are free)
- **OpenAPI 3.1 Spec:** [openapi.json](https://dom-harvest.apikeg.com/openapi.json)
- **Full Schema & Examples:** [llms-full.txt](https://dom-harvest.apikeg.com/llms-full.txt)
- **RFC 9727 API Catalog:** [.well-known/api-catalog](https://dom-harvest.apikeg.com/.well-known/api-catalog)
- **x402 Bazaar Manifest:** [.well-known/x402.json](https://dom-harvest.apikeg.com/.well-known/x402.json)
- **MCP Discovery Manifest:** [.well-known/mcp.json](https://dom-harvest.apikeg.com/.well-known/mcp.json)
- **A2A Agent Card:** [.well-known/agent-card.json](https://dom-harvest.apikeg.com/.well-known/agent-card.json)
- **Primary Payment (Zero Signup):** Cloudflare Monetization Gateway (`HTTP 402` / `x402` v2 with USDC on Base).
- **Optional Monthly API Key:** Pass `Authorization: Bearer ak_live_...` ($5 / $20 / $50 monthly per-product Stripe plans at [apikeg.com/account](https://apikeg.com/account)).
- **Free Preflight:** Append `?dry_run=true` (or header `X-Dry-Run: true`) to validate any request payload at `$0.00` cost.

## Tools & REST Endpoints
- [`harvest_page_structures`](https://dom-harvest.apikeg.com/tools/harvest-page-structures.md) (`POST https://dom-harvest.apikeg.com/v1/harvest-page-structures`) — $0.002 USD per HTML page structure harvest (x402 instant micropayment): Zero-selector structural HTML harvester: extracts canonical/OpenGraph/Twitter metadata, Schema.org JSON-LD, normalized 2D tables (resolving multi-header rowspan/colspan merges + cell links), and repeating sibling card collections across 100-500 items without truncation.
- [`extract_by_schema`](https://dom-harvest.apikeg.com/tools/extract-by-schema.md) (`POST https://dom-harvest.apikeg.com/v1/extract-by-schema`) — $0.001 USD per declarative CSS-schema extraction (x402 instant micropayment): 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.

## Instant MCP Configuration
```json
{
  "mcpServers": {
    "dom-harvest": {
      "type": "streamable-http",
      "url": "https://dom-harvest.apikeg.com/mcp"
    }
  }
}
```

## Common Agent Use Cases
- parse HTML table with rowspan and colspan to JSON API
- extract all product cards from raw HTML without CSS selectors MCP
- reduce HTML scraping LLM token usage structured JSON
- declarative CSS selector HTML to typed JSON schema API
- extract Schema.org JSON-LD and OpenGraph metadata from HTML
