Document extraction

更新时间:
复制 MD 格式

This document describes how to call the document extraction API operation. Before you begin, read the API usage guide.

Introduction

The document extraction API operation automatically extracts key information from various types of documents and tables. It returns structured content in a general key-value (KV) format.

The document extraction API operation is asynchronous. First, call the SubmitDocumentExtractJob operation to submit an asynchronous task. Then, call the GetDocumentExtractResult operation to query the result using polling. You should poll every 10 seconds for a maximum of 120 minutes. If the task is not complete after 120 minutes, the task times out.

After an asynchronous task is submitted, you can query the result within 24 hours after the task is complete. After 24 hours, the result is no longer available.

Procedure

Step 1: Call the SubmitDocumentExtractJob operation

Request parameters

Name

Type

Required

Description

Example value

FileUrl

string

Yes

The URL of a single document. The document can be a PDF file of up to 1000 pages and 100 MB, or a single image of up to 20 MB.

To upload a local file, the software development kit (SDK) provides a separate input parameter to support file stream uploads.

https://example.com/example.pdf

FileName

string

No

The file name, which must include the file extension. You must specify either this parameter or `FileNameExtension`.

example.pdf

FileNameExtension

string

No

The file extension. You must specify either this parameter or `FileName`. Supported types: pdf, jpg, jpeg, png, bmp, and gif.

pdf

OssBucket

string

No

The name of your OSS bucket. For more information, see OSS hosting support.

docmind-trust

OssEndpoint

string

No

The Endpoint of your OSS bucket. For more information, see OSS hosting support.

oss-cn-hangzhou.aliyuncs.com

Note

Supported document formats: PDF and images. Supported image formats: jpg, jpeg, png, bmp, and gif.

Response parameters

Name

Type

Description

Example

RequestId

string

The unique ID of the request.

43A29C77-405E-4CC0-BC55-EE694AD0****

Data

object

The returned data.

{"Id": "docmind-20220712-b15f****"}

Id

string

The business order ID. This is the unique identifier used to query the result with the subsequent query operation.

docmind-20220712-b15f****

Code

string

The status code.

200

Message

string

The detailed information.

Message

Examples

