The ScanFile API uses advanced AI to convert images of documents, such as exam papers, books, official documents, IDs, and line drawings, into high-quality scanned documents. The API uses powerful image processing to remove noise and correct distortions. This lets you produce high-quality scans from photos, with results comparable to those from a traditional scanner.
API definition
Request parameters
Parameter | Type | Required | Default | Description | Example | |
imageUrl | string | No | - | The URL of an image accessible by the Information Query Service (IQS) server. | "www." | |
imageBase64 | string | No | - | The Base64-encoded content of the image. | "/9j/4AAQSkZJR..." | |
scanFileInputConfig | autoCrop | string | No | true | Specifies whether to crop the image. Valid values: | false |
autoRotate | string | No | true | Specifies whether to rotate the image. Valid values: | false | |
Response parameters
Field | Type | Nullable | Description | Example | ||
requestId | string | No | The request ID. Provide this ID when submitting a ticket for troubleshooting. | 35E5608A-A737-2038-****-D9D34C6BFD9E | ||
scanFileInfoList[] | angle | int32 | No | The rotation angle of the image. | 0 | |
height | int32 | No | The height of the image in pixels. | 3071 | ||
width | int32 | No | The width of the image in pixels. | 1315 | ||
imageBase64 | string | No | The Base64-encoded content of the processed image. | "/9j/4AAQSkZJR..." | ||
searchInformation | searchTime | int64 | No | The search time, in milliseconds. | 1048 | |
The server-side timeout is 25 seconds.
Example
Request body
{
"imageUrl": "https://img2.xxx"
}Response body
{
"requestId": "c182ff0b-0a16-4a6d-a586-9841495bb3a2",
"scanFileInfoList": [
{
"angle": 0,
"height": 2178,
"width": 1539,
"imageBase64": "/9j/4AAQSkZJRgAgAooAKKACigD//Z"
}
],
"searchInformation": {
"searchTime": 1265
}
}Error codes
Status | Error code | Error message | Solution |
404 | InvalidAccessKeyId.NotFound | Specified access key is not found. | Ensure your API key is correct and activated. |
403 | Retrieval.NotActivate | Please activate AI search service | Purchase the service or contact your account manager to activate it. |
403 | Retrieval.Arrears | Please recharge first. | Your account balance is insufficient. Add funds to your account. |
403 | Retrieval.NotAuthorised | Please authorize the AliyunIQSFullAccess privilege to the sub-account. | The sub-account is not authorized. For details, see Create and authorize a RAM user. |
403 | Retrieval.TestUserPeriodExpired | The test period has expired. | Your trial period (valid for 15 days after purchase) has expired. Contact your account manager to upgrade to a paid plan. |
429 | Retrieval.Throttling.User | Request was denied due to user flow control. | The request rate exceeds the flow control limit. Contact your account manager to upgrade your plan. |
429 | Retrieval.TestUserQueryExceeded | The query exceeds the limit | The daily query limit for trial users (1,000 queries/day) has been exceeded. Contact your account manager to upgrade to a paid plan. |
API calls
HTTP call
Authenticate by using an API key for the Information Query Service (IQS) and make API calls over HTTP. Create and view an API key to obtain an API key.
curl -X POST https://cloud-iqs.aliyuncs.com/scan/file \
--header "Authorization: Bearer $API_KEY" \
--header "Content-Type: application/json" \
--data '{
"imageUrl": "https://xxxxx"
}'
Replace $API_KEY with your API key from the Information Query Service (IQS) console. For instructions, see Create and view an API key. Note that a new API key can take up to 5 minutes to become active.
SDK call
For more information, see SDK Quick Start.