---
name: "exportStatistics15min"
mode: "kit"
versionRequirements:
  - { name: "@tuya-miniapp/cloud-api", version: "1.0.5" }
---

## exportStatistics15min

> [VERSION] @tuya-miniapp/cloud-api >= 1.0.5

> 💡 该接口为云能力，需开通授权后使用，关于云能力可[查看文档](/cn/miniapp/common/desc/tech-stack/api)。
> 注意：目前云能力在「开发者工具」环境无法使用，需要打包后或真机调试使用。

### 描述

15 分钟为时间间隔，导出设备指定日期的统计数据。

### 参数

`Params`

| 参数 | 类型 | 必填 | 默认值 | 描述 |
| --- | --- | --- | --- | --- |
| `data` | `IGetStatisticsExport15min` | 是 | - | 请求体 |

### 引用对象

##### `type` IGetStatisticsExport15min

按 15 分钟导出：在导出公共字段上增加单日 `date`。

```typescript
export type IGetStatisticsExport15min = ICommonGetStatisticsExport & IDate;
```

##### `type` ICommonGetStatisticsExport

导出类接口（小时/天/月）的公共请求字段。
`dpExcelQuery` 可传 `IDpExcelQuery` 或由 `JSON.stringify` 得到的等价字符串。

| 属性 | 类型 | 描述 |
| --- | --- | --- |
| `email` | `string` | 接收导出文件的邮箱 |
| `lang` | `string` | 多语言标识，例如 `cn`、`en`；默认 `en` |
| `devId` | `string` | 设备 ID |
| `dpExcelQuery` | `IDpExcelQuery[] \| string` | 导出列定义；传对象数组时 SDK 会序列化为 JSON 字符串再上报。 示例数组（概念示意）： `[{"dpId":"101","name":"华氏度转摄氏度","handler":"temperatureF2C"},{"dpId":"101","name":"摄氏度转华氏度","handler":"temperatureC2F"}]` 注意：minituya 文档表格中该列名为 `title`，示例与 SDK 类型使用 `name`。 |
| `auto` | `number` | 数据填充策略，默认 `0`（与区间查询含义一致） |
| `keepScalaPoint` | `boolean` | 小数位是否与 `scale` 对齐；默认 `false`（注意拼写为 `keepScalaPoint`） |
| `type` | `"sum" \| "avg" \| "minux" \| "max" \| "min" \| "count" \| "recent"` | 统计类型，默认 `sum` - `sum`：时段内上报值累加，适用于累计量。 - `minux`：本时段最大值减去上一时段最大值，表示增量/用量（历史拼写，非 `minus`）。 - `avg`：累加后除以上报次数，得平均值。 - `min` / `max`：时段内最小值 / 最大值。 - `count`：时段内上报次数。 - `recent`：最近一次统计值。 |
| `title` | `string` | 邮件标题；不传时使用 SDK 内默认标题 |

##### `type` IDate

单日查询：自然日，格式 `yyyyMMdd`（与 15min/小时区间接口搭配）。

| 属性 | 类型 | 描述 |
| --- | --- | --- |
| `date` | `string` | 要查询的日期，`yyyyMMdd`，例如 `20230511` |

##### `type` IDpExcelQuery

导出 Excel 邮件中的列配置；对象数组在请求前会被 `JSON.stringify`（见 `exportStatistics*` 实现）。

| 属性 | 类型 | 描述 |
| --- | --- | --- |
| `dpId` | `number \| string` | 列对应的 DP ID |
| `name` | `string` | 导出到 Excel 的列标题 |
| `handler` | `string` | 列数据转换；支持 `temperatureF2C`（华氏度转摄氏度）、`temperatureC2F`（摄氏度转华氏度）、 `cubicMeterToGallon`（立方米转加仑）、`gallonToCubicMeter`（加仑转立方米）。 |


### 示例代码

#### 请求示例

```typescript
import { exportStatistics15min } from '@tuya-miniapp/cloud-api';

exportStatistics15min({
  devId: 'vdevo161733425146241',
  email: 'xxxdemo@*.com',
  dpExcelQuery: [{ dpId: 18, name: 'excel数据列标题' }],
  date: '20230510',
  type: 'avg',
  lang: 'cn',
  title: '这是一个标题',
})
  .then((response) => {
    console.log(response);
  })
  .catch();
```

#### 返回示例

```json
true
```