This operation can be called in two ways: by uploading a local file or by providing a document URL.

  • Upload a local file: The following code provides an example of how to upload a local file using the Java SDK. Call the `submitDocumentExtractJobAdvance` method and use the `fileUrlObject` parameter to upload the local file.

    Note

    For information about how to obtain and use AccessKey credentials, see the SDK usage guide for your programming language in SDK Overview.

    import com.aliyun.docmind_api20220711.models.*;
    import com.aliyun.teaopenapi.models.Config;
    import com.aliyun.docmind_api20220711.Client;
    import com.aliyun.teautil.models.RuntimeOptions;
    import java.io.File;
    import java.io.FileInputStream;
    
    public static void submit() throws Exception {
        // Initialize the Credentials client using the default credential.
        com.aliyun.credentials.Client credentialClient = new com.aliyun.credentials.Client();
        Config config = new Config()
            // Obtain the AccessKey ID from the credentials.
            .setAccessKeyId(credentialClient.getAccessKeyId())
            // Obtain the AccessKey secret from the credentials.
            .setAccessKeySecret(credentialClient.getAccessKeySecret());
        // The endpoint. Both IPv4 and IPv6 are supported. For IPv6, use docmind-api-dualstack.cn-hangzhou.aliyuncs.com.
        config.endpoint = "docmind-api.cn-hangzhou.aliyuncs.com";
        Client client = new Client(config);
        // Create a RuntimeObject instance and set runtime parameters.
        RuntimeOptions runtime = new RuntimeOptions();
        SubmitDocumentExtractJobAdvanceRequest advanceRequest = new SubmitDocumentExtractJobAdvanceRequest();
        File file = new File("D:\\example.pdf");
        advanceRequest.fileUrlObject = new FileInputStream(file);
        advanceRequest.fileName = "example.pdf";
        // Send the request and handle the response or exceptions.
        SubmitDocumentExtractJobResponse response = client.submitDocumentExtractJobAdvance(advanceRequest, runtime);
    }
    const Client = require('@alicloud/docmind-api20220711');
    const Credential = require('@alicloud/credentials');
    const Util = require('@alicloud/tea-util');
    const fs = require('fs');
    
    const getResult = async () => {
      // Initialize the Credentials client using the default credential.
      const cred = new Credential.default();
      const client = new Client.default({
        // The endpoint. Both IPv4 and IPv6 are supported. For IPv6, use docmind-api-dualstack.cn-hangzhou.aliyuncs.com.
        endpoint: 'docmind-api.cn-hangzhou.aliyuncs.com',
        // Obtain the AccessKey ID from the credentials.
        accessKeyId: cred.credential.accessKeyId,
        // Obtain the AccessKey secret from the credentials.
        accessKeySecret: cred.credential.accessKeySecret,
        type: 'access_key',
        regionId: 'cn-hangzhou',
      });
      
      const advanceRequest = new Client.SubmitDocumentExtractJobAdvanceRequest();
      const file = fs.createReadStream('./example.pdf');
      advanceRequest.fileUrlObject = file;
      advanceRequest.fileName = 'example.pdf';
      const runtimeObject = new Util.RuntimeOptions({});
      const response = await client.submitDocumentExtractJobAdvance(advanceRequest, runtimeObject);
    	return response.body;
    }
    from alibabacloud_docmind_api20220711.client import Client as docmind_api20220711Client
    from alibabacloud_tea_openapi import models as open_api_models
    from alibabacloud_docmind_api20220711 import models as docmind_api20220711_models
    from alibabacloud_tea_util.client import Client as UtilClient
    from alibabacloud_credentials.client import Client as CredClient
    
    def submit_file():
        cred=CredClient()
        config = open_api_models.Config(
            # Obtain the AccessKey ID from the credentials.
            access_key_id=cred.get_access_key_id(),
            # Obtain the AccessKey secret from the credentials.
            access_key_secret=cred.get_access_key_secret()
        )
        # The endpoint.
        config.endpoint = f'docmind-api.cn-hangzhou.aliyuncs.com'
        client = docmind_api20220711Client(config)
        request = docmind_api20220711_models.SubmitDocumentExtractJobAdvanceRequest(
            # file_url_object: The local file stream.
            file_url_object=open("./example.pdf", "rb"),
            # file_name: The file name. The name must include the file extension.
            file_name='123.pdf',
            # file_name_extension: The file extension. You must specify either this parameter or file_name.
            file_name_extension='pdf'
        )
        runtime = util_models.RuntimeOptions()
        try:
            # If you copy the code to run, print the API return value.
            response = client.submit_document_extract_job_advance(request, runtime)
            # The API return value format is body -> data -> specific property. You can print the results as needed. The following example shows how to print the returned business ID.
            # Property values start with a lowercase letter.
            print(response.body.data.id)        
        except Exception as error:
            # If an error occurs, print the error message.
            UtilClient.assert_as_string(error.message)
    import (
    	"fmt"
    	"os"
      
    	openClient "github.com/alibabacloud-go/darabonba-openapi/v2/client"
    	"github.com/alibabacloud-go/docmind-api-20220711/client"
    	"github.com/alibabacloud-go/tea-utils/v2/service"
      "github.com/aliyun/credentials-go/credentials"
    )
    
    func submit(){
      // Initialize the Credentials client using the default credential.
    	credential, err := credentials.NewCredential(nil)
    	// Obtain the AccessKey ID from the credentials.
    	accessKeyId, err := credential.GetAccessKeyId()
    	// Obtain the AccessKey secret from the credentials.
    	accessKeySecret, err := credential.GetAccessKeySecret()
      // The endpoint. Both IPv4 and IPv6 are supported. For IPv6, use docmind-api-dualstack.cn-hangzhou.aliyuncs.com.
      var endpoint string = "docmind-api.cn-hangzhou.aliyuncs.com"
    	config := openClient.Config{AccessKeyId: accessKeyId, AccessKeySecret: accessKeySecret, Endpoint: &endpoint}
      // Initialize the client.
      cli, err := client.NewClient(&config)
    	if err != nil {
    		panic(err)
    	}
      // Call the operation to upload a local file.
      filename := "D:\\example.pdf"    
      f, err := os.Open(filename)
    	if err != nil {
        panic(err)
    	}
      // Initialize the request for the operation.
      request := client.SubmitDocumentExtractJobAdvanceRequest{
    		FileName:      &filename,
    		FileUrlObject: f,
    	}
      // Create a RuntimeObject instance and set runtime parameters.
      options := service.RuntimeOptions{}
      response, err := cli.SubmitDocumentExtractJobAdvance(&request, &options)
      if err != nil {
    		panic(err)
    	}
      // Print the result.
    	fmt.Println(response.Body.String())
    }
    using Newtonsoft.Json;
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.IO;
    using System.Threading.Tasks;
    
    using Tea;
    using Tea.Utils;
    
    public static void SubmitFile()
            {
                // Initialize the Credentials client using the default credential.
              	var akCredential = new Aliyun.Credentials.Client(null);
                AlibabaCloud.OpenApiClient.Models.Config config = new AlibabaCloud.OpenApiClient.Models.Config
                {
                    // Obtain the AccessKey secret from the credentials.
                    AccessKeyId = akCredential.GetAccessKeyId(),
                    // Obtain the AccessKey secret from the credentials.
                    AccessKeySecret = akCredential.GetAccessKeySecret(),
                };
                // The endpoint.
                config.Endpoint = "docmind-api.cn-hangzhou.aliyuncs.com";
                // You must install the AlibabaCloud.DarabonbaStream dependency library.
                AlibabaCloud.SDK.Docmind_api20220711.Client client = new AlibabaCloud.SDK.Docmind_api20220711.Client(config);
                Stream bodySyream = AlibabaCloud.DarabonbaStream.StreamUtil.ReadFromFilePath("<YOUR-FILE-PATH>");
                AlibabaCloud.SDK.Docmind_api20220711.Models.SubmitDocumentExtractJobAdvanceRequest request = new AlibabaCloud.SDK.Docmind_api20220711.Models.SubmitDocumentExtractJobAdvanceRequest
                {
                    FileUrlObject = bodySyream,
                    FileNameExtension = "pdf"
                };
                AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime = new AlibabaCloud.TeaUtil.Models.RuntimeOptions();
                try
                {
                    // If you copy the code to run, print the API return value.
                    client.SubmitDocumentExtractJobAdvance(request, runtime);
                }
                catch (TeaException error)
                {
                    // If an error occurs, print the error message.
                    AlibabaCloud.TeaUtil.Common.AssertAsString(error.Message);
                }
                catch (Exception _error)
                {
                    TeaException error = new TeaException(new Dictionary<string, object>
                    {
                        { "message", _error.Message }
                    });
                    // If an error occurs, print the error message.
                    AlibabaCloud.TeaUtil.Common.AssertAsString(error.Message);
                }
            }
  • Provide a document URL: The following code provides an example of how to provide a document URL using the Java SDK. Call the `submitDocumentExtractJob` method and use the `fileUrl` parameter to specify the document URL. The URL must be publicly accessible for download over the internet. The URL must not have cross-domain restrictions or contain special escape characters.

    Note

    For information about how to obtain and use AccessKey credentials, see the SDK usage guide for your programming language in SDK Overview.

    import com.aliyun.docmind_api20220711.models.*;
    import com.aliyun.teaopenapi.models.Config;
    import com.aliyun.docmind_api20220711.Client;
    
    public static void submit() throws Exception {
        // Initialize the Credentials client using the default credential.
        com.aliyun.credentials.Client credentialClient = new com.aliyun.credentials.Client();
        Config config = new Config()
            // Obtain the AccessKey ID from the credentials.
            .setAccessKeyId(credentialClient.getAccessKeyId())
            // Obtain the AccessKey secret from the credentials.
            .setAccessKeySecret(credentialClient.getAccessKeySecret());
        // The endpoint. Both IPv4 and IPv6 are supported. For IPv6, use docmind-api-dualstack.cn-hangzhou.aliyuncs.com.
        config.endpoint = "docmind-api.cn-hangzhou.aliyuncs.com";
        Client client = new Client(config);
        // Replace the request parameters and method with those of the specific asynchronous task submission API operation.
        SubmitDocumentExtractJobRequest request = new SubmitDocumentExtractJobRequest();
        request.fileName = "example.pdf";
        request.fileUrl = "https://example.com/example.pdf";
        SubmitDocumentExtractJobResponse response = client.submitDocumentExtractJob(request);
    }
    const Client = require('@alicloud/docmind-api20220711');
    const Credential = require('@alicloud/credentials');
    
    const getResult = async () => {
      // Initialize the Credentials client using the default credential.
      const cred = new Credential.default();
      const client = new Client.default({
        // The endpoint. Both IPv4 and IPv6 are supported. For IPv6, use docmind-api-dualstack.cn-hangzhou.aliyuncs.com.
        endpoint: 'docmind-api.cn-hangzhou.aliyuncs.com',
        // Obtain the AccessKey ID from the credentials.
        accessKeyId: cred.credential.accessKeyId,
        // Obtain the AccessKey secret from the credentials.
        accessKeySecret: cred.credential.accessKeySecret,
        type: 'access_key',
        regionId: 'cn-hangzhou'
      });
      
      const request = new Client.SubmitDocumentExtractJobRequest();
      request.fileName = 'example.pdf';
      request.fileUrl = 'https://example.com/example.pdf';
      const response = await client.submitDocumentExtractJob(request);
      
      return response.body;
    }
    from alibabacloud_docmind_api20220711.client import Client as docmind_api20220711Client
    from alibabacloud_tea_openapi import models as open_api_models
    from alibabacloud_docmind_api20220711 import models as docmind_api20220711_models
    from alibabacloud_tea_util.client import Client as UtilClient
    from alibabacloud_credentials.client import Client as CredClient
    
    
    def submit_url():
        cred=CredClient()
        config = open_api_models.Config(
            # Obtain the AccessKey ID from the credentials.
            access_key_id=cred.get_access_key_id(),
            # Obtain the AccessKey secret from the credentials.
            access_key_secret=cred.get_access_key_secret()
        )
        # The endpoint.
        config.endpoint = f'docmind-api.cn-hangzhou.aliyuncs.com'
        client = docmind_api20220711Client(config)
        request = docmind_api20220711_models.SubmitDocumentExtractJobRequest(
            # file_url: The file URL.
            file_url='https://example.com/example.pdf',
            # file_name: The file name. The name must include the file extension.
            file_name='123.pdf',
            # file_name_extension: The file extension. You must specify either this parameter or file_name.
            file_name_extension='pdf'
        )
        try:
            # If you copy the code to run, print the API return value.
            response = client.submit_document_extract_job(request)
            # The API return value format is body -> data -> specific property. You can print the results as needed. The following example shows how to print the returned business ID.
            # Property values start with a lowercase letter.
            print(response.body.data.id)       
        except Exception as error:
            # If an error occurs, print the error message.
            UtilClient.assert_as_string(error.message)
    import (
    	"fmt"
    
    	openClient "github.com/alibabacloud-go/darabonba-openapi/v2/client"
      "github.com/alibabacloud-go/docmind-api-20220711/client"
      "github.com/aliyun/credentials-go/credentials"
    )
    
    func submit(){
      // Initialize the Credentials client using the default credential.
    	credential, err := credentials.NewCredential(nil)
    	// Obtain the AccessKey ID from the credentials.
    	accessKeyId, err := credential.GetAccessKeyId()
    	// Obtain the AccessKey secret from the credentials.
    	accessKeySecret, err := credential.GetAccessKeySecret()
      // The endpoint. Both IPv4 and IPv6 are supported. For IPv6, use docmind-api-dualstack.cn-hangzhou.aliyuncs.com.
      var endpoint string = "docmind-api.cn-hangzhou.aliyuncs.com"
    	config := openClient.Config{AccessKeyId: accessKeyId, AccessKeySecret: accessKeySecret, Endpoint: &endpoint}
      // Initialize the client.
      cli, err := client.NewClient(&config)
    	if err != nil {
    		panic(err)
    	}
      // The file URL.
      fileURL := "https://example.com/example.pdf"
      // The file name.
      fileName := "example.pdf"
      // Initialize the request for the operation.
      request := client.SubmitDocumentExtractJobRequest{
    		FileUrl:  &fileURL,
    		FileName: &fileName,
    	}
      response, err := cli.SubmitDocumentExtractJob(&request)
      if err != nil {
    		panic(err)
    	}
      // Print the result.
    	fmt.Println(response.Body.String())
    }
    using Newtonsoft.Json;
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.IO;
    using System.Threading.Tasks;
    
    using Tea;
    using Tea.Utils;
    
    public static void SubmitUrl()
            {
                // Initialize the Credentials client using the default credential.
              	var akCredential = new Aliyun.Credentials.Client(null);
                AlibabaCloud.OpenApiClient.Models.Config config = new AlibabaCloud.OpenApiClient.Models.Config
                {
                    // Obtain the AccessKey secret from the credentials.
                    AccessKeyId = akCredential.GetAccessKeyId(),
                    // Obtain the AccessKey secret from the credentials.
                    AccessKeySecret = akCredential.GetAccessKeySecret(),
                };
                // The endpoint.
                config.Endpoint = "docmind-api.cn-hangzhou.aliyuncs.com";
                AlibabaCloud.SDK.Docmind_api20220711.Client client = new AlibabaCloud.SDK.Docmind_api20220711.Client(config);
                AlibabaCloud.SDK.Docmind_api20220711.Models.SubmitDocumentExtractJobRequest request = new AlibabaCloud.SDK.Docmind_api20220711.Models.SubmitDocumentExtractJobRequest
                {
                    FileUrl = "https://example.pdf",
                    FileNameExtension = "pdf"
                };
                try
                {
                    // If you copy the code to run, print the API return value.
                    client.SubmitDocumentExtractJob(request);
                }
                catch (TeaException error)
                {
                    // If an error occurs, print the error message.
                    AlibabaCloud.TeaUtil.Common.AssertAsString(error.Message);
                }
                catch (Exception _error)
                {
                    TeaException error = new TeaException(new Dictionary<string, object>
                    {
                        { "message", _error.Message }
                    });
                    // If an error occurs, print the error message.
                    AlibabaCloud.TeaUtil.Common.AssertAsString(error.Message);
                }
            }
    use AlibabaCloud\SDK\Docmindapi\V20220711\Docmindapi;
    use AlibabaCloud\SDK\Docmindapi\V20220711\Models\SubmitDocumentExtractJobRequest;
    use Darabonba\OpenApi\Models\Config;
    use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
    use AlibabaCloud\Tea\Exception\TeaUnableRetryError;
    use AlibabaCloud\Credentials\Credential;
    
    // Initialize the Credentials client using the default credential.
    $bearerToken = new Credential();    
    $config = new Config();
    // The endpoint. Both IPv4 and IPv6 are supported. For IPv6, use docmind-api-dualstack.cn-hangzhou.aliyuncs.com.
    $config->endpoint = "docmind-api.cn-hangzhou.aliyuncs.com";
    // Obtain the AccessKey ID from the credentials.
    $config->accessKeyId = $bearerToken->getCredential()->getAccessKeyId();
    // Obtain the AccessKey secret from the credentials.
    $config->accessKeySecret = $bearerToken->getCredential()->getAccessKeySecret();
    $config->type = "access_key";
    $config->regionId = "cn-hangzhou";
    $client = new Docmindapi($config);
    $request = new SubmitDocumentExtractJobRequest();
    
    $runtime = new RuntimeOptions();
    $runtime->maxIdleConns = 3;
    $runtime->connectTimeout = 10000;
    $runtime->readTimeout = 10000;
    
    $request->fileName = "example.pdf";
    $request->fileUrl = "https://example.com/example.pdf";
    
    try {
      $response = $client->submitDocumentExtractJob($request, $runtime);
      var_dump($response->toMap());
    } catch (TeaUnableRetryError $e) {
      var_dump($e->getMessage());
      var_dump($e->getErrorInfo());
      var_dump($e->getLastException());
      var_dump($e->getLastRequest());
    }

