getImageTransferKey(data: GetImageTransferKeyParams)

Requires:
@tuya-miniapp/cloud-api≥1.6.0

Description

Get the device image transfer key and encryption level

Parameters

ParameterTypeRequiredDescription
YesRequest parameters

Return Value

Type: Promise<GetImageTransferKeyResult>
GetImageTransferKeyResult: device key, raw skill JSON, and current encryption level

Referenced Types

interfaceGetImageTransferKeyResultResult of getting the device image transmission key and encryption level
PropertyTypeDescription
tckeystring | nullDevice-level key; may be null
skillstringRaw JSON string of the device skill
levelnumberCurrent encryption level; defaults to 3 if not specified in skill

Examples

Request example

import { getImageTransferKey } from '@tuya-miniapp/cloud-api';

getImageTransferKey({
  devId: '6cbed8370dd694e247uk9u',
})
  .then(response => {
    console.log(response);
  })
  .catch(error => {
    console.error('Failed to get image transfer key:', error);
  });

Response example

{
  "tckey": "a1b2c3d4e5f6",
  "skill": "{\"tckey\":\"a1b2c3d4e5f6\",\"level\":3}",
  "level": 3
}

FAQ

Why does the call to cloud capabilities fail?

Before using this API, please ensure that the product to which the device belongs has enabled the Image Transfer advanced capability on the Tuya IoT Development Platform. Devices without this capability enabled cannot perform image upload or printing, and the API will return empty data or an error. If you need to use it, please create a product that supports image transfer/printing functions and enable the corresponding advanced capabilities in the product details. At the same time, the API depends on cloud capabilities, and authorization configuration is required in Development Settings - Cloud Capabilities on the Mini Program Developer Platform.