{"slug":"document-extraction-api","title":"document-extraction-api","summary":"Use the Nutrient Data Extraction API to parse whole documents into Markdown or spatial elements, extract named fields such as invoice totals with source citations, classify documents against labels, or detect document boundaries in a merged packet.","platform":"Claude","tags":[],"authorName":"LLM Mart","authorSlug":"llm-mart","score":0,"source":"github","price":null,"verified":false,"createdAt":"2026-11-29T00:42:56.876981Z","repo":{"url":"https://github.com/PSPDFKit-labs/nutrient-skills","stars":18,"forks":1,"license":null,"updatedAt":"2026-11-26T02:45:46Z"},"bodyHtml":"<hr>\n<h2>name: document-extraction-api\ndescription: &gt;-\nUse the Nutrient Data Extraction API to parse whole documents into Markdown or spatial\nelements, extract named fields such as invoice totals with source citations, classify\ndocuments against labels, or detect document boundaries in a merged packet.\nlicense: MIT\nmetadata:\nauthor: nutrient-sdk\nversion: \"1.1\"\nhomepage: \"https://www.nutrient.io/api/\"\nrepository: \"https://github.com/PSPDFKit-labs/nutrient-skills\"\ncompatibility: \"Requires Python 3.10+, uv, and internet. Works with Claude Code, Codex CLI, Gemini CLI, OpenCode, Cursor, Windsurf, GitHub Copilot, Amp, or any Agent Skills-compatible product.\"\nshort-description: \"Parse, extract cited fields, classify, or separate packets with Nutrient Data Extraction\"</h2>\n<h1>Nutrient Data Extraction</h1>\n<p>Use this skill to build with the Data Extraction API. To process a file in chat, connect\nthe <a href=\"https://github.com/PSPDFKit/nutrient-mcp-plugins\">hosted Nutrient MCP plugin</a> for its\nsupported document tasks.</p>\n<h2>Choose the operation</h2>\n<table>\n<thead>\n<tr>\n<th>Desired result</th>\n<th>Use</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Named fields, such as invoice number, total, and line items, with evidence</td>\n<td><strong><code>extract</code></strong> with a JSON Schema via <code>scripts/extract.py</code>.</td>\n</tr>\n<tr>\n<td>Whole-document Markdown for RAG, search, or migration</td>\n<td><strong><code>parse</code></strong> with Markdown output via <code>scripts/parse.py</code>.</td>\n</tr>\n<tr>\n<td>Document layout, bounding boxes, or every detected table</td>\n<td><strong><code>parse</code></strong> with spatial output via <code>scripts/parse.py</code>.</td>\n</tr>\n<tr>\n<td>The likely document type, such as invoice, receipt, or contract</td>\n<td><strong><code>classify</code></strong> via the <a href=\"https://www.nutrient.io/guides/dws-data-extraction/classify.md\">Classify API</a>.</td>\n</tr>\n<tr>\n<td>Where the component documents start and end in a merged file</td>\n<td><strong><code>split</code></strong> via the <a href=\"https://www.nutrient.io/guides/dws-data-extraction/split.md\">Split API</a>.</td>\n</tr>\n</tbody>\n</table>\n<p>For RAG <em>chunking</em> of a parsed document, see the sibling <code>grounded-rag-ingestion</code> skill. For\nPDF generation, conversion, OCR, redaction, signing, or any <code>/build</code>-based workflow, use the\nsibling <code>document-processor-api</code> skill.</p>\n<h3>Classify or separate a packet</h3>\n<p>Follow the linked API examples for these operations. The bundled scripts cover parsing\nand field extraction.</p>\n<ul>\n<li>Use <code>POST /extraction/classify</code> with at least two meaningful labels for a direct\nclassification request. The result ranks labels with scores. Route ambiguous results to review.</li>\n<li>Use <code>POST /extraction/split</code> when the workspace has Split enabled. Read the one-based,\ninclusive page ranges and boundary confidence from <code>output.segments</code>. When you need\none PDF per segment, the API can also return a ZIP download.</li>\n<li>For a mixed packet, review uncertain boundaries and classify the separated documents.\nThen extract against the right schema for each type. Keep each segment's original page\nrange with the result so a citation can be traced back to the packet.</li>\n<li>When the user provides the page ranges and only wants pages cut out, use the\n<code>document-processor-api</code> skill instead.</li>\n</ul>\n<h2><code>/extraction/extract</code> — schema field extraction with citations</h2>\n<p>Define the fields you want in a JSON Schema (root <code>type: object</code>); <code>extract</code> returns\n<code>output.data</code> with those values and <code>output.metadata</code> with per-field citation metadata\n(<code>options.includeCitations</code> defaults on). Accepts a local file or a URL.</p>\n<p>For a first run, save the schema from the <a href=\"https://www.nutrient.io/guides/dws-data-extraction/extract.md#request-formats\">Extract API examples</a>\nas <code>fields.json</code> and use the <a href=\"https://www.nutrient.io/downloads/pdf-to-json-review/invoice.pdf\">synthetic sample invoice</a>.\nLook for invoice number <code>INV-DEMO-1042</code> and total <code>176.00</code> USD with citations on page 1.</p>\n<pre><code># Pull schema-defined fields from a local invoice, with citations (default)\nuv run scripts/extract.py --input invoice.pdf --schema fields.json --out result.json\n\n# From the public sample URL\nuv run scripts/extract.py --url https://www.nutrient.io/downloads/pdf-to-json-review/invoice.pdf \\\n  --schema fields.json --out result.json --mode understand\n</code></pre>\n<p>Use the <a href=\"https://www.nutrient.io/guides/dws-data-extraction/pricing.md\">Data Extraction pricing guide</a>\nand the response's usage for current charges. The bundled script gates high local estimates\nbehind <code>--yes</code> and can display legacy credit-based estimates. See\n<code>references/extract-output-and-citations.md</code> for the response shape. Include the source page\nwhen reporting cited values, and flag missing or uncertain evidence for review.</p>\n<h2>Setup</h2>\n<ul>\n<li>Get an API key with Data Extraction access at <a href=\"https://dashboard.nutrient.io/\">https://dashboard.nutrient.io/</a>.</li>\n<li>Export it as <code>NUTRIENT_EXTRACT_API_KEY</code>:\n<pre><code>export NUTRIENT_EXTRACT_API_KEY=\"pdf_live_...\"\n</code></pre>\n</li>\n<li>Scripts live in <code>scripts/</code> relative to this SKILL.md. Use the directory containing this\nSKILL.md as the working directory:\n<pre><code>cd &lt;directory containing this SKILL.md&gt; &amp;&amp; uv run scripts/&lt;script&gt;.py --help\n</code></pre>\n</li>\n</ul>\n<p>The helpers prefer <code>NUTRIENT_EXTRACT_API_KEY</code> and can use a global key with Data Extraction\naccess via <code>NUTRIENT_API_KEY</code> when the first variable is unset.</p>\n<h2><code>/extraction/parse</code> — one primitive, two output shapes</h2>\n<p>One call returns a structural document model with typed elements, bounding boxes,\nconfidence scores, and reading order, or a whole-document Markdown string. The processing\nmode determines which element types are available.</p>\n<h3>Picking a mode</h3>\n<p>The <a href=\"https://www.nutrient.io/guides/dws-data-extraction/parsing/processing-modes.md\">processing modes guide</a>\nrecommends <code>auto</code> as a starting point for direct API integrations. It routes each page\nto <code>structure</code>, <code>understand</code>, or <code>agentic</code>. The bundled <code>parse.py</code> helper takes explicit\nmodes and defaults to <code>structure</code> with spatial output.</p>\n<table>\n<thead>\n<tr>\n<th>User intent</th>\n<th>Mode</th>\n<th>Output</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Read an existing PDF text layer for search or RAG</td>\n<td><code>text</code></td>\n<td>Markdown</td>\n</tr>\n<tr>\n<td>Read a scan or photo with OCR</td>\n<td><code>structure</code></td>\n<td>Markdown or spatial</td>\n</tr>\n<tr>\n<td>Enumerate form regions or detect semantic layout</td>\n<td><code>understand</code></td>\n<td>Spatial</td>\n</tr>\n<tr>\n<td>Describe figures or diagrams</td>\n<td><code>agentic</code></td>\n<td>Spatial</td>\n</tr>\n</tbody>\n</table>\n<p>For large runs, estimate the cost from the <a href=\"https://www.nutrient.io/guides/dws-data-extraction/pricing.md\">current per-page prices</a>\nand the page count. When using a legacy credit estimate, confirm with the operator\nbefore running above 200 extraction credits.</p>\n<h3>Invocation</h3>\n<pre><code># Default: structure mode, spatial output\nuv run scripts/parse.py --input doc.pdf --out out.json\n\n# Markdown for RAG (text mode — cheapest)\nuv run scripts/parse.py --input doc.pdf --out out.md --output-format markdown --mode text\n\n# Enumerate all key-value regions of a form (understand mode) — for NAMED fields use extract\nuv run scripts/parse.py --input doc.pdf --out out.json --mode understand\n\n# Agentic (VLM alt text on pictures)\nuv run scripts/parse.py --input doc.pdf --out out.json --mode agentic\n</code></pre>\n<p>The script reports legacy credit usage when present in the response. Use the API response\nor dashboard to verify current charges.</p>\n<h3>Downstream consumption</h3>\n<p>After a single <code>/parse</code> call, slice the response for common needs:</p>\n<ul>\n<li><strong>Reading-order plain text</strong>: walk <code>output.elements</code> sorted by <code>(page.pageIndex, readingOrder)</code>, join <code>paragraph</code> and <code>handwriting</code> <code>text</code> fields</li>\n<li><strong>Tables</strong>: project <code>cells[]</code> on each <code>table</code> element into rows/columns using <code>cell.row</code> and <code>cell.column</code></li>\n<li><strong>Key-value pairs</strong>: read <code>pairs[]</code> on each <code>keyValueRegion</code> element — each pair has <code>.key.value</code> and <code>.value.value</code></li>\n<li><strong>Formulas</strong>: read <code>latex</code> on each <code>formula</code> element</li>\n<li><strong>Pictures</strong>: read <code>classification</code> and <code>altDescription</code> (populated by <code>agentic</code> mode) on each <code>picture</code> element</li>\n<li><strong>Markdown output</strong>: call with <code>--output-format markdown</code>; the script writes the Markdown string directly</li>\n</ul>\n<p>For the canonical response schema and per-mode field availability, see the official docs linked from <code>references/parse-output-filtering.md</code>; that file also lists the tools we suggest for filtering and reshaping the response.</p>\n<h3>Input constraint</h3>\n<p><code>parse.py</code> accepts local file paths. For a document at a public URL, use the\n<a href=\"https://www.nutrient.io/guides/dws-data-extraction/parsing.md#json-body-with-url\">Parse API's documented JSON URL input</a>.</p>\n","files":[{"path":".gitignore","sizeBytes":19,"isText":false},{"path":"references/extract-output-and-citations.md","sizeBytes":2283,"isText":true},{"path":"references/parse-output-filtering.md","sizeBytes":2225,"isText":true},{"path":"scripts/extract.py","sizeBytes":13204,"isText":true},{"path":"scripts/lib/common.py","sizeBytes":2578,"isText":true},{"path":"scripts/lib/test_common.py","sizeBytes":2681,"isText":true},{"path":"scripts/parse.py","sizeBytes":4695,"isText":true},{"path":"scripts/test_extract.py","sizeBytes":20024,"isText":true},{"path":"SKILL.md","sizeBytes":8107,"isText":true}],"reviewScore":null,"reviewSummary":null,"trust":{"provenance":"trusted-source-unreviewed","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow.","bodySource":null},"bodyLocked":false,"purchaseUrl":null,"sourceUrl":null,"report":{"provenance":"trusted-source-unreviewed","screen":{"ran":true,"outcome":"notes-only","suspicious":0,"notes":1,"hiddenCharacters":false},"virusScan":{"engine":"clamav","status":"clean","scannedAt":"2026-11-29T00:45:07.228512Z","sha256":"4A4EDDCA9E29893823F020ACEAA29F6CE249C7750DB4A4D996E9BBF98EFE8CCF","sizeBytes":19447},"review":null,"source":{"repositoryUrl":"https://github.com/PSPDFKit-labs/nutrient-skills","path":"plugins/nutrient-dws/skills/document-extraction-api","license":null,"commit":"83aea52a003a4ebb69fcf78ea724b48cbe950835","subtreeSha":"8BD4CA6CE35AE5281463D92D1DAE5D736C9F9AEBBF0FEF20CFE6EDEBF4C8D2FE","lastSyncedAt":"2026-11-29T00:42:56.729498Z"},"reviewedAt":"2026-11-29T00:50:15.908605Z","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow."},"install":[{"target":"skills-cli","command":"npx skills add https://github.com/PSPDFKit-labs/nutrient-skills/tree/main/plugins/nutrient-dws/skills/document-extraction-api"},{"target":"claude-code","command":"claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install pspdfkit-labs-nutrient-skills@llmmart"},{"target":"git","command":"git clone https://github.com/PSPDFKit-labs/nutrient-skills.git"}]}