The following code shows a sample success response in JSON format.

{
  "RequestId": "43A29C77-405E-4CC0-BC55-EE694AD00655",
  "Data": {
    "Id": "docmind-20220712-b15fe420"
  }  
}

Step 2: Poll for the result by calling the GetDocumentExtractResult operation

The `Id` request parameter for this query operation is the `Id` that is returned in the response from the asynchronous task submission operation. The query can return one of three results: processing, successful, or failed. You can poll for the result every 10 seconds for a maximum of 120 minutes. You can stop polling if the `Completed` parameter returns `true` or if the maximum polling time is exceeded.

Request parameters

Name

Type

Required

Description

Example

Id

string

Yes

The business order ID to query. Obtain this ID from the response of the submission operation.

docmind-20220712-b15f****

Response parameters

Name

Type

Description

Example

RequestId

string

The unique ID of the request.

43A29C77-405E-4CC0-BC55-EE694AD0****

Completed

boolean

Indicates whether the asynchronous task is complete. `false` means the task is still processing. `true` means the task is complete, with a result of either success or failure.

true

Status

string

The final status of the completed asynchronous task. `Success` indicates the task was successful. `Fail` indicates the task failed.

Success

Data

string

The returned data. The data is in a JSON structure with general key-value content.

-

Code

string

