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

## getMessageList

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

### 描述

消息列表查询

### 参数

`Params`

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

### 引用对象

##### `type` QueryGetMessageList

| 属性 | 类型 | 描述 |
| --- | --- | --- |
| `sourceIds` | `string[]` | 设备 id 列表 |
| `limit` | `number` | 请求数量 |
| `offset` | `number` | 请求的偏移量（分页） |

##### `interface` VisionBoxMessage

| 属性 | 类型 | 描述 |
| --- | --- | --- |
| `msgTypeContent` | `string` | 消息类型内容 |
| `msgContent` | `string` | 消息内容 |
| `time` | `number` | 时间戳 |
| `msgTitle` | `string` | 消息标题 |
| `dateTime` | `string` | 日期时间字符串 |
| `attachPics` | `string` | 附件图片 |
| `id` | `number` | 消息主键 id |
| `idStr` | `string` | 消息 id 字符串形式 |
| `homeId` | `number` | 家庭 id |
| `msgSrcId` | `string` | 消息来源 id |
| `businessKey` | `string` | 业务密钥字段 |


### 示例代码

#### 请求示例

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

getMessageList({ sourceIds: ['vdevo1'], limit: 20, offset: 0 })
  .then((res) => console.log(res))
  .catch(console.error);
```

#### 返回示例

```json
{
  "pageNo": 1,
  "datas": [
    {
      "msgTypeContent": "4",
      "msgContent": "{}",
      "time": 1700000000000,
      "msgTitle": "示例消息",
      "dateTime": "2024-01-01 12:00:00",
      "attachPics": "",
      "id": 1,
      "idStr": "1",
      "homeId": 194137,
      "msgSrcId": "src-1",
      "businessKey": "******"
    }
  ],
  "totalCount": 1,
  "class": "4"
}
```
