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

## getWeatherDailyHistory

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

> 💡 接口依赖云能力，需在 [小程序开发者平台](https://iot.tuya.com/miniapp/)开发设置-云能力进行授权配置。
> 注意：目前云能力在「开发者工具」环境无法使用，需要打包后或真机调试使用。

### 描述

根据设备 id 查询历史天气

### 参数

`Params`

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

### 引用对象

##### `interface` GetWeatherDailyHistoryParams

| 属性 | 类型 | 描述 |
| --- | --- | --- |
| `devId` | `string` | 设备 ID |
| `weatherFieldNames` | `string` | 天气字段，多个用逗号隔开（如 pm25）；枚举值见 minituya 文档「weatherFieldNames 枚举值」 |
| `beginTime` | `number` | 开始时间戳 |
| `endTime` | `number` | 结束时间戳 |
| `ip` | `string` | IP 地址 |


### 示例代码

#### 请求示例

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

getWeatherDailyHistory({
  devId: '6cbed8370dd694e247uk9u',
  ip: '',
  weatherFieldNames: 'pm25',
  beginTime: 1698028537000,
  endTime: 1698287737698,
})
  .then((response) => {
    console.log(response);
  })
  .catch();
```

#### 返回示例

```json
{
  "2023-10-24": {
    "date": "2023-10-24",
    "localDate": 1698076800000,
    "pm25": "31.82"
  },
  "2023-10-25": {
    "date": "2023-10-25",
    "localDate": 1698163200000,
    "pm25": "50.93"
  }
}
```