The status code.

200

Message

string

The detailed information.

Message

Example

The following code provides an example of how to query the result of a document extraction task using the Java SDK. Call the `getDocumentExtractResult` method and pass the query ID in the `Id` parameter.

Note

For information about how to obtain and use AccessKey credentials, see the SDK usage guide for your programming language in SDK Overview.

import com.aliyun.docmind_api20220711.models.*;
import com.aliyun.teaopenapi.models.Config;
import com.aliyun.docmind_api20220711.Client;

public static void submit() throws Exception {
    // Initialize the Credentials client using the default credential.
    com.aliyun.credentials.Client credentialClient = new com.aliyun.credentials.Client();
    Config config = new Config()
        // Obtain the AccessKey ID from the credentials.
        .setAccessKeyId(credentialClient.getAccessKeyId())
        // Obtain the AccessKey secret from the credentials.
        .setAccessKeySecret(credentialClient.getAccessKeySecret());
    // The endpoint. Both IPv4 and IPv6 are supported. For IPv6, use docmind-api-dualstack.cn-hangzhou.aliyuncs.com.
    config.endpoint = "docmind-api.cn-hangzhou.aliyuncs.com";
    Client client = new Client(config);
    GetDocumentExtractResultRequest resultRequest = new GetDocumentExtractResultRequest();
    resultRequest.id = "docmind-20220902-824b****";
    GetDocumentExtractResultResponse response = client.getDocumentExtractResult(resultRequest);
}
const Client = require('@alicloud/docmind-api20220711');
const Credential = require('@alicloud/credentials');

