# FastX402 HTML Heading Tree Extractor

> FastX402 HTML Heading Tree Extractor is a paid API for AI agents from fastx402.tools, paid per call via x402, $0.001/call, status unknown (last checked 2026-10-20).

Parses an HTML document or fragment and returns a nested tree of all heading elements (h1–h6) with their text, level, depth, id, and hierarchical children.

## Facts

- Endpoint: GET https://fastx402.tools/html-heading-tree?utm_source=zero.xyz
- Price: $0.001/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-20
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/fastx402-html-heading-tree-extractor-ad2202ec
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_-wujNYIUAbRWBTDGDet1r

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability fastx402-html-heading-tree-extractor-ad2202ec
```

Example prompt: Can you extract all the headings from this HTML and give them back to me as a nested tree? Here's the HTML: '<h1>Introduction</h1><h2>Background</h2><h3>History</h3><h2>Methods</h2><h1>Conclusion</h1>'

## When to prefer this

Choose this endpoint when you need a structured, hierarchical tree representation of headings from raw HTML — not just a flat list. It is ideal for generating tables of contents, building navigation menus, auditing document structure, or analyzing heading hierarchy. Prefer this over manual regex approaches when you need proper nesting with depth and id metadata. Pay-per-call with no account or API key required makes it ideal for one-off agent tasks.

## Known failure modes

- Missing or empty 'html' query parameter — API returns an error requiring the field
- HTML with no heading elements — returns an empty headings array
- Malformed HTML — parser may produce unexpected or empty tree depending on severity
- Very large HTML documents may time out or exceed request limits
- Non-UTF-8 encoded HTML may cause parsing errors

## How this service works

200 pay-per-call tools for AI agents, from $0.001 per request in USDC on Base or Solana with x402. No account, no API key.

## Output

Returns a JSON object containing a 'headings' array of nested heading nodes. Each node includes: 'text' (heading content), 'level' (h1=1 through h6=6), 'depth' (nesting depth starting at 0 for top-level), 'id' (the element's HTML id attribute if present), and 'children' (array of sub-heading nodes with the same structure). The tree mirrors the hierarchical document outline implied by the HTML heading tags.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "required": [
  "input"
 ],
 "properties": {
  "input": {
   "type": "object",
   "required": [
    "type",
    "method"
   ],
   "properties": {
    "type": {
     "type": "string",
     "const": "http"
    },
    "method": {
     "enum": [
      "GET"
     ],
     "type": "string"
    },
    "queryParams": {
     "type": "object",
     "required": [
      "html"
     ],
     "properties": {
      "html": {
       "type": "string",
       "description": "HTML document or fragment to extract headings from"
      }
     }
    }
   },
   "additionalProperties": false
  },
  "output": {
   "type": "object",
   "required": [
    "type"
   ],
   "properties": {
    "type": {
     "type": "string"
    },
    "example": {
     "type": "object",
     "properties": {
      "headings": {
       "type": "array",
       "items": {
        "type": "object",
        "properties": {
         "id": {
          "type": "string"
         },
         "text": {
          "type": "string"
         },
         "depth": {
          "type": "integer"
         },
         "level": {
          "type": "integer"
         },
         "children": {
          "type": "array",
          "items": {
           "type": "object",
           "properties": {
            "id": {
             "type": "string"
            },
            "text": {
             "type": "string"
            },
            "depth": {
             "type": "integer"
            },
            "level": {
             "type": "integer"
            },
            "children": {
             "type": "array",
             "items": {
              "type": "object",
              "properties": {
               "text": {
                "type": "string"
               },
               "depth": {
                "type": "integer"
               },
               "level": {
                "type": "integer"
               },
               "children": {
                "type": "array",
                "items": {}
               }
              }
             }
            }
           }
          }
         }
        }
       }
      }
     }
    }
   }
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "headings": [
   {
    "id": "intro",
    "text": "Introduction",
    "depth": 0,
    "level": 1,
    "children": [
     {
      "id": "bg",
      "text": "Background",
      "depth": 1,
      "level": 2,
      "children": [
       {
        "text": "History",
        "depth": 2,
        "level": 3,
        "children": []
       }
      ]
     },
     {
      "text": "Methods",
      "depth": 1,
      "level": 2,
      "children": []
     }
    ]
   },
   {
    "text": "Conclusion",
    "depth": 0,
    "level": 1,
    "children": []
   }
  ]
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/fastx402-html-heading-tree-extractor-ad2202ec/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from fastx402.tools](https://www.zero.xyz/host/fastx402.tools/llms.txt)
