tencent cloud

All product documents
Tencent Cloud Super App as a Service
Code Scanning
Last updated: 2025-04-10 18:18:36
Code Scanning
Last updated: 2025-04-10 18:18:36

scanCode

This API is called using wx.scanCode(Object object).
Notes:
This API is supported in mini programs but not in mini games.
Feature description:Opens the client’s code scanning interface to scan the code.
Parameter and description:Object object.
Property
Type
Valid values and description
Default value
‍Required
Description
onlyFromCamera
boolean
-
false
False
Whether to only allow scanning from the camera, not from the photo album.
scanType
Array.<string>
barCode: Barcode
qrCode: QR code
datamatrix: Data Matrix code
pdf417: PDF417 barcode
['barCode', 'qrCode']
False
Types of codes to scan.
success
function
-
-
False
Callback function for successful API calls.
fail
function
-
-
False
Callback function for failed API calls.
complete
function
-
-
False
Callback function executed after API call ends (regardless of success or failure).
object.success callback function parameter:Object res.
Property
Type
Valid values and description
Description
result
string
-
Content of the scanned code.
scanType
string
QR_CODE: QR code
AZTEC: Barcode
CODABAR: Barcode
CODE_39: Barcode
CODE_93: Barcode
CODE_128: Barcode
DATA_MATRIX: QR code
EAN_8: Barcode
EAN_13: Barcode
ITF: Barcode
MAXICODE: Barcode
PDF_417: QR code
RSS_14: Barcode
RSS_EXPANDED: Barcode
UPC_A: Barcode
UPC_E: Barcode
UPC_EAN_EXTENSION: Barcode
WX_CODE: QR code
CODE_25: Barcode
Type of the scanned code.
charSet
string
-
Character set of the scanned code.
path
string
-
If the scanned code is a QR code for the current mini program, this field will be returned with the path carried by the QR code
rawData
string
-
Base64-encoded raw data.
Example:
// Allow scanning from both camera and photo album
wx.scanCode({
success (res) {
console.log(res)
}
})

// Only allow scanning from the camera
wx.scanCode({
onlyFromCamera: true,
success (res) {
console.log(res)
}
})


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

Feedback

Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 available.

7x24 Phone Support