const getResult = async () => {
  // Initialize the Credentials client using the default credential.
  const cred = new Credential.default();
  const client = new Client.default({
    // The endpoint. Both IPv4 and IPv6 are supported. For IPv6, use docmind-api-dualstack.cn-hangzhou.aliyuncs.com.
    endpoint: 'docmind-api.cn-hangzhou.aliyuncs.com',
    // Obtain the AccessKey ID from the credentials.
    accessKeyId: cred.credential.accessKeyId,
    // Obtain the AccessKey secret from the credentials.
    accessKeySecret: cred.credential.accessKeySecret,
    type: 'access_key',
    regionId: 'cn-hangzhou'
  });
  
  const resultRequest = new Client.GetDocumentExtractResultRequest();
  resultRequest.id = "docmind-20220902-824b****";
  const response = await client.getDocumentExtractResult(resultRequest);
  
  return response.body;
}
from alibabacloud_docmind_api20220711.client import Client as docmind_api20220711Client
from alibabacloud_tea_openapi import models as open_api_models
from alibabacloud_docmind_api20220711 import models as docmind_api20220711_models
from alibabacloud_tea_util.client import Client as UtilClient
from alibabacloud_credentials.client import Client as CredClient

def query():
    cred=CredClient()
    config = open_api_models.Config(
        # Obtain the AccessKey ID from the credentials.
        access_key_id=cred.get_access_key_id(),
        # Obtain the AccessKey secret from the credentials.
        access_key_secret=cred.get_access_key_secret()
    )
    # The endpoint.
    config.endpoint = f'docmind-api.cn-hangzhou.aliyuncs.com'
    client = docmind_api20220711Client(config)
    request = docmind_api20220711_models.GetDocumentExtractResultRequest(
        # id: The ID returned by the task submission operation.
        id='docmind-20220902-824b****'
    )
    try:
        # If you copy the code to run, print the API return value.
        response = client.get_document_extract_result(request)
        # The API return value format is body -> data -> specific property. You can print the results as needed. Property values start with a lowercase letter.
        # Get the status of the asynchronous task. You can check response.body.completed to determine whether to continue polling for the result.
        print(response.body.completed)
        # Get the returned result. We recommend converting response.body.data to JSON first, and then retrieving the specific values you need from the JSON object.
        print(response.body.data)       
    except Exception as error:
        # If an error occurs, print the error message.
        UtilClient.assert_as_string(error.message)
        
