Logo of Lexmount
DocsTemplatesBlogHelp Center
GitHub
Logo of LexmountLexmount Browser

Get started

Lexmount Documentation
Console guide

Browser

Web Fetch

OverviewQuick Start
All-in-One ExtractDump DOM
Common Errors

Web Search

OverviewQuick StartSearch API

Runtime

OverviewQuickstartCapabilitiesExamples

Help and billing

Capability FAQ
ChangelogContact support
API reference

All-in-One Extract

Full request and response reference for POST /v1/extract.

POST /v1/extract

Use this endpoint when you want a single request to fetch a page and return structured output.

Authentication

  • External requests must include both X-API-Key and X-Project-Id
  • Create or copy them from API key settings on the current site
  • Use https://api.lexmount.com for COM projects and https://api.lexmount.cn for CN projects; credentials must match the API region

Request Body

{
  "extract": {
    "url": "https://example.com"
  }
}

Fields

FieldTypeRequiredDescription
extractobjectYesMain extraction request
extract.urlstringNoTarget page URL
extract.dom_idstringNoExisting DOM snapshot ID
trace.include_stepsboolNoReturn workflow steps when set to true
trace.include_raw_domboolNoReturn raw DOM when set to true

Rules:

  • At least one of extract.url or extract.dom_id is required
  • Set trace.include_steps=true when you need workflow diagnostics

Extraction Options

FieldTypeDescription
extract.options.engine_preferencestringDefaults to auto; see Dump DOM for engine values
extract.options.user_agentstringOptional fetch User-Agent
{
  "extract": {
    "url": "https://example.com",
    "options": {
      "engine_preference": "chrome_cdp",
      "user_agent": "MyFetcher/1.0"
    }
  },
  "trace": { "include_steps": true }
}

When extract.dom_id is present, extraction reuses the snapshot instead of fetching the URL. Prefer sending only the returned dom_id rather than an unrelated URL. Changing the engine cannot re-render an existing snapshot; fetch the URL again for that.

/v1/extract currently uses a service-controlled 30-second extraction deadline. extract.options.timeout_ms does not override it, and the legacy workflow field does not configure it. The public gateway has its own timeout. Script/style filtering belongs to Dump DOM, not to an extraction output switch. template_id is no longer supported; templates are matched automatically. Do not rely on internal template-debug or force-generation fields. Unknown JSON fields are rejected.

Minimal Example

API_KEY='<your-api-key>'
PROJECT_ID='<your-project-id>'

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":{"url":"https://example.com"}}'

Response Shape

Top-level response fields:

FieldDescription
request_idRequest correlation ID. Also returned in the X-Request-ID response header
resultStructured extraction result on success
metadataExtra metadata such as dom_id and server_elapsed_ms
errorError object on failure
traceWorkflow trace steps; returned only when include_steps=true
raw_domRaw DOM content; returned only when include_raw_dom=true

Use request_id when you need to report a problem or correlate a client-side response with server-side request logs.

Common fields inside result:

  • url
  • final_url
  • status_code
  • title
  • description
  • main_text
  • publish_time
  • author
  • language
  • links
  • images
  • engine
  • dom_id

Reuse an Existing dom_id

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": "123"
    }
  }'

Enable Trace

By default, POST /v1/extract does not return trace.

To inspect workflow diagnostics, explicitly enable it:

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": {
      "url": "https://example.com"
    },
    "trace": {
      "include_steps": true
    }
  }'

Return Raw DOM

By default, raw_dom is not returned.

Enable it only when you actually need the captured DOM in the response:

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": {
      "url": "https://example.com"
    },
    "trace": {
      "include_raw_dom": true
    }
  }'
  • raw_dom can be very large and is not recommended for normal production calls

Debug Mode

Turn on both debug fields only when you need to inspect the workflow and the captured page:

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": {
      "url": "https://example.com"
    },
    "trace": {
      "include_steps": true,
      "include_raw_dom": true
    }
  }'
  • trace makes responses larger
  • raw_dom can be very large and is not recommended for normal production calls

For common failures, see Common Errors.

Field Types and Optional Output

  • result.status_code is the target page's status, not the API response's HTTP status.
  • result.fetched_at is a timestamp string; publish_time, when present, is also a timestamp string.
  • A links entry is { "text": "Example", "href": "https://example.com/" }; an images entry is { "src": "https://example.com/image.png", "alt": "Example" }.
  • description, main_text, author, publish_time, language, links, images, debug, and extra may be omitted. Handle absent arrays before iterating them.
  • extra may contain Open Graph, JSON-LD, or DOM summaries; its content varies by page and extraction method.
  • metadata may contain dom_id, an opaque template_id, and server_elapsed_ms. The template identifier is not a supported input option.
  • Even when requested, raw_dom may be omitted if no snapshot content is available. Individual trace steps also vary with the processing path.

See Dump DOM for snapshot reuse and recovery.

Quick Start

Send your first Web Fetch request and understand the default response behavior.

Dump DOM

Capture HTML, inspect rendered output, and reuse DOM snapshots.

Table of Contents

Authentication
Request Body
Fields
Extraction Options
Minimal Example
Response Shape
Reuse an Existing dom_id
Enable Trace
Return Raw DOM
Debug Mode
Field Types and Optional Output

Still need help?