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

## getStatisticsRang15min

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

> 💡 This API is a cloud capability and requires authorization before use. For details on cloud capabilities, see the [documentation](/cn/miniapp/common/desc/tech-stack/api).
> Note: Currently, cloud capabilities are not available in the Developer Tools environment; you must package the app or debug on a real device.

### Description

With a 15-minute interval, retrieve the device's statistics for the date range.

### Parameters

`Params`

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `data` | `IGetStatisticsRang` | Yes | Request body |

### Return Value

Type: `Promise<IStatisticsData>`

IStatisticsData (keys are time slices, values are statistic strings; missing data may be `#`, etc.—see the response example in the docs)

### Referenced Types

##### `type` IGetStatisticsRang

15-min/hour granularity: single day + common statistics fields (e.g., `getStatisticsRang15min`, `getStatisticsRangHour`).

```typescript
export type IGetStatisticsRang = ICommonGetStatisticsRang & IDate;
```

##### `type` ICommonGetStatisticsRang

Common fields for range statistics/export requests (combined with `IDate`, `IStartEndDay`, `StartEndMonth` to form concrete input types).

| Property | Type | Description |
| --- | --- | --- |
| `devId` | `string` | Device ID |
| `dpId` | `number \| string` | Data point ID (DP) to be aggregated |
| `type` | `"sum" \| "avg" \| "minux" \| "max" \| "min" \| "count" \| "recent"` | Statistic type; if omitted, each API has a default in `index` (mostly `sum`). Aggregation algorithm, aligned with minituya 'Statistic Type Description'. - `sum`: Sum of values reported within the interval; suitable for cumulative metrics. - `minux`: Current interval maximum minus previous interval maximum, representing increment/consumption (historical spelling, not `minus`). - `avg`: Sum divided by the number of reports to obtain the average. - `min` / `max`: Minimum / maximum within the interval. - `count`: Number of reports within the interval. - `recent`: Most recent statistic value. |
| `auto` | `number` | Data filling strategy, consistent with the cloud-side agreement; default is `0` for all APIs. Refer to the IoT platform’s Smart Metering/Open API specs for the exact enum values. |
| `keepScalaPoint` | `boolean` | When `true`, decimal places align with the device DP `scale`; default is `false`. |

##### `type` IDate

Single-day query: calendar day, format `yyyyMMdd` (used with 15-min/hour range APIs).

| Property | Type | Description |
| --- | --- | --- |
| `date` | `string` | Date to query, `yyyyMMdd`, e.g., `20230511` |


### Examples

#### Request example

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

getStatisticsRang15min({
  devId: 'vdevo161733425146241',
  dpId: '18',
  date: '20230511',
  type: 'avg',
})
  .then((response) => {
    console.log(response);
  })
  .catch();
```

#### Response example

```json
{
  "202105260000": "1312.02",
  "202105260015": "1249.49",
  "202105262345": "#",
  "...": "..."
}
```