import (
	"fmt"

	openClient "github.com/alibabacloud-go/darabonba-openapi/v2/client"
  "github.com/alibabacloud-go/docmind-api-20220711/client"
  "github.com/aliyun/credentials-go/credentials"
)

func submit(){
    // Initialize the Credentials client using the default credential.
		credential, err := credentials.NewCredential(nil)
		// Obtain the AccessKey ID from the credentials.
		accessKeyId, err := credential.GetAccessKeyId()
		// Obtain the AccessKey secret from the credentials.
		accessKeySecret, err := credential.GetAccessKeySecret()
  	// The endpoint. Both IPv4 and IPv6 are supported. For IPv6, use docmind-api-dualstack.cn-hangzhou.aliyuncs.com.
  	var endpoint string = "docmind-api.cn-hangzhou.aliyuncs.com"
		config := openClient.Config{AccessKeyId: accessKeyId, AccessKeySecret: accessKeySecret, Endpoint: &endpoint}
    // Initialize the client.
    cli, err := client.NewClient(&config)
    if err != nil {
      panic(err)
    }
    id := "docmind-20220925-76b1****"
    // Call the query operation.
    request := client.GetDocumentExtractResultRequest{Id: &id}
    response, err := cli.GetDocumentExtractResult(&request)
    if err != nil {
      panic(err)
    }
    // Print the query result.
    fmt.Println(response.Body.String())
}
using Newtonsoft.Json;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;

using Tea;
using Tea.Utils;

 public static void GetResult() 
        {
            // Initialize the Credentials client using the default credential.
          	var akCredential = new Aliyun.Credentials.Client(null);
            AlibabaCloud.OpenApiClient.Models.Config config = new AlibabaCloud.OpenApiClient.Models.Config
            {
                // Obtain the AccessKey secret from the credentials.
                AccessKeyId = akCredential.GetAccessKeyId(),
                // Obtain the AccessKey secret from the credentials.
                AccessKeySecret = akCredential.GetAccessKeySecret(),
            };
            // The endpoint.
            config.Endpoint = "docmind-api.cn-hangzhou.aliyuncs.com";
            AlibabaCloud.SDK.Docmind_api20220711.Client client = new AlibabaCloud.SDK.Docmind_api20220711.Client(config);
            AlibabaCloud.SDK.Docmind_api20220711.Models.GetDocumentExtractResultRequest request = new AlibabaCloud.SDK.Docmind_api20220711.Models.GetDocumentExtractResultRequest
            {
                Id = "docmind-20220902-824b****"
            };
            AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime = new AlibabaCloud.TeaUtil.Models.RuntimeOptions();
            try
            {
                // If you copy the code to run, print the API return value.
                client.GetDocumentExtractResult(request);
            }
            catch (TeaException error)
            {
                // If an error occurs, print the error message.
                AlibabaCloud.TeaUtil.Common.AssertAsString(error.Message);
            }
            catch (Exception _error)
            {
                TeaException error = new TeaException(new Dictionary<string, object>
                {
                    { "message", _error.Message }
                });
                // If an error occurs, print the error message.
                AlibabaCloud.TeaUtil.Common.AssertAsString(error.Message);
            }
        }
use AlibabaCloud\SDK\Docmindapi\V20220711\Docmindapi;
use AlibabaCloud\SDK\Docmindapi\V20220711\Models\GetDocumentExtractResultRequest;
use Darabonba\OpenApi\Models\Config;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
use AlibabaCloud\Tea\Exception\TeaUnableRetryError;
use AlibabaCloud\Credentials\Credential;

