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

## getWeatherDailyHistory

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

> 💡 This API depends on cloud capabilities; configure authorization in the Mini App Developer Platform (https://iot.tuya.com/miniapp/) under Development Settings > Cloud Capabilities. Note: Cloud capabilities are not available in the Developer Tools environment; package the app or use a real device for debugging.

### Description

Query historical weather by device ID

### Parameters

`Params`

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

### Return Value

Type: `Promise<Record<string, Weather>>`

GetWeatherDailyHistoryResult (keys are YYYY-MM-DD date strings, and values are the Weather object for that day; see type definitions and minituya return parameters for field meanings)

### Referenced Types

##### `interface` GetWeatherDailyHistoryParams

| Property | Type | Description |
| --- | --- | --- |
| `devId` | `string` | Device ID |
| `weatherFieldNames` | `string` | Weather fields, comma-separated (e.g., pm25); see the 'weatherFieldNames' enum values in the minituya documentation |
| `beginTime` | `number` | Start timestamp |
| `endTime` | `number` | End timestamp |
| `ip` | `string` | IP address |


### Examples

#### Request example

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

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

#### Response example

```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"
  }
}
```
