Skip to main content
Use these scripts as starting points for common tasks with the Parse, Extract, and Ground APIs. Each script has a Python and a TypeScript version and reads the response the way these APIs return it: the document as Markdown, a structure tree of pages and blocks, and a grounding object on every block with its page number and bounding box. If you are moving code from ADE Gen1, these scripts replace the Gen1 samples. Gen1 scripts read chunks and a top-level grounding map keyed by chunk ID, and neither exists in these responses. See the Migration Guide.
These examples require the Python or TypeScript client library. Before running a script, set your API key and install the library and any required dependencies.

Parse Documents

Parse a Directory of Documents

Submit every file in a folder as a Parse Job on the standard tier and save the Markdown and the full response.

Parse Documents Concurrently

Submit and poll many Parse Jobs at once with the async Python client or Promise.allSettled().

Visualize Parsed Blocks

Draw a labeled, color-coded box around every block and table cell on each page.

Save Parsed Blocks as Images

Crop each block on each page and save it as a separate PNG named by its block ID.

Extract and Ground Fields

Parse & Extract

Parse a document, extract fields with a JSON schema, and save both responses.

Link Extracted Data to Document Locations

Ground each extracted field with the Ground API, then save a crop and the page and box of each value.