// Initialize the Credentials client using the default credential.
$bearerToken = new Credential();    
$config = new Config();
// The endpoint. Both IPv4 and IPv6 are supported. For IPv6, use docmind-api-dualstack.cn-hangzhou.aliyuncs.com.
$config->endpoint = "docmind-api.cn-hangzhou.aliyuncs.com";
// Obtain the AccessKey ID from the credentials.
$config->accessKeyId = $bearerToken->getCredential()->getAccessKeyId();
// Obtain the AccessKey secret from the credentials.
$config->accessKeySecret = $bearerToken->getCredential()->getAccessKeySecret();
$config->type = "access_key";
$config->regionId = "cn-hangzhou";
$client = new Docmindapi($config);
$request = new GetDocumentExtractResultRequest();   
$request->id = "docmind-20220902-824b****";

$runtime = new RuntimeOptions();
$runtime->maxIdleConns = 3;
$runtime->connectTimeout = 10000;
$runtime->readTimeout = 10000;

try {
  $response = $client->getDocumentExtractResult($request, $runtime);
  var_dump($response->toMap());
} catch (TeaUnableRetryError $e) {
  var_dump($e->getMessage());
  var_dump($e->getErrorInfo());
  var_dump($e->getLastException());
  var_dump($e->getLastRequest());
}

Query results

