Dump DOM
Capture HTML, inspect rendered output, and reuse DOM snapshots.
POST /v1/dom/dump
Use this endpoint when you need the captured HTML itself, want to inspect rendering output, or want to reuse a DOM snapshot in a later extraction request.
Authentication
- External requests must include both
X-API-KeyandX-Project-Id - Create or copy them from API key settings on the current site
- Use
https://api.lexmount.comfor COM projects andhttps://api.lexmount.cnfor CN projects; credentials must match the API region
Request Body
{
"url": "https://example.com",
"options": {
"engine_preference": "lightmount_dcl",
"timeout_ms": 30000,
"filter_scripts_styles": false
}
}Fields
| Field | Type | Required | Description |
|---|---|---|---|
url | string | Yes | Target page URL |
options.engine_preference | string | No | Preferred engine, default auto |
options.timeout_ms | int | No | Positive timeout in milliseconds; cannot extend the public gateway deadline |
options.user_agent | string | No | Custom fetch User-Agent |
options.filter_scripts_styles | bool | No | Remove script and style before returning and saving the dump |
Supported engine_preference values:
autohttpchromechrome_cdplightmount_litelightmount_dcllightmount_domstable
Engine Behavior
auto uses a matching service-side site-engine rule; without a match it currently selects lightmount_dcl. It does not guarantee HTTP first or a sequence through every browser. Choose an explicit engine when you need a fixed selection, and inspect the returned engine.
| Engine | Behavior |
|---|---|
http | Fetch HTML directly without running page JavaScript |
chrome / chrome_cdp | Chrome fetch paths |
lightmount_lite | Lightweight fetch path |
lightmount_dcl | LightMount, waiting for DOMContentLoaded |
lightmount_domstable | LightMount, waiting for DOM stability |
Compatibility varies by engine. DOMContentLoaded or DOM stability does not guarantee that every asynchronously loaded section is present. Dump DOM fetches url; use the extraction endpoint to reuse a snapshot.
Basic Example
API_KEY='<your-api-key>'
PROJECT_ID='<your-project-id>'
curl -sS -X POST https://api.lexmount.cn/v1/dom/dump \
-H 'Content-Type: application/json' \
-H "X-API-Key: $API_KEY" \
-H "X-Project-Id: $PROJECT_ID" \
-d '{
"url": "https://example.com",
"options": {
"engine_preference": "lightmount_dcl",
"timeout_ms": 30000
}
}' \
| jq '{final_url, engine, dom_id, html_len:(.html|length)}'Response Fields
Common response fields:
request_idurlfinal_urlstatus_codefetched_atenginedom_idhtmldebug
request_id is the request correlation ID. The same value is also returned in the X-Request-ID response header.
Filter script / style
curl -sS -X POST https://api.lexmount.cn/v1/dom/dump \
-H 'Content-Type: application/json' \
-H "X-API-Key: $API_KEY" \
-H "X-Project-Id: $PROJECT_ID" \
-d '{
"url": "https://example.com",
"options": {
"engine_preference": "lightmount_dcl",
"filter_scripts_styles": true
}
}' \
| jq '{dom_id, has_script:(.html|test("<script"; "i")), has_style:(.html|test("<style"; "i"))}'Use this mode when you want a cleaner DOM for inspection or template work. Do not treat it as an exact browser snapshot.
Reuse dom_id
Capture a snapshot first, then pass dom_id into /v1/extract:
set -euo pipefail
DOM_ID="$(curl --fail-with-body -sS -X POST https://api.lexmount.cn/v1/dom/dump \
-H 'Content-Type: application/json' \
-H "X-API-Key: $API_KEY" \
-H "X-Project-Id: $PROJECT_ID" \
-d '{"url":"https://example.com","options":{"engine_preference":"lightmount_dcl"}}' \
| jq -er '.dom_id | select(type == "string" and length > 0)')"
curl -sS -X POST https://api.lexmount.cn/v1/extract \
-H 'Content-Type: application/json' \
-H "X-API-Key: $API_KEY" \
-H "X-Project-Id: $PROJECT_ID" \
-d "{\"extract\":{\"dom_id\":\"$DOM_ID\"}}" \
| jq '{title:.result.title, engine:.result.engine, dom_id:.metadata.dom_id}'For troubleshooting, see Common Errors.
Snapshot Reuse and Response Checks
dom_id is a returned string identifier, such as "123"; preserve it exactly. An example ID is not a reusable real snapshot. Continue using the regional endpoint that captured it. A snapshot is not a cross-region browser Context, and no fixed retention period is guaranteed publicly. If dom_snapshot_not_found occurs, fetch the URL again. Store required content in your application for long-term retention.
HTTP 200 from Dump DOM means the capture completed; the target page may still have returned 403 or 404. Check top-level status_code, final_url, and html as well. Handle empty HTML and absent debug. When filtering is enabled, the saved snapshot also contains the cleaned HTML.
In production, check HTTP status and dom_id before sending the reuse request; do not send null as an ID after a failed dump. Both successful calls count toward Web Fetch usage.
