TITLE: Begin Basic Contract Field Extraction DESCRIPTION: This example illustrates how to initiate the field extraction process for a Basic Contract using the ABBYY Document AI SDK. It sends a request with an input source URL pointing to the document and asserts that the extraction process has started successfully. SOURCE: https://github.com/sarvottam-bhagat/abbyy-documentation/blob/main/api documentation.md#_snippet_51 LANGUAGE: python CODE: ``` from abbyy_document_ai import DocumentAi import os with DocumentAi( api_key_auth=os.getenv("DOCUMENTAI_API_KEY_AUTH", ""), ) as document_ai: res = document_ai.models.basic_contract.begin_field_extraction(request={ "input_source": { "url": "https://example.com/documents/basic_contract.png", }, }) assert res.documents is not None # Handle response print(res.documents) ``` ---------------------------------------- TITLE: ABBYY Document AI Invoice Processing API DESCRIPTION: Documentation for the ABBYY Document AI API endpoints related to invoice processing, including initial submission and retrieval of extracted fields. It details the request parameters, response structures, and status handling. SOURCE: https://github.com/sarvottam-bhagat/abbyy-documentation/blob/main/quickstart.md#_snippet_3 LANGUAGE: APIDOC CODE: ``` Endpoint: POST /documents/invoice Description: Submits an invoice document for data extraction. Parameters: input_source (object): Defines the source of the invoice document. url (string): URL to the invoice file. Headers: Authorization: Bearer Response (Initial Submission): Type: JSON Array of Document Objects Example: [ { "id": "r23qpmmjsc7f93o3", "name": "Invoice%20CA_1.pdf", "createdAt": "2025-04-01 20:41:26.510152", "status": "Pending", "pageCount": 1 } ] Properties: id (string): Unique identifier for the submitted document. name (string): Original name of the document. createdAt (string): Timestamp of document submission. status (string): Current processing status (e.g., 'Pending', 'Processed'). pageCount (integer): Number of pages in the document. Endpoint: GET /documents/invoice/[document-id] Description: Retrieves the extracted fields for a previously submitted invoice document. Parameters: document_id (string): The ID of the document obtained from the initial submission. Response (Processed Invoice Fields): Type: JSON Object Example: { "meta": { "id": "r23qpmmjsc7f93o3", "name": "Invoice%20CA_1.pdf", "createdAt": "2025-04-01 20:41:26.510152", "status": "Processed", "pageCount": 1 }, "fields": { "invoiceNumber": "9435435", "invoiceDate": "2021-11-11", "total": 4620, "currency": "CAD", "businessUnit": { "name": "M GROUP INC.", "address": "770-21ST AVENUE N\nSASKATOON SK S1K7R1\nCANADA", "country": "CA" }, "vendor": { "name": "ANADAYA CANADA", "address": "262 Merrier Avenue, Toronto, Ontario Т1Т 3R29" }, "reversedCharged": false, "invoiceType": { "invoice": true, "creditNote": false }, "purchaseOrder": [ { "orderChecked": false } ], "lineItems": [ { "isValid": false, "position": 1, "articleNumberVendor": "864UW7", "description": "RECEIVER (19003)", "quantity": 2, "unitPrice": 385, "netPrice": 770, "currency": "CAD" }, { "isValid": false, "position": 2, "articleNumberVendor": "864UW7", "description": "RECEIVER (85813)", "quantity": 2, "unitPrice": 385, "netPrice": 770, "currency": "CAD" }, { "isValid": false, "position": 3, "articleNumberVendor": "384 UW5", "description": "RECEIVER (19053)", "quantity": 2, "unitPrice": 385, "netPrice": 770, "currency": "CAD" }, { "isValid": false, "position": 4, "articleNumberVendor": "365UW8", "description": "RECEIVER (85583)", "quantity": 2, "unitPrice": 385, "netPrice": 770, "currency": "CAD" }, { "isValid": false, "position": 5, "articleNumberVendor": "354UW7", "description": "RECEIVER (15003)", "quantity": 2, "unitPrice": 385, "netPrice": 770, "currency": "CAD" }, { "isValid": false, "position": 6, "articleNumberVendor": "564UW7", "description": "RECEIVER (85513)", "quantity": 2, "unitPrice": 385, "netPrice": 770, "currency": "CAD" } ] } } ``` ---------------------------------------- TITLE: Begin Brokerage Statement Field Extraction DESCRIPTION: This code example demonstrates how to start the field extraction process for a Brokerage Statement using the ABBYY Document AI SDK. It sends the document's URL as an input source to the service and verifies that the extraction request was successfully initiated. SOURCE: https://github.com/sarvottam-bhagat/abbyy-documentation/blob/main/api documentation.md#_snippet_53 LANGUAGE: python CODE: ``` from abbyy_document_ai import DocumentAi import os with DocumentAi( api_key_auth=os.getenv("DOCUMENTAI_API_KEY_AUTH", ""), ) as document_ai: res = document_ai.models.brokerage_statement.begin_field_extraction(request={ "input_source": { "url": "https://example.com/documents/brokerage_statement.png", }, }) assert res.documents is not None # Handle response print(res.documents) ``` ---------------------------------------- TITLE: Begin Field Extraction for Remittance Advice using ABBYY Document AI SDK DESCRIPTION: This Python example illustrates how to initiate the field extraction process for a remittance advice document using the ABBYY Document AI SDK. It sets up the DocumentAi client and then calls the `begin_field_extraction` method on the remittance advice model, providing a URL to the input document. The response contains information about the initiated extraction. SOURCE: https://github.com/sarvottam-bhagat/abbyy-documentation/blob/main/api documentation.md#_snippet_13 LANGUAGE: python CODE: ``` from abbyy_document_ai import DocumentAi import os with DocumentAi( api_key_auth=os.getenv("DOCUMENTAI_API_KEY_AUTH", ""), ) as document_ai: res = document_ai.models.remittance_advice.begin_field_extraction(request={ "input_source": { "url": "https://example.com/documents/invoice.png", }, }) assert res.documents is not None # Handle response print(res.documents) ``` ---------------------------------------- TITLE: Start Packing List Field Extraction with ABBYY Document AI Python SDK DESCRIPTION: This code initiates the field extraction process for a packing list document from a specified URL. It sets up the Document AI client using an API key and then invokes the `begin_field_extraction` method, providing the document's URL as input. The response, containing document processing details, is then printed. SOURCE: https://github.com/sarvottam-bhagat/abbyy-documentation/blob/main/api documentation.md#_snippet_45 LANGUAGE: python CODE: ``` from abbyy_document_ai import DocumentAi import os with DocumentAi( api_key_auth=os.getenv("DOCUMENTAI_API_KEY_AUTH", ""), ) as document_ai: res = document_ai.models.packing_list.begin_field_extraction(request={ "input_source": { "url": "https://example.com/documents/packing_list.png", }, }) assert res.documents is not None # Handle response print(res.documents) ``` ---------------------------------------- TITLE: Get Extracted Fields for Invoices using ABBYY Document AI SDK DESCRIPTION: This Python snippet demonstrates how to retrieve previously extracted fields for a specific invoice document using the ABBYY Document AI SDK. It initializes the DocumentAi client with an API key and then calls the `get_extracted_fields` method on the invoice model, asserting that the invoice data is not None. SOURCE: https://github.com/sarvottam-bhagat/abbyy-documentation/blob/main/api documentation.md#_snippet_10 LANGUAGE: python CODE: ``` from abbyy_document_ai import DocumentAi import os with DocumentAi( api_key_auth=os.getenv("DOCUMENTAI_API_KEY_AUTH", ""), ) as document_ai: res = document_ai.models.invoice.get_extracted_fields(document_id="wh23anb5xjf0ntw5taase5qz") assert res.invoice is not None # Handle response print(res.invoice) ``` ---------------------------------------- TITLE: List Documents with ABBYY Document AI Python SDK DESCRIPTION: This snippet demonstrates how to list documents using the ABBYY Document AI Python SDK. It initializes the client with an API key and then iteratively fetches documents, handling pagination with the `cursor` and `next()` method to retrieve all available items. SOURCE: https://github.com/sarvottam-bhagat/abbyy-documentation/blob/main/api documentation.md#_snippet_0 LANGUAGE: python CODE: ``` from abbyy_document_ai import DocumentAi import os with DocumentAi( api_key_auth=os.getenv("DOCUMENTAI_API_KEY_AUTH", ""), ) as document_ai: res = document_ai.documents.list(cursor="xyz") while res is not None: # Handle items res = res.next() ``` ---------------------------------------- TITLE: Delete Document with ABBYY Document AI Python SDK DESCRIPTION: This example shows how to delete a specific document by its ID using the ABBYY Document AI Python SDK. It initializes the client with the necessary API key and then calls the `delete` method on the `documents` service, asserting a successful response upon completion. SOURCE: https://github.com/sarvottam-bhagat/abbyy-documentation/blob/main/api documentation.md#_snippet_1 LANGUAGE: python CODE: ``` from abbyy_document_ai import DocumentAi import os with DocumentAi( api_key_auth=os.getenv("DOCUMENTAI_API_KEY_AUTH", ""), ) as document_ai: res = document_ai.documents.delete(document_id="wh23anb5xjf0ntw5taase5qz") assert res is not None # Handle response print(res) ``` ---------------------------------------- TITLE: Synchronous usage of ABBYY Document AI SDK to list documents DESCRIPTION: Illustrates how to initialize the ABBYY Document AI SDK client with an API key and perform a synchronous API call to list documents, including handling pagination through the `res.next()` method. SOURCE: https://github.com/sarvottam-bhagat/abbyy-documentation/blob/main/python.md#_snippet_4 LANGUAGE: Python CODE: ``` from abbyy_document_ai import DocumentAi import os with DocumentAi( api_key_auth=os.getenv("DOCUMENTAI_API_KEY_AUTH", ""), ) as document_ai: res = document_ai.documents.list(cursor="") while res is not None: # Handle items res = res.next() ``` ---------------------------------------- TITLE: Get Extracted Fields for Remittance Advice using ABBYY Document AI SDK DESCRIPTION: This Python snippet demonstrates how to retrieve previously extracted fields for a specific remittance advice document using the ABBYY Document AI SDK. It initializes the DocumentAi client with an API key and then calls the `get_extracted_fields` method on the remittance advice model, asserting that the remittance advice data is not None. SOURCE: https://github.com/sarvottam-bhagat/abbyy-documentation/blob/main/api documentation.md#_snippet_14 LANGUAGE: python CODE: ``` from abbyy_document_ai import DocumentAi import os with DocumentAi( api_key_auth=os.getenv("DOCUMENTAI_API_KEY_AUTH", ""), ) as document_ai: res = document_ai.models.remittance_advice.get_extracted_fields(document_id="wh23anb5xjf0ntw5taase5qz") assert res.remittance_advice is not None # Handle response print(res.remittance_advice) ``` ---------------------------------------- TITLE: Start Sea Waybill Field Extraction with ABBYY Document AI Python SDK DESCRIPTION: This code initiates the field extraction process for a sea waybill document from a specified URL. It sets up the Document AI client using an API key and then invokes the `begin_field_extraction` method, providing the document's URL as input. The response, containing document processing details, is then printed. SOURCE: https://github.com/sarvottam-bhagat/abbyy-documentation/blob/main/api documentation.md#_snippet_47 LANGUAGE: python CODE: ``` from abbyy_document_ai import DocumentAi import os with DocumentAi( api_key_auth=os.getenv("DOCUMENTAI_API_KEY_AUTH", ""), ) as document_ai: res = document_ai.models.sea_waybill.begin_field_extraction(request={ "input_source": { "url": "https://example.com/documents/sea_waybill.png", }, }) assert res.documents is not None # Handle response print(res.documents) ``` ---------------------------------------- TITLE: Begin Field Extraction for Delivery Notes using ABBYY Document AI SDK DESCRIPTION: This Python example illustrates how to initiate the field extraction process for a delivery note document using the ABBYY Document AI SDK. It sets up the DocumentAi client and then calls the `begin_field_extraction` method on the delivery note model, providing a URL to the input document. The response contains information about the initiated extraction. SOURCE: https://github.com/sarvottam-bhagat/abbyy-documentation/blob/main/api documentation.md#_snippet_15 LANGUAGE: python CODE: ``` from abbyy_document_ai import DocumentAi import os with DocumentAi( api_key_auth=os.getenv("DOCUMENTAI_API_KEY_AUTH", ""), ) as document_ai: res = document_ai.models.delivery_note.begin_field_extraction(request={ "input_source": { "url": "https://example.com/documents/delivery_note.png", }, }) assert res.documents is not None # Handle response print(res.documents) ``` ---------------------------------------- TITLE: Begin Field Extraction for Hotel Invoices using ABBYY Document AI SDK DESCRIPTION: This Python example illustrates how to initiate the field extraction process for a hotel invoice document using the ABBYY Document AI SDK. It sets up the DocumentAi client and then calls the `begin_field_extraction` method on the hotel invoice model, providing a URL to the input document. The response contains information about the initiated extraction. SOURCE: https://github.com/sarvottam-bhagat/abbyy-documentation/blob/main/api documentation.md#_snippet_17 LANGUAGE: python CODE: ``` from abbyy_document_ai import DocumentAi import os with DocumentAi( api_key_auth=os.getenv("DOCUMENTAI_API_KEY_AUTH", ""), ) as document_ai: res = document_ai.models.hotel_invoice.begin_field_extraction(request={ "input_source": { "url": "https://example.com/documents/hotel_invoice.png", }, }) assert res.documents is not None # Handle response print(res.documents) ``` ---------------------------------------- TITLE: Poll ABBYY Document AI API for Processed Invoice Results DESCRIPTION: Python code demonstrating how to poll the Document AI API to check the processing status of an invoice. It repeatedly calls the API until the document's status changes to 'Processed', then accesses and prints an extracted field. SOURCE: https://github.com/sarvottam-bhagat/abbyy-documentation/blob/main/quickstart.md#_snippet_4 LANGUAGE: python CODE: ``` # import time module at the top of the file for waiting between field checks import time processed = False while not processed: time.sleep(3) # Wait 3 seconds between checks res = document_ai.models.invoice.get_extracted_fields( document_id=docId ) processed = res.invoice.meta.status == "Processed" print("Invoice number: ", res.invoice.fields.invoice_number) ``` ---------------------------------------- TITLE: Begin Field Extraction for Purchase Orders using ABBYY Document AI SDK DESCRIPTION: This Python example illustrates how to initiate the field extraction process for a purchase order document using the ABBYY Document AI SDK. It sets up the DocumentAi client and then calls the `begin_field_extraction` method on the purchase order model, providing a URL to the input document. The response contains information about the initiated extraction. SOURCE: https://github.com/sarvottam-bhagat/abbyy-documentation/blob/main/api documentation.md#_snippet_11 LANGUAGE: python CODE: ``` from abbyy_document_ai import DocumentAi import os with DocumentAi( api_key_auth=os.getenv("DOCUMENTAI_API_KEY_AUTH", ""), ) as document_ai: res = document_ai.models.purchase_order.begin_field_extraction(request={ "input_source": { "url": "https://example.com/documents/invoice.png", }, }) assert res.documents is not None # Handle response print(res.documents) ``` ---------------------------------------- TITLE: Begin Field Extraction for Taxi Receipts using ABBYY Document AI SDK DESCRIPTION: This Python example illustrates how to initiate the field extraction process for a taxi receipt document using the ABBYY Document AI SDK. It sets up the DocumentAi client and then calls the `begin_field_extraction` method on the taxi receipt model, providing a URL to the input document. The response contains information about the initiated extraction. SOURCE: https://github.com/sarvottam-bhagat/abbyy-documentation/blob/main/api documentation.md#_snippet_19 LANGUAGE: python CODE: ``` from abbyy_document_ai import DocumentAi import os with DocumentAi( api_key_auth=os.getenv("DOCUMENTAI_API_KEY_AUTH", ""), ) as document_ai: res = document_ai.models.taxi_receipt.begin_field_extraction(request={ "input_source": { "url": "https://example.com/documents/taxi_receipt.png", }, }) assert res.documents is not None # Handle response print(res.documents) ``` ---------------------------------------- TITLE: Extract Invoice Data using ABBYY Document AI Python SDK DESCRIPTION: Python code to initialize the Document AI SDK with an API key and send an invoice file for processing. It demonstrates how to use the 'documents/invoice' endpoint and capture the document ID from the initial response. SOURCE: https://github.com/sarvottam-bhagat/abbyy-documentation/blob/main/quickstart.md#_snippet_2 LANGUAGE: python CODE: ``` from document_ai_sdk import DocumentAi API_KEY="your-api-key-here" with DocumentAi(api_key_auth=API_KEY) as document_ai: res = document_ai.invoice.extract_invoice_data(input_source={ "url": "https://raw.githubusercontent.com/dotNetkow/test-cods/6c25fa2e54fb96ecf534903aef0d3cbecd71e987/Invoice%20CA_1.pdf", }) docId = res.documents[0].id print(res) ``` ---------------------------------------- TITLE: Start International Consignment Note Field Extraction with ABBYY Document AI Python SDK DESCRIPTION: This code initiates the field extraction process for an international consignment note document from a specified URL. It sets up the Document AI client using an API key and then invokes the `begin_field_extraction` method, providing the document's URL as input. The response, containing document processing details, is then printed. SOURCE: https://github.com/sarvottam-bhagat/abbyy-documentation/blob/main/api documentation.md#_snippet_49 LANGUAGE: python CODE: ``` from abbyy_document_ai import DocumentAi import os with DocumentAi( api_key_auth=os.getenv("DOCUMENTAI_API_KEY_AUTH", ""), ) as document_ai: res = document_ai.models.international_consignment_note.begin_field_extraction(request={ "input_source": { "url": "https://example.com/documents/international_consignment_note.png", }, }) assert res.documents is not None # Handle response print(res.documents) ``` ---------------------------------------- TITLE: Extract Invoice Data and Poll for Completion (Python) DESCRIPTION: This Python snippet demonstrates how to initialize the Document AI SDK, submit an invoice PDF for data extraction using a URL, and then poll the API until the document processing is complete. It showcases how to retrieve and print specific extracted fields like the invoice number. SOURCE: https://github.com/sarvottam-bhagat/abbyy-documentation/blob/main/quickstart.md#_snippet_5 LANGUAGE: python CODE: ``` import time from document_ai_sdk import DocumentAi API_KEY="your-api-key-here" with DocumentAi(api_key_auth=API_KEY) as document_ai: res = document_ai.invoice.extract_invoice_data(input_source={ "url": "https://raw.githubusercontent.com/dotNetkow/test-cods/6c25fa2e54fb96ecf534903aef0d3cbecd71e987/Invoice%20CA_1.pdf", }) docId = res.documents[0].id print(res) processed = False while not processed: time.sleep(3) # Wait 3 seconds between checks res = document_ai.models.invoice.get_extracted_fields( document_id=docId ) processed = res.invoice.meta.status == "Processed" print("Invoice number: ", res.invoice.fields.invoice_number) ``` ---------------------------------------- TITLE: Get Arrival Notice Extracted Fields using ABBYY Document AI Python SDK DESCRIPTION: This Python snippet retrieves the extracted fields for a specific arrival notice document using the ABBYY Document AI SDK. It initializes the client with an API key and calls the `get_extracted_fields` method on the `arrival_notice` model, asserting the response and printing the extracted data. SOURCE: https://github.com/sarvottam-bhagat/abbyy-documentation/blob/main/api documentation.md#_snippet_34 LANGUAGE: python CODE: ``` from abbyy_document_ai import DocumentAi import os with DocumentAi( api_key_auth=os.getenv("DOCUMENTAI_API_KEY_AUTH", ""), ) as document_ai: res = document_ai.models.arrival_notice.get_extracted_fields(document_id="wh23anb5xjf0ntw5taase5qz") assert res.arrival_notice is not None # Handle response print(res.arrival_notice) ``` ---------------------------------------- TITLE: Get Extracted Fields for Delivery Notes using ABBYY Document AI SDK DESCRIPTION: This Python snippet demonstrates how to retrieve previously extracted fields for a specific delivery note document using the ABBYY Document AI SDK. It initializes the DocumentAi client with an API key and then calls the `get_extracted_fields` method on the delivery note model, asserting that the delivery note data is not None. SOURCE: https://github.com/sarvottam-bhagat/abbyy-documentation/blob/main/api documentation.md#_snippet_16 LANGUAGE: python CODE: ``` from abbyy_document_ai import DocumentAi import os with DocumentAi( api_key_auth=os.getenv("DOCUMENTAI_API_KEY_AUTH", ""), ) as document_ai: res = document_ai.models.delivery_note.get_extracted_fields(document_id="wh23anb5xjf0ntw5taase5qz") assert res.delivery_note is not None # Handle response print(res.delivery_note) ``` ---------------------------------------- TITLE: Begin Field Extraction for Utility Bills using Python SDK DESCRIPTION: This Python snippet shows how to initiate the field extraction process for a utility bill document using the ABBYY Document AI SDK. It configures the SDK with an API key and sends a request with the URL of the utility bill image for processing. SOURCE: https://github.com/sarvottam-bhagat/abbyy-documentation/blob/main/api documentation.md#_snippet_21 LANGUAGE: python CODE: ``` from abbyy_document_ai import DocumentAi import os with DocumentAi( api_key_auth=os.getenv("DOCUMENTAI_API_KEY_AUTH", ""), ) as document_ai: res = document_ai.models.utility_bill.begin_field_extraction(request={ "input_source": { "url": "https://example.com/documents/utility_bill.png", }, }) assert res.documents is not None # Handle response print(res.documents) ``` ---------------------------------------- TITLE: Get Bill Of Lading Extracted Fields using ABBYY Document AI Python SDK DESCRIPTION: This Python snippet retrieves the extracted fields for a specific bill of lading document using the ABBYY Document AI SDK. It initializes the client with an API key and calls the `get_extracted_fields` method on the `bill_of_lading` model, asserting the response and printing the extracted data. SOURCE: https://github.com/sarvottam-bhagat/abbyy-documentation/blob/main/api documentation.md#_snippet_36 LANGUAGE: python CODE: ``` from abbyy_document_ai import DocumentAi import os with DocumentAi( api_key_auth=os.getenv("DOCUMENTAI_API_KEY_AUTH", ""), ) as document_ai: res = document_ai.models.bill_of_lading.get_extracted_fields(document_id="wh23anb5xjf0ntw5taase5qz") assert res.bill_of_lading is not None # Handle response print(res.bill_of_lading) ``` ---------------------------------------- TITLE: Perform Asynchronous Document Listing with ABBYY Document AI SDK DESCRIPTION: Demonstrates how to use the `DocumentAi` SDK asynchronously to list documents, including handling pagination. It initializes the client with an API key from an environment variable and iterates through results using `list_async`. SOURCE: https://github.com/sarvottam-bhagat/abbyy-documentation/blob/main/python.md#_snippet_5 LANGUAGE: python CODE: ``` from abbyy_document_ai import DocumentAi import asyncio import os async def main(): async with DocumentAi( api_key_auth=os.getenv("DOCUMENTAI_API_KEY_AUTH", ""), ) as document_ai: res = await document_ai.documents.list_async(cursor="") while res is not None: # Handle items res = res.next() asyncio.run(main()) ``` ---------------------------------------- TITLE: Get Extracted Fields for Hotel Invoices using ABBYY Document AI SDK DESCRIPTION: This Python snippet demonstrates how to retrieve previously extracted fields for a specific hotel invoice document using the ABBYY Document AI SDK. It initializes the DocumentAi client with an API key and then calls the `get_extracted_fields` method on the hotel invoice model, asserting that the hotel invoice data is not None. SOURCE: https://github.com/sarvottam-bhagat/abbyy-documentation/blob/main/api documentation.md#_snippet_18 LANGUAGE: python CODE: ``` from abbyy_document_ai import DocumentAi import os with DocumentAi( api_key_auth=os.getenv("DOCUMENTAI_API_KEY_AUTH", ""), ) as document_ai: res = document_ai.models.hotel_invoice.get_extracted_fields(document_id="wh23anb5xjf0ntw5taase5qz") assert res.hotel_invoice is not None # Handle response print(res.hotel_invoice) ``` ---------------------------------------- TITLE: Start Customs Declaration Field Extraction with ABBYY Document AI Python SDK DESCRIPTION: This code initiates the field extraction process for a customs declaration document from a specified URL. It sets up the Document AI client using an API key and then invokes the `begin_field_extraction` method, providing the document's URL as input. The response, containing document processing details, is then printed. SOURCE: https://github.com/sarvottam-bhagat/abbyy-documentation/blob/main/api documentation.md#_snippet_43 LANGUAGE: python CODE: ``` from abbyy_document_ai import DocumentAi import os with DocumentAi( api_key_auth=os.getenv("DOCUMENTAI_API_KEY_AUTH", ""), ) as document_ai: res = document_ai.models.customs_declaration.begin_field_extraction(request={ "input_source": { "url": "https://example.com/documents/customs_declaration.png", }, }) assert res.documents is not None # Handle response print(res.documents) ``` ---------------------------------------- TITLE: Get Air Waybill Extracted Fields using ABBYY Document AI Python SDK DESCRIPTION: This Python snippet retrieves the extracted fields for a specific air waybill document using the ABBYY Document AI SDK. It initializes the client with an API key and calls the `get_extracted_fields` method on the `air_waybill` model, asserting the response and printing the extracted data. SOURCE: https://github.com/sarvottam-bhagat/abbyy-documentation/blob/main/api documentation.md#_snippet_32 LANGUAGE: python CODE: ``` from abbyy_document_ai import DocumentAi import os with DocumentAi( api_key_auth=os.getenv("DOCUMENTAI_API_KEY_AUTH", ""), ) as document_ai: res = document_ai.models.air_waybill.get_extracted_fields(document_id="wh23anb5xjf0ntw5taase5qz") assert res.air_waybill is not None # Handle response print(res.air_waybill) ``` ---------------------------------------- TITLE: Retrieve Document Conversion Status with ABBYY Document AI Python SDK DESCRIPTION: This example demonstrates how to retrieve the status and results of a previously initiated document conversion using its document ID. It queries the `get_conversion` method to check the progress and obtain the conversion results, which can then be processed or downloaded. SOURCE: https://github.com/sarvottam-bhagat/abbyy-documentation/blob/main/api documentation.md#_snippet_3 LANGUAGE: python CODE: ``` from abbyy_document_ai import DocumentAi import os with DocumentAi( api_key_auth=os.getenv("DOCUMENTAI_API_KEY_AUTH", ""), ) as document_ai: res = document_ai.models.document_conversion.get_conversion(document_id="wh23anb5xjf0ntw5taase5qz") assert res.conversion_results is not None # Handle response print(res.conversion_results) ``` ---------------------------------------- TITLE: Start Dangerous Goods Declaration Field Extraction with ABBYY Document AI Python SDK DESCRIPTION: This code initiates the field extraction process for a dangerous goods declaration document from a specified URL. It sets up the Document AI client using an API key and then invokes the `begin_field_extraction` method, providing the document's URL as input. The response, containing document processing details, is then printed. SOURCE: https://github.com/sarvottam-bhagat/abbyy-documentation/blob/main/api documentation.md#_snippet_41 LANGUAGE: python CODE: ``` from abbyy_document_ai import DocumentAi import os with DocumentAi( api_key_auth=os.getenv("DOCUMENTAI_API_KEY_AUTH", ""), ) as document_ai: res = document_ai.models.dangerous_goods_declaration.begin_field_extraction(request={ "input_source": { "url": "https://example.com/documents/dangerous_goods_declaration.png", }, }) assert res.documents is not None # Handle response print(res.documents) ``` ---------------------------------------- TITLE: List Documents with ABBYY Document AI Python SDK and Error Handling DESCRIPTION: This snippet demonstrates how to initialize the ABBYY Document AI SDK, list documents using pagination, and implement robust error handling for various API exceptions such as BadRequestError, UnauthorizedError, TooManyRequestsError, InternalServerError, and a generic APIError. SOURCE: https://github.com/sarvottam-bhagat/abbyy-documentation/blob/main/python.md#_snippet_11 LANGUAGE: python CODE: ``` from abbyy_document_ai import DocumentAi, models import os with DocumentAi( api_key_auth=os.getenv("DOCUMENTAI_API_KEY_AUTH", ""), ) as document_ai: res = None try: res = document_ai.documents.list(cursor="") while res is not None: # Handle items res = res.next() except models.BadRequestError as e: # handle e.data: models.BadRequestErrorData raise(e) except models.UnauthorizedError as e: # handle e.data: models.UnauthorizedErrorData raise(e) except models.TooManyRequestsError as e: # handle e.data: models.TooManyRequestsErrorData raise(e) except models.InternalServerError as e: # handle e.data: models.InternalServerErrorData raise(e) except models.APIError as e: # handle exception raise(e) ``` ---------------------------------------- TITLE: Retrieve Extracted Text with ABBYY Document AI Python SDK DESCRIPTION: This example demonstrates how to retrieve the text extracted from an image after an image-to-text extraction process has completed. It uses the document ID to fetch the results, providing access to the recognized text content. SOURCE: https://github.com/sarvottam-bhagat/abbyy-documentation/blob/main/api documentation.md#_snippet_6 LANGUAGE: python CODE: ``` from abbyy_document_ai import DocumentAi import os with DocumentAi( api_key_auth=os.getenv("DOCUMENTAI_API_KEY_AUTH", ""), ) as document_ai: res = document_ai.models.image_to_text.get_extracted_text(document_id="wh23anb5xjf0ntw5taase5qz") assert res.extracted_text is not None # Handle response print(res.extracted_text) ``` ---------------------------------------- TITLE: Get Certificate Of Origin Extracted Fields using ABBYY Document AI Python SDK DESCRIPTION: This Python snippet retrieves the extracted fields for a specific certificate of origin document using the ABBYY Document AI SDK. It initializes the client with an API key and calls the `get_extracted_fields` method on the `certificate_of_origin` model, asserting the response and printing the extracted data. SOURCE: https://github.com/sarvottam-bhagat/abbyy-documentation/blob/main/api documentation.md#_snippet_38 LANGUAGE: python CODE: ``` from abbyy_document_ai import DocumentAi import os with DocumentAi( api_key_auth=os.getenv("DOCUMENTAI_API_KEY_AUTH", ""), ) as document_ai: res = document_ai.models.certificate_of_origin.get_extracted_fields(document_id="wh23anb5xjf0ntw5taase5qz") assert res.certificate_of_origin is not None # Handle response print(res.certificate_of_origin) ``` ---------------------------------------- TITLE: Get Bank Statement Extracted Fields using ABBYY Document AI Python SDK DESCRIPTION: This Python snippet demonstrates how to retrieve previously extracted fields for a bank statement using the ABBYY Document AI SDK. It initializes the client with an API key and then calls the `get_extracted_fields` method on the `bank_statement` model, asserting the response and printing the extracted data. SOURCE: https://github.com/sarvottam-bhagat/abbyy-documentation/blob/main/api documentation.md#_snippet_30 LANGUAGE: python CODE: ``` from abbyy_document_ai import DocumentAi import os with DocumentAi( api_key_auth=os.getenv("DOCUMENTAI_API_KEY_AUTH", ""), ) as document_ai: res = document_ai.models.bank_statement.get_extracted_fields(document_id="wh23anb5xjf0ntw5taase5qz") assert res.bank_statement is not None # Handle response print(res.bank_statement) ``` ---------------------------------------- TITLE: Get Extracted Fields for Purchase Orders using ABBYY Document AI SDK DESCRIPTION: This Python snippet demonstrates how to retrieve previously extracted fields for a specific purchase order document using the ABBYY Document AI SDK. It initializes the DocumentAi client with an API key and then calls the `get_extracted_fields` method on the purchase order model, asserting that the purchase order data is not None. SOURCE: https://github.com/sarvottam-bhagat/abbyy-documentation/blob/main/api documentation.md#_snippet_12 LANGUAGE: python CODE: ``` from abbyy_document_ai import DocumentAi import os with DocumentAi( api_key_auth=os.getenv("DOCUMENTAI_API_KEY_AUTH", ""), ) as document_ai: res = document_ai.models.purchase_order.get_extracted_fields(document_id="wh23anb5xjf0ntw5taase5qz") assert res.purchase_order is not None # Handle response print(res.purchase_order) ``` ---------------------------------------- TITLE: Process Remittance Advice Documents with Python SDK DESCRIPTION: This Python snippet demonstrates how to use the ABBYY Document AI SDK to initiate field extraction from a remittance advice document via a URL. It then polls the API periodically until the document processing is complete, and finally prints the extracted fields. Replace 'YOUR_API_KEY' with your actual API key. SOURCE: https://github.com/sarvottam-bhagat/abbyy-documentation/blob/main/model/Accounts Payable/Remittance Advice.md#_snippet_0 LANGUAGE: python CODE: ``` from abbyy_document_ai import DocumentAi import time with DocumentAi(api_key_auth=YOUR_API_KEY) as document_ai: res = document_ai.models.remittance_advice.begin_field_extraction(input_source={ "url": "https://example.com/document.pdf", }) assert res.documents is not None doc_id = res.documents[0].id processed = False while not processed: time.sleep(3) # Wait 3 seconds between checks res = document_ai.models.remittance_advice.get_extracted_fields( document_id=doc_id ) processed = res.remittance_advice.meta.status == "Processed" print(res.remittance_advice.fields) ``` ---------------------------------------- TITLE: Get Basic Contract Fields DESCRIPTION: This Python snippet shows how to retrieve the results of a previously initiated field extraction for a Basic Contract. It uses the document ID to fetch the processed data from the ABBYY Document AI service and prints the extracted contract information. SOURCE: https://github.com/sarvottam-bhagat/abbyy-documentation/blob/main/api documentation.md#_snippet_52 LANGUAGE: python CODE: ``` from abbyy_document_ai import DocumentAi import os with DocumentAi( api_key_auth=os.getenv("DOCUMENTAI_API_KEY_AUTH", ""), ) as document_ai: res = document_ai.models.basic_contract.get_extracted_fields(document_id="wh23anb5xjf0ntw5taase5qz") assert res.basic_contract is not None # Handle response print(res.basic_contract) ``` ---------------------------------------- TITLE: Begin Document Conversion with ABBYY Document AI Python SDK DESCRIPTION: This snippet initiates a document conversion process using the ABBYY Document AI Python SDK. It specifies an input document via a URL and defines the desired output format, such as PDF. The response contains information about the newly created converted document. SOURCE: https://github.com/sarvottam-bhagat/abbyy-documentation/blob/main/api documentation.md#_snippet_2 LANGUAGE: python CODE: ``` import abbyy_document_ai from abbyy_document_ai import DocumentAi import os with DocumentAi( api_key_auth=os.getenv("DOCUMENTAI_API_KEY_AUTH", ""), ) as document_ai: res = document_ai.models.document_conversion.begin_conversion(request={ "input_source": { "url": "https://example.com/documents/invoice.png", }, "options": { "format_": abbyy_document_ai.DocumentConversionOutputFormat.PDF, }, }) assert res.documents is not None # Handle response print(res.documents) ``` ---------------------------------------- TITLE: Begin Bill Of Lading Field Extraction using ABBYY Document AI Python SDK DESCRIPTION: This Python snippet initiates the field extraction process for a bill of lading using the ABBYY Document AI SDK. It configures the client with an API key and sends a request with the URL of the bill of lading image to the `begin_field_extraction` method, asserting the response and printing the document details. SOURCE: https://github.com/sarvottam-bhagat/abbyy-documentation/blob/main/api documentation.md#_snippet_35 LANGUAGE: python CODE: ``` from abbyy_document_ai import DocumentAi import os with DocumentAi( api_key_auth=os.getenv("DOCUMENTAI_API_KEY_AUTH", ""), ) as document_ai: res = document_ai.models.bill_of_lading.begin_field_extraction(request={ "input_source": { "url": "https://example.com/documents/bill_of_lading.png", }, }) assert res.documents is not None # Handle response print(res.documents) ``` ---------------------------------------- TITLE: Begin Commercial Invoice Field Extraction using ABBYY Document AI Python SDK DESCRIPTION: This Python snippet initiates the field extraction process for a commercial invoice using the ABBYY Document AI SDK. It configures the client with an API key and sends a request with the URL of the commercial invoice image to the `begin_field_extraction` method, asserting the response and printing the document details. SOURCE: https://github.com/sarvottam-bhagat/abbyy-documentation/blob/main/api documentation.md#_snippet_39 LANGUAGE: python CODE: ``` from abbyy_document_ai import DocumentAi import os with DocumentAi( api_key_auth=os.getenv("DOCUMENTAI_API_KEY_AUTH", ""), ) as document_ai: res = document_ai.models.commercial_invoice.begin_field_extraction(request={ "input_source": { "url": "https://example.com/documents/commercial_invoice.png", }, }) assert res.documents is not None # Handle response print(res.documents) ``` ---------------------------------------- TITLE: Retrieve Extracted Fields for Utility Bills using Python SDK DESCRIPTION: This Python snippet demonstrates how to retrieve previously extracted fields for a utility bill document using the ABBYY Document AI SDK. It initializes the SDK with an API key and then calls the `get_extracted_fields` method for a specific document ID. SOURCE: https://github.com/sarvottam-bhagat/abbyy-documentation/blob/main/api documentation.md#_snippet_22 LANGUAGE: python CODE: ``` from abbyy_document_ai import DocumentAi import os with DocumentAi( api_key_auth=os.getenv("DOCUMENTAI_API_KEY_AUTH", ""), ) as document_ai: res = document_ai.models.utility_bill.get_extracted_fields(document_id="wh23anb5xjf0ntw5taase5qz") assert res.utility_bill is not None # Handle response print(res.utility_bill) ``` ---------------------------------------- TITLE: Authenticate and List Documents Synchronously with ABBYY Document AI SDK DESCRIPTION: Illustrates synchronous authentication and document listing using the `DocumentAi` SDK. The API key is loaded from an environment variable, and the `documents.list` method is called to retrieve and paginate through document results. SOURCE: https://github.com/sarvottam-bhagat/abbyy-documentation/blob/main/python.md#_snippet_6 LANGUAGE: python CODE: ``` from abbyy_document_ai import DocumentAi import os with DocumentAi( api_key_auth=os.getenv("DOCUMENTAI_API_KEY_AUTH", ""), ) as document_ai: res = document_ai.documents.list(cursor="") while res is not None: # Handle items res = res.next() ``` ---------------------------------------- TITLE: Begin Arrival Notice Field Extraction using ABBYY Document AI Python SDK DESCRIPTION: This Python snippet initiates the field extraction process for an arrival notice using the ABBYY Document AI SDK. It configures the client with an API key and sends a request with the URL of the arrival notice image to the `begin_field_extraction` method, asserting the response and printing the document details. SOURCE: https://github.com/sarvottam-bhagat/abbyy-documentation/blob/main/api documentation.md#_snippet_33 LANGUAGE: python CODE: ``` from abbyy_document_ai import DocumentAi import os with DocumentAi( api_key_auth=os.getenv("DOCUMENTAI_API_KEY_AUTH", ""), ) as document_ai: res = document_ai.models.arrival_notice.begin_field_extraction(request={ "input_source": { "url": "https://example.com/documents/arrival_notice.png", }, }) assert res.documents is not None # Handle response print(res.documents) ``` ---------------------------------------- TITLE: Wrap Custom HTTP Client for ABBYY Document AI Python SDK DESCRIPTION: This advanced example demonstrates how to create a custom HTTP client class that wraps an existing `AsyncHttpClient` to inject custom logic, such as modifying request headers before sending. It shows how to implement the `send` method to intercept and modify requests, providing fine-grained control over network operations. SOURCE: https://github.com/sarvottam-bhagat/abbyy-documentation/blob/main/python.md#_snippet_14 LANGUAGE: python CODE: ``` from abbyy_document_ai import DocumentAi from abbyy_document_ai.httpclient import AsyncHttpClient import httpx class CustomClient(AsyncHttpClient): client: AsyncHttpClient def __init__(self, client: AsyncHttpClient): self.client = client async def send( self, request: httpx.Request, *, stream: bool = False, auth: Union[ httpx._types.AuthTypes, httpx._client.UseClientDefault, None ] = httpx.USE_CLIENT_DEFAULT, follow_redirects: Union[ bool, httpx._client.UseClientDefault ] = httpx.USE_CLIENT_DEFAULT, ) -> httpx.Response: request.headers["Client-Level-Header"] = "added by client" return await self.client.send( request, stream=stream, auth=auth, follow_redirects=follow_redirects ) def build_request( self, method: str, url: httpx._types.URLTypes, *, content: Optional[httpx._types.RequestContent] = None, data: Optional[httpx._types.RequestData] = None, files: Optional[httpx._types.RequestFiles] = None, json: Optional[Any] = None, params: Optional[httpx._types.QueryParamTypes] = None, headers: Optional[httpx._types.HeaderTypes] = None, cookies: Optional[httpx._types.CookieTypes] = None, timeout: Union[ httpx._types.TimeoutTypes, httpx._client.UseClientDefault ] = httpx.USE_CLIENT_DEFAULT, extensions: Optional[httpx._types.RequestExtensions] = None, ) -> httpx.Request: ```