The query can return one of three results: processing, failed, or successful. The following sections provide sample responses for each case.

  • The results are as follows:

    {
      "RequestId": "2AABD2C2-D24F-12F7-875D-683A27C3****",
      "Completed": false,
      "Code": "DocProcessing",
      "Message": "Document processing",
      "HostId": "ocr-api.cn-hangzhou.aliyuncs.com",
      "Recommend": "https://next.api.aliyun.com/troubleshoot?q=DocProcessing&product=docmind-api"
    }

    If the task is still processing, `Completed` returns `false`. In this case, continue polling until `Completed` returns `true` or the maximum polling time is exceeded.

  • The following shows the response to a failed operation:

    {
      "RequestId": "A8EF3A36-1380-1116-A39E-B377BE27****",
      "Completed": true,
      "Status": "Fail",
      "Code": "UrlNotLegal",
      "Message": "Failed to process the document.  The document url you provided is not legal.",
      "HostId": "docmind-api.cn-hangzhou.aliyuncs.com",
      "Recommend": "https://next.api.aliyun.com/troubleshoot?q=IDP.UrlNotLegal&product=docmind-api"
    }

    If a task fails, the `Completed` field is set to `true` and the `Status` field is set to `Fail`. The response also includes an error `Code` and a detailed `Message`. For more information about error codes, see Error codes.

  • The following sample response shows a task that was successful:

    {
    	"Status": "Success",
    	"RequestId": "73134E1A-E281-1B2C-A105-D0ECFE2D****",
    	"Completed": true,
    	"Data": {
    		"status": "success",
    		"errorCode": null,
    		"errorMessage": null,
    		"result": {
    			"kvListInfo": [
    				[
    					[{
    							"value": [
    								"019W"
    							],
    							"key": [
    								"Voyage"
    							],
    							"extInfo": {
    								"table_id": "adf1d2f40b208d4923764d2ea6175365"
    							}
    						},
    						{
    							"value": [
    								"Ningbo"
    							],
    							"key": [
    								"POL"
    							],
    							"extInfo": {
    								"table_id": "adf1d2f40b208d4923764d2ea6175365"
    							}
    						},
    						{
    							"value": [
    								"2022-05-3110: 00"
    							],
    							"key": [
    								"ETD"
    							],
    							"extInfo": {
    								"table_id": "adf1d2f40b208d4923764d2ea6175365"
    							}
    						},
    						{
    							"value": [
    								"Piraeus"
    							],
    							"key": [
    								"POD"
    							],
    							"extInfo": {
    								"table_id": "adf1d2f40b208d4923764d2ea6175365"
    							}
    						},
    						{
    							"value": [
    								"2022-06-2007: 00"
    							],
    							"key": [
    								"ETA"
    							],
    							"extInfo": {
    								"table_id": "adf1d2f40b208d4923764d2ea6175365"
    							}
    						}
    					],
    					[{
    							"value": [
    								""
    							],
    							"key": [
    								"Voyage"
    							],
    							"extInfo": {
    								"table_id": "adf1d2f40b208d4923764d2ea6175365"
    							}
    						},
    						{
    							"value": [
    								"Piraeus"
    							],
    							"key": [
    								"POL"
    							],
    							"extInfo": {
    								"table_id": "adf1d2f40b208d4923764d2ea6175365"
    							}
    						},
    						{
    							"value": [
    								""
    							],
    							"key": [
    								"ETD"
    							],
    							"extInfo": {
    								"table_id": "adf1d2f40b208d4923764d2ea6175365"
    							}
    						},
    						{
    							"value": [
    								"Algeciras"
    							],
    							"key": [
    								"POD"
    							],
    							"extInfo": {
    								"table_id": "adf1d2f40b208d4923764d2ea6175365"
    							}
    						},
    						{
    							"value": [
    								""
    							],
    							"key": [
    								"ETA"
    							],
    							"extInfo": {
    								"table_id": "adf1d2f40b208d4923764d2ea6175365"
    							}
    						}
    					]
    				]
    			],
    			"kvInfo": [{
    				"value": [
    					"Ningbo"
    				],
    				"key": [
    					"Place of Receipt"
    				],
    				"extInfo": {
    					"valueLayoutId": "7248c73597b46266b9c84505f2bab8fe",
    					"valueConfidence": 0.9994202852249146,
    					"keyConfidence": 0.9719930092493693,
    					"keyLayoutId": "7248c73597b46266b9c84505f2bab8fe"
    				}
    			}],
    			"pageInfo": [{
    					"imageWidth": 1917,
    					"imageUrl": "http://docmind-api-cn-hangzhou.oss-cn-hangzhou.aliyuncs.com/idp/ab4fe775d9dd423182f30db57c62d379/example1.jpg?Expires=1661221931&OSSAccessKeyId=XX&Signature=YY",
    					"angle": 0.0,
    					"pageIdCurDoc": 1,
    					"imageType": "JPEG",
    					"imageHeight": 2713,
    					"pageIdAllDocs": 1
    				},
    				{
    					"imageWidth": 1917,
    					"imageUrl": "http://docmind-api-cn-hangzhou.oss-cn-hangzhou.aliyuncs.com/idp/ab4fe775d9dd423182f30db57c62d379/example2.jpg?Expires=1661221931&OSSAccessKeyId=XX&Signature=YY",
    					"angle": 0.0,
    					"pageIdCurDoc": 2,
    					"imageType": "JPEG",
    					"imageHeight": 2713,
    					"pageIdAllDocs": 2
    				},
    				{
    					"imageWidth": 1917,
    					"imageUrl": "http://docmind-api-cn-hangzhou.oss-cn-hangzhou.aliyuncs.com/idp/ab4fe775d9dd423182f30db57c62d379/example3.jpg?Expires=1661221931&OSSAccessKeyId=XX&Signature=YY",
    					"angle": 0.0,
    					"pageIdCurDoc": 3,
    					"imageType": "JPEG",
    					"imageHeight": 2713,
    					"pageIdAllDocs": 3
    				}
    			]
    		}
    	}
    }

    If the task is successful, `Completed` returns `true` and `Status` returns `Success`. The detailed results are in the `Data` node. The following table describes the structure of the `Data` node.

    Name

    Type

    Example value

    Description

    status

    String

    init

    The status. Valid values:

    init (initialization), processing, and success

    result

    JSONObject

    -

    The key-value extraction result.

    kvListInfo

    array of arrays

    Note that there can be multiple tables.

    Information about the key-value list. This typically appears for table key-values. Note that `kvListInfo` is an array of arrays. Because extraction results may come from multiple tables, each table is a collection of `kvInfo`.

    kvInfo

    array

    -

    Paragraph key-value information.

    valuePos

    array

    -

    The coordinates of the value. There can be multiple coordinates.

    width

    int

    863

    The width.

    x

    int

    410

    The x-coordinate.

    y

    int

    837

    The y-coordinate.

    pageId

    int

    0

    The page number.

    height

    int

    45

    The height.

    existCorrection

    boolean

    false

    Indicates whether a correction was made.

    existTranscoding

    boolean

    true

    Indicates whether transcoding occurred.

    originalValue

    array

    A company

    The original value before processing.

    keyPos

    array

    -

    The coordinates of the key.

    width

    int

    863

    The width.

    x

    int

    410

    The x-coordinate.

    y

    int

    837

    The y-coordinate.

    pageId

    int

    0

    The page number.

    height

    int

    45

    The height.

    keyDesc

    array

    Party A Name

    The description of the key.

    value

    array

    A company

    The final extracted value after processing.

    key

    array

    firstPartyName

    The English code for the key.

    extInfo

    object

    -

    Extended information.

    valueConfidence

    double

    0.9994202852249146

    The confidence level of the value.

    keyConfidence

    double

    0.9719930092493693

    The confidence level of the key.

    extractFrom

    String

    -

    The extraction source. The default is nlp.

    pageInfo

    array

    -

    A list of document pages.

    imageType

    string

    JPEG

    The type of the converted page.

    imageUrl

    string

    -

    The URL of the image after the page is converted to an image.

    angle

    float

    90

    The rotation angle of the image after page conversion. The value represents a counter-clockwise rotation.

    imageWidth

    int

    1917

    The width of the converted image.

    imageHeight

    int

    1917

    The height of the converted image.

    pageIdCurDoc

    int

    0

    The page index in the current document. The index starts from 0.

    pageIdAllDocs

    int

    0

    The page index across all documents. The index starts from 0.