- A Datalab account with an API key (new accounts include $5 in free credits)
- Python 3.10+ installed
- The Datalab SDK:
pip install datalab-python-sdk - Your
DATALAB_API_KEYenvironment variable set
Restrict to Specific Pages
If you know which pages contain the data you need, usepage_range:
Segment and Chain Extractions
For documents with distinct sections (like financial reports or contracts), extract the table of contents first, then process each section separately.Step 1: Extract Table of Contents
Step 2: Extract Each Section
Use Document Segmentation
For documents without a clear table of contents, use Document Segmentation to locate named sections in the parsed document.Full Example
Process sections after verifying the table of contents and mapping its page numbers to PDF page indices:Tips
- Process pages you need - Use
page_rangeto avoid processing unnecessary pages - Extract TOC first - Build page ranges dynamically from the document structure
- Choose extraction and parsing independently - Set
extraction_modefor extraction quality andmodefor parsing quality; see Extraction Modes - Handle errors - Some sections may not match your schema exactly
Next Steps
Structured Extraction
Learn the full structured extraction API and schema options.
Document Segmentation
Automatically split documents by section headers.
Batch Processing
Process multiple long documents efficiently in parallel.
Pipelines
Chain processors into versioned, reusable pipelines.