Skip to main content
Extract specific fields from documents by providing a JSON schema. Marker parses the document and fills in your schema with extracted values. Before you begin, make sure you have:
  1. A Datalab account with an API key (new accounts include $5 in free credits)
  2. Python 3.10+ installed
  3. The Datalab SDK: pip install datalab-python-sdk
  4. Your DATALAB_API_KEY environment variable set
EU requests return a signed result_url; the REST examples below download it before reading the output. See Regional Result Downloads, including the Python SDK 0.5.0 limitation.
Building for production? Use Pipelines to chain processors, version your configuration, and deploy with a single API call.

Quick Start

Extraction Modes

The extraction_mode form parameter controls how extraction runs. This is separate from mode, which controls document parsing quality. Fast, balanced, and accurate modes return per-field citations. Balanced and accurate modes also return _meta fields with extraction_status, reasoning, and verification results. Turbo requires the source file and cannot reuse a checkpoint. These are base extraction rates. Parsing is billed separately when it runs, and complex balanced or accurate requests can incur usage-based charges. See Billing and pricing for your applicable rates. When mode is omitted from a REST request, balanced and accurate extraction use accurate parsing; fast uses fast parsing. An explicit mode overrides this choice. Turbo skips parsing.
balanced is the default. Teams that made an extraction request in the 30 days before June 4, 2026 default to fast instead. Pass extraction_mode explicitly to override the default in either case.
See Balanced and Accurate Extraction Modes for verification metadata and examples.

Schema Format

Use JSON Schema format to define what you want to extract:

Tips for Better Extraction

  1. Use descriptive field names - invoice_number is clearer than id
  2. Add descriptions - The description field helps the model understand context
  3. Specify types correctly - Use number for numeric values, string for text
  4. Use arrays for repeating data - Line items, table rows, etc.
Common schema pitfalls:
  • Using vague field names like data or info — be specific (e.g., invoice_number, total_amount)
  • Forgetting description fields — these help the model understand what to extract
  • Setting type: "string" for numeric values — use type: "number" for amounts, quantities, etc.
  • Deeply nested schemas — keep schemas as flat as possible for better extraction accuracy

Response

The extracted data is returned in extraction_schema_json:

Citation Tracking

Each extracted field includes citations to the source blocks:
Use these block IDs with the json output to trace extracted values back to the source document.

Schema Examples

Financial Document

Scientific Paper

Contract

Using Checkpoints

If you already converted a document with save_checkpoint=True using the Convert API, pass the checkpoint_id to ExtractOptions to skip re-parsing. Send the checkpoint without a file or file URL. Turbo extraction requires source images and cannot reuse checkpoints.
The extract endpoint accepts the following parameters: file or file_url, page_schema or schema_id (one is required), schema_version, extraction_mode, mode, output_format, skip_cache, max_pages, page_range, save_checkpoint, checkpoint_id, webhook_url, and processing_location (e.g. "eu" — routes processing and storage to EU infrastructure; requires file_url or a pre-uploaded datalab:// reference instead of a multipart upload).

Using Saved Schemas

Instead of passing page_schema inline, you can save schemas to Datalab and reference them by ID. This avoids repeating the schema in every request and enables versioning.
Pass schema_version to pin to a specific schema version; omit it to always use the latest. See Saved Schemas for full CRUD API reference.

Confidence Scoring

Extraction scoring is in beta.We’d love your feedback — reach out at support@datalab.to.Scoring is free.
Scoring runs asynchronously after cloud extraction in fast mode. After scoring succeeds, later polls of request_check_url include _score fields and a non-null extraction_score_average. Scoring can fail independently of extraction; use a bounded polling window and handle missing or null scores. Turbo, balanced, and accurate modes do not produce numeric confidence scores. No extra parameters or endpoints are needed. Each _score field is a {"score": int, "reasoning": str} object explaining what evidence was found or missing.

Score response format

Without scoring complete, extraction_schema_json contains fields and citations:
Once scoring finishes, each field also gets a _score object, and the top-level response includes an extraction_score_average:
The top-level response also includes extraction_score_average (4.5 in this case), averaging all field scores. Score rubric: See Confidence Scoring for a full walkthrough with code examples.

Auto-Generate Schemas

Don’t want to write schemas by hand? Use the schema generation endpoint to automatically suggest schemas for your document. This requires a checkpoint from a previous conversion:
The endpoint returns three schema options at different complexity levels — use the one that best matches your needs, then customize it.

Using Forge

Create and test schemas visually in Forge:
  1. Upload a sample document
  2. Define fields in the visual editor
  3. Switch to JSON Editor to copy the schema
  4. Test extraction before deploying

Next Steps

Balanced and Accurate Extraction Modes

Per-field verification, reasoning, and extraction status for compliance workflows

Saved Schemas

Create reusable schemas and reference them by ID — no need to repeat the schema in each request

Confidence Scoring

Score extraction results with per-field confidence ratings

Handling Long Documents

Strategies for extracting from 100+ page documents