Skip to main content

Export Results

DocumentPro offers two methods to export parsing results: exporting a single parsed result and exporting results for a date range.

1. Export Single Parsed Result#

This endpoint allows you to export the results of a single parsing job to Excel or CSV format.

API Endpoint#

GET https://api.documentpro.ai/files/export

Query Parameters#

  • request_id (required): The unique identifier of the parsing job.
  • file_format (required): Format of the export file. Options: "csv" or "xlsx".
  • data_layout (required): Layout of the data. Options: "flat" or "line_items".
  • include_filename (optional): Include the filename in the export. Options: "true" or "false".
  • include_request_id (optional): Include the request ID in the results. Options: "true" or "false".
  • merge_field (required if data_layout is "line_items"): The name of a table-type field in the parser to merge.

Headers#

  • x-api-key (required): Your API key for authentication.

Example Using cURL#

curl --location 'https://api.documentpro.ai/files/export?request_id=151656f5-4df4-4005-9186-ba8ebb239c4d&file_format=csv&include_filename=true&include_request_id=true&data_layout=flat' \--header 'x-api-key: YOUR_API_KEY'

Response#

{    "success": true,    "file_presigned_url": "https://documentpro-exports.s3.amazonaws.com/..."}

The file_presigned_url is valid for 1 hour and can be used to download the exported file.

2. Export Results for Date Range#

This endpoint allows you to export parsing results for a specific parser over a date range.

API Endpoint#

GET https://api.documentpro.ai/files/export

Query Parameters#

  • template_id (required): The unique identifier of the parser (also known as parser_id).
  • date_range (required): The range of dates to export. Options: "today", "7_days", "30_days", "90_days".
  • file_format (required): Format of the export file. Options: "csv" or "xlsx".
  • data_layout (required): Layout of the data. Options: "flat" or "line_items".
  • include_filename (optional): Include the filename in the export. Options: "true" or "false".
  • include_request_id (optional): Include the request ID in the results. Options: "true" or "false".
  • merge_field (required if data_layout is "line_items"): The name of a table-type field in the parser to merge.
  • excel_format (optional, applies when file_format is "xlsx"): Format of Excel file. Options: "single_sheet" (default) or "multi_sheet".

Headers#

  • x-api-key (required): Your API key for authentication.

Example Using Python#

import requests
url = "https://api.documentpro.ai/files/export"headers = {    "x-api-key": "YOUR_API_KEY"}params = {    "template_id": "a62e2b5f-ccc2-4e2a-8fda-d7bd6579a692",    "date_range": "30_days",    "file_format": "xlsx",    "data_layout": "flat",    "include_filename": "true",    "include_request_id": "true",    "excel_format": "single_sheet"}
response = requests.get(url, headers=headers, params=params)
if response.status_code == 200:    result = response.json()    print(f"Export successful. Download URL: {result['file_presigned_url']}")else:    print("Export failed")    print(response.text)

Response#

{    "success": true}

The file_presigned_url is sent to your account email and is valid for 1 hour. It can be used to download the exported file.

Important Notes#

  1. The file_presigned_url in the response is temporary and will expire after 1 hour.
  2. For the date range export, if excel_format is set to "single_sheet", all results will appear in one sheet. If set to "multi_sheet", each parsing result will appear in its own sheet.
  3. When data_layout is set to "line_items", the merge_field must be specified and should correspond to a table-type field in your parser.
  4. Ensure you have the necessary permissions to access the parsing results you're trying to export.

Next Steps#

  • Download the exported file using the provided file_presigned_url