Intelligent table parsing
The intelligent table parsing API extracts and understands tables. It extracts information such as table styles, table content, text key-value pairs (KVs), and table KVs from PDF or image documents. This topic describes how to call the intelligent table parsing API. Before you call the API, read the API usage guide.
How to call the API
The intelligent table parsing API is asynchronous. First, you can call the SubmitTableUnderstandingJob or SubmitTableUnderstandingJobAdvance service to submit an asynchronous task. Then, you can call the GetTableUnderstandingResult service to poll for the result.
-
You can poll for the result every 10 seconds for up to 120 minutes. If the task is not complete after 120 minutes, the task times out.
-
After you submit an asynchronous task, you can query the result within 24 hours. After 24 hours, the result is no longer available.
-
The free quota is 100 pages and is not renewable. If your free quota or resource plan is used up, the system automatically switches to the pay-as-you-go billing method.
-
If you parse a document with more than 100 pages for the first time, the system automatically switches to the pay-as-you-go billing method and generates a bill after the document is successfully parsed.
-
Supported document formats: PDF and images. Supported image formats include JPG, JPEG, PNG, BMP, and GIF.
Step 1: Call the SubmitTableUnderstandingJob API to asynchronously submit a task
The asynchronous submission service supports local files and files from URLs:
-
To upload a file from a URL, use the SubmitTableUnderstandingJob API.
-
To upload a local file, use the SubmitTableUnderstandingJobAdvance API.
Request parameters
|
Name |
Type |
Required |
Description |
Example |
|
FileUrl |
string |
Yes |
Used when you call the API to upload a file from a URL. A single document. PDF documents can be up to 1000 pages and 100 MB. Single images can be up to 20 MB. |
https://example.com/example.pdf |
|
FileUrlObject |
stream |
Yes |
Used when you call the API to upload a local file. A single document. PDF documents can be up to 1000 pages and 100 MB. Single images can be up to 20 MB. |
A FileInputStream generated from a local file |
|
FileName |
string |
No |
The file name, which must include the file extension. You must specify either `FileName` or `FileNameExtension`. |
example.pdf |
|
FileNameExtension |
string |
No |
The file type. This parameter is mutually exclusive with `fileName`. Supported types are pdf, jpg, jpeg, png, bmp, or gif. |
|
|
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 |
Response parameters
|
Name |
Type |
Description |
Example value |
|
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 number. This is the unique identifier used to query the result. |
docmind-20220712-b15f**** |
|
Code |
string |
The status code. |
200 |
|
Message |
string |
The detailed information. |
Message |
Examples
You can call this API to upload a local file or a file from a URL.
-
Local file upload: The following code provides an example of how to upload a local document using the Java SDK. To upload a local document, call the `SubmitTableUnderstandingJobAdvance` API and use the `fileUrlObject` parameter.
NoteFor information about how to obtain and use AccessKey pairs, see the software development kit (SDK) usage guides for different languages 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 main(String[] args) throws Exception { submit(); } public static void submit() throws Exception { // Use the default credential to initialize the Credentials client. com.aliyun.credentials.Client credentialClient = new com.aliyun.credentials.Client(); Config config = new Config() // Obtain the AccessKey ID from the configuration using credentials. .setAccessKeyId(credentialClient.getAccessKeyId()) // Obtain the AccessKey secret from the configuration using 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 the runtime parameters. RuntimeOptions runtime = new RuntimeOptions(); SubmitTableUnderstandingJobAdvanceRequest advanceRequest = new SubmitTableUnderstandingJobAdvanceRequest(); File file = new File("D:\\example.pdf"); advanceRequest.fileUrlObject = new FileInputStream(file); advanceRequest.fileName = "example.pdf"; // 4. Send the request and handle the response or exceptions. SubmitTableUnderstandingJobResponse response = client.submitTableUnderstandingJobAdvance(advanceRequest, runtime); System.out.println(JSON.toJSON(response.getBody())); }const Client = require('@alicloud/docmind-api20220711'); const Credential = require('@alicloud/credentials'); const Util = require('@alicloud/tea-util'); const fs = require('fs'); const getResult = async () => { // Use the default credential to initialize the Credentials client. 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 configuration using credentials. accessKeyId: cred.credential.accessKeyId, // Obtain the AccessKey secret from the configuration using credentials. accessKeySecret: cred.credential.accessKeySecret, type: 'access_key', regionId: 'cn-hangzhou', }); const advanceRequest = new Client.SubmitTableUnderstandingJobAdvanceRequest(); const file = fs.createReadStream('./example.pdf'); advanceRequest.fileUrlObject = file; advanceRequest.fileName = 'example.pdf'; const runtimeObject = new Util.RuntimeOptions({}); const response = await client.submitTableUnderstandingJobAdvance(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 if __name__ == '__main__': cred=CredClient() config = open_api_models.Config( # Obtain the AccessKey ID from the configuration using credentials. access_key_id=cred.get_credential().get_access_key_id(), # Obtain the AccessKey secret from the configuration using credentials. access_key_secret=cred.get_credential().get_access_key_secret() ) # The endpoint. config.endpoint = f'docmind-api.cn-hangzhou.aliyuncs.com' client = docmind_api20220711Client(config) request = docmind_api20220711_models.SubmitTableUnderstandingJobAdvanceRequest( # 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 file_name or file_name_extension. # file_name_extension='pdf' ) runtime = util_models.RuntimeOptions() try: # If you copy the code, print the API response on your own. response = client.submit_table_understanding_job_advance(request, runtime) # The API response is in the format of 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) 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(){ // Use the default credential to initialize the Credentials client. credential, err := credentials.NewCredential(nil) // Obtain the AccessKey ID from the configuration using credentials. accessKeyId, err := credential.GetAccessKeyId() // Obtain the AccessKey secret from the configuration using 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 API to upload a local document. filename := "D:\\example.pdf" f, err := os.Open(filename) if err != nil { panic(err) } // Initialize the API request. request := client.SubmitTableUnderstandingJobAdvanceRequest{ FileName: &filename, FileUrlObject: f, } // Create a RuntimeObject instance and set the runtime parameters. options := service.RuntimeOptions{} response, err := cli.SubmitTableUnderstandingJobAdvance(&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() { // Use the default credential to initialize the Credentials client. var akCredential = new Aliyun.Credentials.Client(null); AlibabaCloud.OpenApiClient.Models.Config config = new AlibabaCloud.OpenApiClient.Models.Config { // Obtain the AccessKey secret from the configuration using credentials. AccessKeyId = akCredential.GetAccessKeyId(), // Obtain the AccessKey secret from the configuration using credentials. AccessKeySecret = akCredential.GetAccessKeySecret(), }; // The endpoint. config.Endpoint = "docmind-api.cn-hangzhou.aliyuncs.com"; // You need to install an additional dependency library: AlibabaCloud.DarabonbaStream. 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.SubmitTableUnderstandingJobAdvanceRequest request = new AlibabaCloud.SDK.Docmind_api20220711.Models.SubmitTableUnderstandingJobAdvanceRequest { FileUrlObject = bodySyream, FileNameExtension = "pdf" }; AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime = new AlibabaCloud.TeaUtil.Models.RuntimeOptions(); try { // If you copy the code, print the API response on your own. client.SubmitTableUnderstandingJobAdvance(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); } } -
File upload from a URL: The following code provides an example of how to upload a document from a URL using the Java SDK. Call the `SubmitTableUnderstandingJob` API and use the `fileUrl` parameter to specify the document URL. The URL must be a public URL that is accessible over the Internet, has no cross-domain restrictions, and does not contain special escape characters.
NoteFor information about how to obtain and use AccessKey pairs, see the software development kit (SDK) usage guides for different languages in SDK Overview.
import com.aliyun.docmind_api20220711.models.*; import com.aliyun.teaopenapi.models.Config; import com.aliyun.docmind_api20220711.Client; public static void main(String[] args) throws Exception { submit(); } public static void submit() throws Exception { // Use the default credential to initialize the Credentials client. com.aliyun.credentials.Client credentialClient = new com.aliyun.credentials.Client(); Config config = new Config() // Obtain the AccessKey ID from the configuration using credentials. .setAccessKeyId(credentialClient.getAccessKeyId()) // Obtain the AccessKey secret from the configuration using 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); SubmitTableUnderstandingJobRequest request = new SubmitTableUnderstandingJobRequest(); request.fileName = "example.pdf"; request.fileUrl = "https://example.com/example.pdf"; SubmitTableUnderstandingJobResponse response = client.submitTableUnderstandingJob(request); System.out.println(JSON.toJSON(response.getBody())); }const Client = require('@alicloud/docmind-api20220711'); const Credential = require('@alicloud/credentials'); const getResult = async () => { // Use the default credential to initialize the Credentials client. 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 configuration using credentials. accessKeyId: cred.credential.accessKeyId, // Obtain the AccessKey secret from the configuration using credentials. accessKeySecret: cred.credential.accessKeySecret, type: 'access_key', regionId: 'cn-hangzhou' }); const advanceRequest = new Client.SubmitDocStructureJobAdvanceRequest(); const file = fs.createReadStream('./example.pdf'); advanceRequest.fileUrlObject = file; advanceRequest.fileName = 'example.pdf'; const runtimeObject = new Util.RuntimeOptions({}); const response = await client.submitDocStructureJobAdvance(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 if __name__ == '__main__': cred=CredClient() config = open_api_models.Config( # Obtain the AccessKey ID from the configuration using credentials. access_key_id=cred.get_credential().get_access_key_id(), # Obtain the AccessKey secret from the configuration using credentials. access_key_secret=cred.get_credential().get_access_key_secret() ) # The endpoint. config.endpoint = f'docmind-api.cn-hangzhou.aliyuncs.com' client = docmind_api20220711Client(config) request = docmind_api20220711_models.SubmitTableUnderstandingJobRequest( # file_url: The URL of the file. 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 file_name or file_name_extension. # file_name_extension='pdf' ) try: # If you copy the code, print the API response on your own. response = client.submit_table_understanding_job(request) # The API response is in the format of 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) 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(){ // Use the default credential to initialize the Credentials client. credential, err := credentials.NewCredential(nil) // Obtain the AccessKey ID from the configuration using credentials. accessKeyId, err := credential.GetAccessKeyId() // Obtain the AccessKey secret from the configuration using 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 API request. request := client.SubmitTableUnderstandingJobRequest{ FileUrl: &fileURL, FileName: &fileName, } response, err := cli.SubmitTableUnderstandingJob(&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() { // Use the default credential to initialize the Credentials client. var akCredential = new Aliyun.Credentials.Client(null); AlibabaCloud.OpenApiClient.Models.Config config = new AlibabaCloud.OpenApiClient.Models.Config { // Obtain the AccessKey secret from the configuration using credentials. AccessKeyId = akCredential.GetAccessKeyId(), // Obtain the AccessKey secret from the configuration using 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.SubmitTableUnderstandingJobRequest request = new AlibabaCloud.SDK.Docmind_api20220711.Models.SubmitTableUnderstandingJobRequest { FileUrl = "https://example.pdf", FileNameExtension = "pdf" }; try { // If you copy the code, print the API response on your own. client.SubmitTableUnderstandingJob(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\SubmitTableUnderstandingJobRequest; use Darabonba\OpenApi\Models\Config; use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions; use AlibabaCloud\Tea\Exception\TeaUnableRetryError; use AlibabaCloud\Credentials\Credential; // Use the default credential to initialize the Credentials client. $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 configuration using credentials. $config->accessKeyId = $bearerToken->getCredential()->getAccessKeyId(); // Obtain the AccessKey secret from the configuration using credentials. $config->accessKeySecret = $bearerToken->getCredential()->getAccessKeySecret(); $config->type = "access_key"; $config->regionId = "cn-hangzhou"; $client = new Docmindapi($config); $request = new SubmitTableUnderstandingJobRequest(); $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->submitTableUnderstandingJob($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()); }
Example of a successful response:
{
"RequestId": "43A29C77-405E-4CC0-BC55-EE694AD0****",
"Data": {
"Id": "docmind-20220712-b15f****"
}
}
Step 2: Poll the GetTableUnderstandingResult API to query the result
The `Id` input parameter for the query API is the `Id` that is returned in the response from the asynchronous task submission API. The status of the query result can be processing, successful, or failed. You can poll for the result every 10 seconds for up to 120 minutes. Stop polling if the `Completed` parameter returns `true` or if the maximum polling duration is exceeded.
Request parameters
|
Name |
Type |
Required |
Description |
Example |
|
Id |
string |
Yes |
The business order number to query. Obtain this number from the response of the submission API. |
docmind-20220712-b15f**** |
Response parameters
|
Name |
Type |
Description |
Example |
|
RequestId |
string |
The request ID. |
43A29C77-405E-4CC0-BC55-EE694AD0**** |
|
Completed |
boolean |
Indicates whether the asynchronous task is complete. `false` indicates that the task is still processing. `true` indicates that the task is complete, with a result of either successful or failed. |
true |
|
Status |
String |
The final status of the asynchronous task. `Success` indicates that the task was successful. `Fail` indicates that the task failed. |
Success |
|
Data |
string |
The returned data. This is the result of the intelligent table parsing. The output is a JSON data structure that contains the table style, table content, and table KVs parsed from the table. |
- |
|
Code |
string |
The status code. |
200 |
|
Message |
string |
The detailed information. |
Message |
Example
The following code provides an example of how to call the result query API for intelligent document parsing using the Java SDK. Call the `getTableUnderstandingResult` API and pass the query ID in the `Id` parameter.
For information about how to obtain and use AccessKey pairs, see the software development kit (SDK) usage guides for different languages in SDK Overview.
import com.aliyun.docmind_api20220711.models.*;
import com.aliyun.teaopenapi.models.Config;
import com.aliyun.docmind_api20220711.Client;
public static void main(String[] args) throws Exception {
submit();
}
public static void submit() throws Exception {
// Use the default credential to initialize the Credentials client.
com.aliyun.credentials.Client credentialClient = new com.aliyun.credentials.Client();
Config config = new Config()
// Obtain the AccessKey ID from the configuration using credentials.
.setAccessKeyId(credentialClient.getAccessKeyId())
// Obtain the AccessKey secret from the configuration using 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);
GetTableUnderstandingResultRequest resultRequest = new GetTableUnderstandingResultRequest();
resultRequest.id = "docmind-20220902-824b****";
GetTableUnderstandingResultResponse response = client.getTableUnderstandingResult(resultRequest);
System.out.println(JSON.toJSON(response.getBody()));
}const Client = require('@alicloud/docmind-api20220711');
const Credential = require('@alicloud/credentials');
const getResult = async () => {
// Use the default credential to initialize the Credentials client.
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 configuration using credentials.
accessKeyId: cred.credential.accessKeyId,
// Obtain the AccessKey secret from the configuration using credentials.
accessKeySecret: cred.credential.accessKeySecret,
type: 'access_key',
regionId: 'cn-hangzhou'
});
const resultRequest = new Client.GetTableUnderstandingResultRequest();
resultRequest.id = "docmind-20220902-824b****";
const response = await client.getTableUnderstandingResult(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
if __name__ == '__main__':
cred=CredClient()
config = open_api_models.Config(
# Obtain the AccessKey ID from the configuration using credentials.
access_key_id=cred.get_credential().get_access_key_id(),
# Obtain the AccessKey secret from the configuration using credentials.
access_key_secret=cred.get_credential().get_access_key_secret()
)
# The endpoint.
config.endpoint = f'docmind-api.cn-hangzhou.aliyuncs.com'
client = docmind_api20220711Client(config)
request = docmind_api20220711_models.GetTableUnderstandingResultRequest(
# id: The ID returned by the task submission API.
id='docmind-20220902-824b****'
)
try:
# If you copy the code, print the API response on your own.
response = client.get_table_understanding_result(request)
# The API response is in the format of body -> data -> specific property. You can print the results as needed. Property values start with a lowercase letter.
# Obtain 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)
# Obtain the result. We recommend that you first convert response.body.data to JSON and then extract the required values from the JSON object.
print(response.body)
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(){
// Use the default credential to initialize the Credentials client.
credential, err := credentials.NewCredential(nil)
// Obtain the AccessKey ID from the configuration using credentials.
accessKeyId, err := credential.GetAccessKeyId()
// Obtain the AccessKey secret from the configuration using 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 API.
request := client.GetTableUnderstandingResultRequest{Id: &id}
response, err := cli.GetTableUnderstandingResult(&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()
{
// Use the default credential to initialize the Credentials client.
var akCredential = new Aliyun.Credentials.Client(null);
AlibabaCloud.OpenApiClient.Models.Config config = new AlibabaCloud.OpenApiClient.Models.Config
{
// Obtain the AccessKey secret from the configuration using credentials.
AccessKeyId = akCredential.GetAccessKeyId(),
// Obtain the AccessKey secret from the configuration using 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.GetTableUnderstandingResultRequest request = new AlibabaCloud.SDK.Docmind_api20220711.Models.GetTableUnderstandingResultRequest
{
Id = "docmind-20220902-824b****"
};
AlibabaCloud.TeaUtil.Models.RuntimeOptions runtime = new AlibabaCloud.TeaUtil.Models.RuntimeOptions();
try
{
// If you copy the code, print the API response on your own.
client.GetTableUnderstandingResult(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\GetTableUnderstandingResultRequest;
use Darabonba\OpenApi\Models\Config;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
use AlibabaCloud\Tea\Exception\TeaUnableRetryError;
use AlibabaCloud\Credentials\Credential;
// Use the default credential to initialize the Credentials client.
$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 configuration using credentials.
$config->accessKeyId = $bearerToken->getCredential()->getAccessKeyId();
// Obtain the AccessKey secret from the configuration using credentials.
$config->accessKeySecret = $bearerToken->getCredential()->getAccessKeySecret();
$config->type = "access_key";
$config->regionId = "cn-hangzhou";
$client = new Docmindapi($config);
$request = new GetTableUnderstandingResultRequest();
$request->id = "docmind-20220902-824b****";
$runtime = new RuntimeOptions();
$runtime->maxIdleConns = 3;
$runtime->connectTimeout = 10000;
$runtime->readTimeout = 10000;
try {
$response = $client->getTableUnderstandingResult($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 status of the query result can be processing, successful, or failed. The following sections provide examples for each case.
-
The response for an operation in progress is 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, the value of `Completed` is `false`. In this case, continue to poll for the result until `Completed` returns `true` or the maximum polling duration is exceeded.
-
If an operation fails, the response is as follows:
{ "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 the task fails, `Completed` returns `true` and `Status` returns `Fail`. The response also includes the error `Code` and a detailed `Message`. For more information about error codes, see Error codes.
-
The following code shows an example of a response for a successful task:
{ "Status": "Success", "RequestId": "73134E1A-E281-1B2C-A105-D0ECFE2D****", "Completed": true, "Data": { "tables": [ { "tableName": "Table 1", "tableNote": null, "sheetName": "Table 1", "sheetNumber": 1, "cells": [ { "content": "Ordinal Number", "autoWrap": false, "colNumber": 0, "rowNumber": 0, "pos": [ { "x": 178, "y": 1517 }, { "x": 704, "y": 1515 }, { "x": 706, "y": 1630 }, { "x": 180, "y": 1631 } ], "filledColor": null, "borderLine": null, "borderStyle": null, "borderColor": null, "blocks": [ { "font": "Times_New_Roman", "fontColor": "000000", "fontSize": 10, "bold": false, "underline": false, "deleteline": false, "italic": false, "alignment": null } ], "mergedCell": false, "firstMergedCell": false } ], "tableKVs": [ { "type": "kv", "relations": [ { "key": [ "Ordinal Number" ], "value": [ "Test 1", "Test 2" ] } ], "cellIdRelations": [ { "key": [ "0" ], "value": [ "4", "7" ] } ] } ] } ], "docInfo": { "pages": [ { "imageWidth": 1357, "sheetName": "", "fileIndex": 0, "pageIdCurDoc": 0, "imageHeight": 1919, "sourceFileType": "normal", "pageType": "digitalPage", "imageUrl": "http://docmind-api-cn-hangzhou.oss-cn-hangzhou.aliyuncs.com/1865815779912606/publicDocStructure/docmind-20251104-d6b4b01afd084de5a203e86b113799c9/0.png?Expires=1762282914&OSSAccessKeyId=LTAI5tQL9bqLHC5HYXXXX&Signature=5mTXXXXFeW7Sg7s8C4lVRxZLqY%3D", "angle": 0.0, "imageType": "JPEG", "imageStorageKey": "docmind-20251104-d6b4b01afd084de5a203e86b113799c9/0.png", "pageIdAllDocs": 0, "imageParseResult": "http://docmind-api-cn-hangzhou.oss-cn-hangzhou.aliyuncs.com/parse?Expires=1762282914&OSSAccessKeyId=LTAI5tQL9bqLHC5HYKXXXXX&Signature=GXXXXIPa2bRslOMP4s9aJwIX8%3D" } ], "layouts": [ { "firstLinesChars": 0, "pos": [ { "x": 334, "y": 177 }, { "x": 1019, "y": 177 }, { "x": 1019, "y": 205 }, { "x": 334, "y": 205 } ], "blocks": [ { "pos": [ { "x": 336, "y": 178 }, { "x": 1020, "y": 178 }, { "x": 1020, "y": 205 }, { "x": 336, "y": 205 } ], "styleId": 0, "style": { "fontName": "FAAAAJ+SimSun", "charScale": 1.0, "color": "000000", "underline": false, "styleId": 0, "deleteLine": false, "fontSize": 12, "bold": false, "italic": false }, "text": "Announcement of Successful Bid for the 2021 Zhengzhou National Fitness Month Launch Ceremony Service Project" } ], "index": 0, "subType": "none", "lineHeight": 0, "text": "Announcement of Successful Bid for the 2021 Zhengzhou National Fitness Month Launch Ceremony Service Project\n", "alignment": "center", "type": "title", "pageNum": [ 0 ], "uniqueId": "0c31592a200bee03f9911be07faxxx" } ] } } }If the task is successful, `Completed` returns `true` and `Status` returns `Success`. The parsing result is in the `Data` node. The `Data` node is a list that contains only one element. The following table describes the format of the element in the `Data` node.
Name
Type
Description
requestId
string
The unique request ID.
success
bool
Indicates whether the request was successful.
code
string
The error code.
msg
string
The overall error message.
data
object
The parsing result.
tables
array
The table information.
tableName
string
The table name.
tableNote
string
The table note.
sheetName
string
The sheet name.
sheetNumber
int
The sheet page number.
cells
array
The cell information.
content
string
The text content of the cell.
autoWrap
bool
Indicates whether the text is wrapped.
isMergedCell
bool
Indicates whether the cell is a merged cell.
isFirstMergedCell
bool
Specifies whether to merge the starting cell.
colNumber
int
The column number.
rowNumber
int
The row number.
filledColor
string
The fill color of the cell.
borderLine
string
The border line of the cell.
borderStyle
string
The border style.
borderColor
string
The border color.
pos
array
The coordinates.
blocks
array
The list of block information.
font
int
The font.
fontColor
string
The font color.
fontSize
int
The font size.
bold
bool
Indicates whether the text is bold.
underline
bool
Indicates whether the text is underlined.
deleteline
bool
Indicates whether the text has a strikethrough.
italic
bool
Indicates whether the text is italic.
alignment
string
The alignment.
tableKVs
array
The extracted table content.
type
string
The type of the extracted table content.
relations
array
The list of extracted table content.
key
array
The list of keys.
value
array
The list of values.
cellIdRelations
array
The list of cell relationships.
key
array
The list of cell IDs where the keys are located.
value
array
The list of cell IDs where the values are located.
docInfo
object
Document information.
imageWidth
int
The width of the image converted from the page.
imageHeight
int
The height of the image converted from the page.
pageIdCurDoc
int
The page index in the current document. The value starts from 0.
pageIdAllDocs
int
The page index across all documents. The value starts from 0.
imageUrl
string
The URL of the image converted from the page.
angle
float
The rotation angle of the image converted from the page.
imageType
string
The type of the converted page.
layouts
array
Embedded layout information.
firstLinesChars
int
The indent of the first line. (Specific to paragraph layouts)
pos
array
The coordinates.
index
int
The reading order of the layout.
subType
string
The layout subtype.
lineHeight
int
The average line height. (Specific to paragraph layouts)
text
string
The text content.
alignment
string
The pitch enumeration.
type
string
The layout type. For more information, see Layout types.
pageNum
array
The page numbers where the layout is located. (May span multiple pages)
uniqueId
string
The unique ID of the layout information.