Document Processing - Image-to-Excel API

Updated at:

Call the processDocument API to convert a single image into an Excel document. The API returns the Base64 encoding of the resulting file.

API overview

API name: processDocument

Feature description: Converts an image to an Excel file when the engineType parameter is set to ScanDocConvertExcel.

Item

Description

Request method

POST

Service address

https://cloud-iqs.aliyuncs.com/document/process

Request format

Request header Content-Type: application/json

Authentication method

Request header X-API-Key

This feature is billed as Vertical Search, and each successful API call incurs a charge. For pricing details, see the "Vertical Search Billing Information" document.

API definition

Request parameters

Parameter

Type

Required

Default

Description

Example

engineType

string

Yes

None

Must be set to ScanDocConvertExcel. This value is case-sensitive.

ScanDocConvertExcel

dataUrl

string

Required if dataBase64 is not specified.

None

The URL of a downloadable image. A public HTTPS URL is recommended.

See request example

dataBase64

string

Required if dataUrl is not specified.

None

The standard Base64 encoding of a single image, without the data: prefix. The original image cannot exceed 10 MiB (10,485,760 bytes).

Full image Base64 string

Note

Response parameters

The following fields are included in a successful response. The field names are case-sensitive.

Field

Type

Return condition

Description

requestId

string

Always returned

The request ID. Provide this ID when contacting technical support.

searchInformation

object

Always returned

Contains the document processing time.

searchInformation.searchTime

int64

Always returned

The document processing time, in milliseconds.

functionOption

string

Always returned

A fixed value of excel. This value is case-sensitive and differs from the engineType in the request.

fileBase64

string

Always returned

The Base64 encoding of the converted Excel file.

fileName

string

Always returned

A fixed value of result.xlsx.

mimeType

string

Always returned

A fixed value of application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.

To use the response, parse the JSON and Base64-decode the value of fileBase64 to retrieve the file's binary bytes. Save these bytes to a file named result.xlsx, as specified by the fileName field. Do not save the raw Base64 string as the file content; the correct file type is specified by the mimeType field.

Examples

The image URL in the example is a placeholder. Replace it with a valid, downloadable image URL when you call the API.

Request parameters:

{
  "engineType": "ScanDocConvertExcel",
  "dataUrl": "https://example.com/images/ScanDocConvertExcel.png"
}

Response parameters: The following example shows the response structure. The request ID and processing time are for demonstration purposes only. [FULL_FILE_BASE64] is a placeholder representing the complete Base64-encoded file returned in an actual response; it is not a decodable value.

{
  "requestId": "example-request-id",
  "searchInformation": {"searchTime": 120},
  "functionOption": "excel",
  "fileBase64": "[FULL_FILE_BASE64]",
  "fileName": "result.xlsx",
  "mimeType": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
}

Make an API call

To call this API, pass an authorized API Key in the X-API-Key request header. The following example reads the credential from an API_KEY environment variable. Do not embed your actual credential in front-end code or public repositories.

curl -X POST 'https://cloud-iqs.aliyuncs.com/document/process' \
  --header "X-API-Key: $API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
    "engineType": "ScanDocConvertExcel",
    "dataUrl": "https://example.com/images/ScanDocConvertExcel.png"
  }'

To use Base64 encoding instead of dataUrl, use the dataBase64 parameter and provide the complete image encoding as described in the parameter table. Do not include both image source parameters in the same request. The request must be a POST request with a JSON body and use only the fields defined in this document.

Error codes

When handling errors, first check the HTTP status code and the response body format. A JSON response for a document processing error contains the errorCode and errorMessage fields. Optional code and message fields may also be present and have the same meaning. For 403 errors related to permissions or quotas, the presence of these fields is not guaranteed. Prioritize reading errorCode and errorMessage from the response. If they are missing, fall back to reading code and message. The requestId is not guaranteed in all error responses, and the response body may be non-JSON or empty.

Example of a parameter error (including optional mirrored fields):

{
  "errorCode": "InvalidParameter",
  "errorMessage": "Image too large",
  "code": "InvalidParameter",
  "message": "Image too large"
}

HTTP status code

Error code

Description

Solution

400

MissingParameter

An image source or a required parameter is missing.

Check the engineType and provide one non-empty image source.

400

InvalidParameter

A parameter is invalid or the image is too large.

Verify the casing of ScanDocConvertExcel, ensure the image sources are mutually exclusive, check the Base64 padding, and confirm the original image size. Do not pass inputConfig or other extra parameters.

403

Retrieval.InvalidAPIKey

The API Key is invalid.

Check the X-API-Key request header and the credential.

403

As returned in the response

Insufficient permissions or available quota.

Verify that the API is enabled for your account, and check your permissions and available quota.

415

As returned in the response

Unsupported request format. The response body may be empty.

Use Content-Type: application/json.

429

Retrieval.Throttling.scan (Common)

Requests are too frequent.

Reduce the call frequency and implement a backoff and retry strategy.

502

As returned in the response

Failed to process the image or retrieve the result.

Check if the image is downloadable and inspect its content. If the issue persists, contact technical support and provide the request ID, if available.

503

As returned in the response

The service is temporarily unavailable.

Try again later. If the issue persists, contact technical support.

500

As returned in the response

An internal service error occurred.

Contact technical support and provide the request ID (if available) and the error message from the response body.

Note The service may return a non-JSON response if the engineType value is incorrectly cased (e.g., scandocconvertexcel instead of ScanDocConvertExcel) or if the JSON request body is truncated. Do not attempt to parse all error responses as JSON. Handle empty response bodies based on the HTTP status code.

Related documentation