getWeatherDailyHistory(data: GetWeatherDailyHistoryParams)

Requires:
@tuya-miniapp/cloud-api≥1.0.5

Description

Query historical weather by device ID

Parameters

ParameterTypeRequiredDescription
YesRequest 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

interfaceWeatherField set for a single day's weather: `date` and `localDate` are as documented; other keys correspond to the requested `weatherFieldNames`.
PropertyTypeDescription
datestringformatDate, e.g., 2023-10-24
localDatenumberTimestamp, e.g., 1698076800000

Examples

Request example

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

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