exportDeviceData(params: ExportDeviceDataParams)

Requires:
@tuya-miniapp/cloud-api≥1.3.0
Additional notesRead the full notes
This API depends on cloud capabilities. In the Mini App Developer Platform, go to Development Settings - Cloud Capabilities to configure authorization. Before using this API, ensure the product to which the device belongs has enabled the advanced capability **Power Consumption Statistics** on the Tuya IoT Development Platform. Products that have not enabled this capability cannot collect energy consumption/electricity cost data; the API will return empty data or errors. To use it, create a product with energy consumption/electricity cost statistics and enable the corresponding advanced capability in the product details.

Description

Export the device's energy data for a specified time range and send it to the designated email address. Multiple indicators are supported in a single export. The export task is asynchronous: a successful response only means the task was submitted; the email will be sent after background processing.

Parameters

ParameterTypeRequiredDescription
YesRequest parameters

Return Value

Type: Promise<boolean>
Whether the export task was submitted successfully; returning true only means the task was submitted. Email delivery is asynchronous and may be delayed.

Referenced Types

enumDateType
ValueActual ValueDescription
DateType.HourhourHour-level granularity; date format is `YYYYMMDDHH`, e.g., `2026010108`
DateType.DaydayDaily granularity, date format `YYYYMMDD`, e.g., `20260101`
DateType.MonthmonthMonthly granularity, date format `YYYYMM`, e.g., `202601`
enumIndicatorCode
ValueActual ValueDescription
IndicatorCode.EleUsageele_usageElectricity consumption
IndicatorCode.EleCostele_costElectricity bill

Valid Values

DateType
ValueDescriptionSince
hourHour-level granularity; date format is `YYYYMMDDHH`, e.g., `2026010108`-
dayDaily granularity, date format `YYYYMMDD`, e.g., `20260101`-
monthMonthly granularity, date format `YYYYMM`, e.g., `202601`-
IndicatorCode
ValueDescriptionSince
ele_usageElectricity consumption-
ele_costElectricity bill-

Examples

Request example

import { exportDeviceData, IndicatorCode, DateType } from '@tuya-miniapp/cloud-api';

exportDeviceData({
  devId: 'vdevo123',
  dateType: DateType.Month,
  beginDate: '202601',
  endDate: '202603',
  email: 'demo@*.com',
  indicatorCodes: [IndicatorCode.EleUsage, IndicatorCode.EleCost],
})
  .then(result => {
    console.log('Export task submitted successfully:', result);
  })
  .catch(error => {
    console.error('Export task submission failed:', error);
  });

Response example

true

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.