Can I analyze multiple documents using form recognizer sdk or rest api?

f-ang 31 Reputation points
2022-09-19T23:22:37.567+00:00

Is there a way to analyze multiple documents with form recognizer rest api or sdk?
(Asking this because I believe I need to specify the document url...)
Thanks.

Azure AI Document Intelligence
Azure AI Document Intelligence
An Azure service that turns documents into usable data. Previously known as Azure Form Recognizer.
1,924 questions
{count} votes

1 answer

Sort by: Most helpful
  1. romungi-MSFT 48,541 Reputation points Microsoft Employee
    2022-09-20T08:36:04.023+00:00

    @f-ang If you are looking to analyze multiple documents in a single request, then it is currently not possible to pass multiple URLs in a single request. You can however use the SDK and REST API to pass the base64source of a local image using the FR SDK client. You can refer this thread I answered recently on how to use the REST API with the base64source.
    For the SDK there are several examples on using the analyze operation with local images in this repo. You can loop through images in a local directory and pass them in every request to get the response by polling and printing the result.

    For example:

     from azure.core.credentials import AzureKeyCredential  
     from azure.ai.formrecognizer import DocumentAnalysisClient  
      
      
    endpoint = "AZURE_FORM_RECOGNIZER_ENDPOINT"  
    key = "AZURE_FORM_RECOGNIZER_KEY"  
      
    document_analysis_client = DocumentAnalysisClient(endpoint=endpoint, credential=AzureKeyCredential(key))  
      
    path_to_sample_documents = <path to document>  
      
    with open(path_to_sample_documents, "rb") as f:  
            poller = document_analysis_client.begin_analyze_document(  
                "prebuilt-layout", document=f  
            )  
    result = poller.result()  
    

    If an answer is helpful, please click on 130616-image.png or upvote 130671-image.png which might help other community members reading this thread.

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.