tencent cloud

Quick Integration Guide
Last updated:2026-01-22 13:21:24
Quick Integration Guide
Last updated: 2026-01-22 13:21:24

Overview

This guide helps you call the text recognition API 3.0 relevant APIs through the API 3.0 Explorer online interface debugging page after enabling the text recognition service, and integrate the SDK corresponding to this interface's language into your project.

Prerequisites

Before calling text recognition-related APIs, you need to first apply for enabling the corresponding text recognition service. Once the application is successful, enter the text recognition API 3.0 Explorer online interface debugging page, and call the API according to the following directions.

Directions

1. In the left navigation pane, select the API you need to call.


2. Fill in the personal key and the required content in the input parameters.


Region parameter: The region information in the domain name. This parameter determines the access point. For example, ocr.ap-shanghai.tencentcloudapi.com is to access the Shanghai access point. The public parameter Region determines the region where the business resources are located. For example, Region=ap-beijing is to operate resources in the Beijing region. If the domain name does not specify region information, it will by default connect to a nearby access point. Proximity access may have problems. If no IP can be resolved, it will by default access the Guangzhou region. Additionally, the domain name region and the public parameter Region may differ, but this may increase latency. It is advisable to select the same region for the domain name and the public parameter Region: South China (Guangzhou), ap-guangzhou.
Config is of String type and is parsed into Json format.


3. Select the language to generate corresponding code. You fill in the parameter values on the left, then generate the code. Some field information and filled content in the generated code are associated. If adjustments to input parameters are needed, modify the parameter values on the left and regenerate the code.
4. Integrate the SDK into the project. Refer to the SDK usage instructions in the upper-right corner to introduce the SDK into the project. The generated code from [Step 3] can be used to call the corresponding interface.



Demo (Recommended)

const tencentcloud = require("../../../../tencentcloud-sdk-nodejs");

const OcrClient = tencentcloud.ocr.v20181119.Client;
const models = tencentcloud.ocr.v20181119.Models;

const Credential = tencentcloud.common.Credential;
const ClientProfile = tencentcloud.common.ClientProfile;
const HttpProfile = tencentcloud.common.HttpProfile;

let cred = new Credential(" SecretId ", " SecretKey ");
let httpProfile = new HttpProfile();
let clientProfile = new ClientProfile();
/*
Recommended to use V3 authentication. When the content exceeds 1M, signature authentication using V3 must be used. Except for Node SDK, other language SDKs support V3.
clientProfile.signMethod = "TC3-HMAC-SHA256";
*/
clientProfile.httpProfile = httpProfile;
let client = new OcrClient(cred, "ap-guangzhou", clientProfile);

let req = new models.IDCardOCRRequest();

req.ImageUrl = "[https://test.jpg](https://test.jpg/)";
req.CardSide = "FRONT";
let config = {"CropPortrait":true};
req.Config = JSON.stringify(config)

client.IDCardOCR(req, function(errMsg, response) {

if (errMsg) {
console.log(errMsg);
return;
}

console.log(response.to_json_string());

});

Must-Knows

When making SDK calls to common parameters, only need to focus on the Region field. It is advisable to uniformly use "ap-guangzhou" for the domain name and Region.
Generate SecretId/SecretKey address: Cloud Access Management - API Key Management. The text recognition-related APIs currently only support root account calls. We will support sub-account calls as soon as possible.
Remove the relevant prefix data:image/jpg;base64, and line break \\n when converting images/videos to Base64.
If the request result prompts as follows, you need to manually set the signature type:
[TencentCloudSDKException]message:AuthFailure.SignatureFailure-The provided credentials
could not be validated because of exceeding request size limit, please use new signature
method `TC3-HMAC-SHA256`. requestId:719970d4-5814-4dd9-9757-a3f11ecc9b20
Set signature type
clientProfile.setSignMethod("TC3-HMAC-SHA256"); // Specify the signature algorithm (default is HmacSHA256)
If the API request content exceeds 1M, only TC3-HMAC-SHA256 authentication can be used. Except for Node SDK, other language SDKs support V3.
API 3.0 SDK supported languages: Node, Python, Java, PHP, Go, .Net. Other languages such as C++ do not currently support SDK-based calls and require implementing your own V3 authentication for API calls. It is recommended to use the string signature generation tool in API 3.0 Explorer to verify signature validity.


Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback