Use this file to discover all available pages before exploring further.
Use the Playground to explore and understand basic concepts without writing code. When you’re ready to scale intelligent document processing, follow the tutorial below to get started with code.
This tutorial guides you through how to parse a sample bank statement and extract these fields: Account Holder Name and Number of Deposits.
cURL
Python
TypeScript
1
Install jq
Install jq, a free third-party command-line tool that will help you save files later in this procedure. Some common install instructions are below; to see all installation methods, go the the jq site.
brew install jq
2
Parse a document
Run the code below to parse a sample bank statement with the API. The > at the end of the command saves the response to a file called parse-output.json.Replace YOUR_API_KEY with your API key.
To extract data from the document, you need to pass the markdown field from parse-output.json to the API.Run the following command to save the markdown field to a file called markdown-bank-statement.md.
Now that the parsed output is in a Markdown file, run the code below to extract the Account Holder Name and Number of Deposits fields using the API.Replace YOUR_API_KEY with your API key.
curl -X POST 'https://api.va.landing.ai/v1/ade/extract' \ -H 'Authorization: Bearer YOUR_API_KEY' \ -F 'schema={"type": "object", "properties": {"name": {"type": "string", "description": "Account holder name"}, "number_deposits": {"type": "integer", "description": "The number of deposits"}}}' \ -F 'markdown=@markdown-bank-statement.md' \ -F 'model=extract-latest'
Get your API key and set it as an environment variable. For more details, go to API Key.
export VISION_AGENT_API_KEY=<your-api-key>
2
Install the Python library
Install the library.
pip install landingai-ade
3
Create your code
This example shows the complete workflow of parsing a sample bank statement and extracting the Account Holder Name and Number of Deposits fields. If you only need to parse documents, use just the parsing section.Save the code block below as quickstart.py.
import jsonfrom landingai_ade import LandingAIADE# Initialize the clientclient = LandingAIADE()##### Parse the document ###### Parse the documentparse_response = client.parse( document_url="https://docs.landing.ai/examples/bank-statement.pdf", model="dpt-2-latest", save_to="./output" # optional: saves the full response as JSON for later reference)print("Full Parse response saved to ./output/")##### Extract fields from the parsed document ###### Define which fields to extract. Each property specifies a field name and its expected data type.schema_dict = { "type": "object", "properties": { "name": { "type": "string", "description": "Account holder name" }, "number_deposits": { "type": "integer", "description": "The number of deposits" } }}# Convert schema dictionary to JSON stringschema_json = json.dumps(schema_dict)# Extract fields using the parsed markdownextract_response = client.extract( schema=schema_json, markdown=parse_response.markdown, # Parse converts the document to Markdown; Extract uses it to identify and pull specific fields model="extract-latest", save_to="./output" # optional: saves the full response as JSON for later reference)print("Full Extract response saved to ./output/")# Print the extracted fieldsprint("\nExtracted fields:")print(extract_response.extraction)
4
Run your code
Run the Python file you created.
python quickstart.py
The script parses the document and saves both responses to ./output/. The extracted fields returned are:
Account Holder Name: Sarah J. Mitchell
Number of Deposits: 5
Extracted fields:{'name': 'Sarah J. Mitchell', 'number_deposits': 5}
1
Set the API key as an environment variable
Get your API key and set it as an environment variable. For more details, go to API Key.
export VISION_AGENT_API_KEY=<your-api-key>
2
Install the TypeScript library
Install the library.
npm install landingai-ade
3
Create your code
This example shows the complete workflow of parsing a sample bank statement and extracting the Account Holder Name and Number of Deposits fields. If you only need to parse documents, use just the parsing section.Save the code block below as quickstart.ts.
import LandingAIADE from "landingai-ade";// Initialize the clientconst client = new LandingAIADE();///// Parse the document /////// Parse the documentconst parseResponse = await client.parse({ document: await fetch("https://docs.landing.ai/examples/bank-statement.pdf"), model: "dpt-2-latest", saveTo: "./output" // optional: saves the full response as JSON for later reference});console.log("Full Parse response saved to ./output/");///// Extract fields from the parsed document /////// Define which fields to extract. Each property specifies a field name and its expected data type.const schemaDict = { type: "object", properties: { name: { type: "string", description: "Account holder name" }, number_deposits: { type: "integer", description: "The number of deposits" } }};// Convert schema object to JSON stringconst schemaJson = JSON.stringify(schemaDict);// Extract fields using the parsed markdownconst extractResponse = await client.extract({ schema: schemaJson, markdown: parseResponse.markdown, // Parse converts the document to Markdown; Extract uses it to identify and pull specific fields model: "extract-latest", saveTo: "./output" // optional: saves the full response as JSON for later reference});console.log("Full Extract response saved to ./output/");// Print the extracted fieldsconsole.log("\nExtracted fields:");console.log(extractResponse.extraction);
4
Run your code
Run the TypeScript file you created.
npx tsx quickstart.ts
The script parses the document and saves both responses to ./output/. The extracted fields returned are:
Account Holder Name: Sarah J. Mitchell
Number of Deposits: 5
Extracted fields:{ name: 'Sarah J. Mitchell', number_deposits: 5 }
Choose how you want to integrate into your workflow. Call the API directly for maximum flexibility, or use our Python or TypeScript libraries for faster development.
API
Call the API directly for language flexibility and advanced customization.
Python Library
Use our Python library to build custom scripts.
TypeScript Library
Use our TypeScript library to build custom scripts.