getDeviceCurrency(params: GetDeviceCurrencyParams)

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

Description

Get the device’s currently configured currency unit. This can be used to display the correct currency symbol with electricity costs in the UI. If the device has no currency configured, an empty string is returned.

Parameters

ParameterTypeRequiredDescription
YesRequest parameters

Return Value

Type: Promise<string>
Currency code (ISO 4217), e.g., CNY, USD; returns an empty string if not configured

Examples

Request example

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

getDeviceCurrency({ devId: 'vdevo123' })
  .then(currency => {
    console.log('Device currency:', currency); // e.g. "CNY"
  })
  .catch(error => {
    console.error('Failed to get device currency:', error);
  });

Response example

"CNY"

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 Electricity Statistics advanced capability on the Tuya IoT Development Platform. Products without this capability enabled cannot collect electricity consumption/cost data, and the API will return empty data or an error. If you need to use it, please create a product with electricity consumption/cost statistics 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.