---
name: "getLightLibrariesData"
mode: "api"
versionRequirements:
  - { name: "@tuya-miniapp/cloud-api", version: "1.0.5" }
  - { name: "Mini Program Base Library", version: "2.18.1" }
---

## getLightLibrariesData

> [VERSION] @tuya-miniapp/cloud-api >= 1.0.5 | Mini Program Base Library >= 2.18.1

> 💡 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). Currently, cloud capabilities are not available in the Developer Tools environment; you must package the app or debug on a real device.
> The [Lighting Scene Library](https://developer.tuya.com/cn/docs/iot/scene_library?id=Kbn3oiww4klzq) can be used only after Advanced Capabilities are enabled on the Tuya Developer Platform Product Function Definition page; otherwise, cloud capability calls will fail.

### Description

Retrieve the lighting libraries (scene/music, etc.) bound to a device or group, and output the data in the libraries. For example, scene parameter information from the scene library.

### Parameters

`Params`

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `data` | `GetLightLibrariesDataParams` | Yes | Request parameters: bizId (business ID), bizType (business type: 0 = device, 1 = group), libType (library type: SCENE_LIB = scene library, MUSIC_LIB = music library, SCENE_IMAGE_LIB = scene image library), libDataType (library data type: 0 = all; if 0, the library is considered updatable if any data type has updates; 1 = basic data, provided by Tuya and bound at the panel uiId level; 2 = advanced data, maintained by users in the micro app backend). |

### Return Value

Type: `Promise<Plate[]>`

Plate[] (each element includes plateId, plateName, plateIcon, plateIconDisplayType, data, etc.; data contains group data and items, where items are entries from the Scene Library or Image Library; see the Plate, Data, and SceneLibraryItem tables in the documentation for field definitions)

##### Plate

| Property | Type | Description |
| --- | --- | --- |
| `plateIconDisplayType` | `number` | Group icon display type: 1 = A, 2 = B, 3 = C, 4 = D |
| `plateId` | `number` | Group ID |
| `data` | `DataItem[]` | Data in the group |
| `plateName` | `string` | Group name |
| `plateIconDisplaySize` | `string` | Group icon display size (for example, "343*100") |
| `plateIcon` | `string` | Group image |

### Referenced Types

##### `interface` GetLightLibrariesDataParams

| Property | Type | Description |
| --- | --- | --- |
| `bizId` | `string` | Business ID |
| `bizType` | `0 \| 1` | Business type: 0 = device, 1 = group |
| `libType` | `"SCENE_LIB" \| "MUSIC_LIB" \| "SCENE_IMAGE_LIB"` | Library type. SCENE_LIB: scene library. MUSIC_LIB: music library. SCENE_IMAGE_LIB: scene image library. |
| `libDataType` | `0 \| 1 \| 2` | Library data type. 0: all. If 0, the library is considered updatable when any data type has updates. 1: basic data—provided by Tuya and bound at the panel uiId level. 2: advanced data—maintained by users in the micro app backend. |

##### `interface` DataItem

| Property | Type | Description |
| --- | --- | --- |
| `iconDisplayType` | `number` | Icon display type of the data: 1: Class A, 2: Class B, 3: Class C, 4: Class D |
| `iconDisplaySize` | `string` | Icon display size of the data (e.g., "343*100") |
| `items` | `SceneLibraryItem[]` | Detailed data |

##### `type` SceneLibraryItem

| Property | Type | Description |
| --- | --- | --- |
| `sceneId` | `number` | Scene ID |
| `sceneName` | `string` | Scene name |
| `sort` | `number` | Sort order |
| `dpCode` | `string` | DP code |
| `icon` | `string` | Scene icon |
| `sceneData` | `string` | Scene parameters |
| `sceneDesc` | `string` | Scene description |


### Examples

#### Request example

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

getLightLibrariesData({
  bizId: 'vdevo167504******003',
  bizType: 0,
  libType: 'SCENE_LIB',
  libDataType: 0,
})
  .then((response) => {
    console.log(response);
  })
  .catch();
```

#### Response example

```json
[
  {
    "plateIconDisplayType": 0,
    "plateId": 2774,
    "data": [
      {
        "iconDisplayType": 3,
        "iconDisplaySize": "166*102",
        "items": [
          {
            "sceneName": "Good night",
            "icon": "https://images.tuyacn.com/light/library/icon/bixc94box***.png",
            "sort": 0,
            "sceneDesc": "50",
            "dpCode": "sceneData",
            "sceneId": 3537,
            "sceneData": "000e0d0000000000000000c80000"
          }
        ]
      }
    ],
    "plateName": "Cozy life",
    "plateIcon": ""
  },
  {
    "plateIconDisplayType": 0,
    "plateId": 2775,
    "data": [
      {
        "iconDisplayType": 3,
        "iconDisplaySize": "166*102",
        "items": [
          {
            "sceneName": "Ocean",
            "icon": "https://images.tuyacn.com/light/library/icon/bixbr00rh***.png",
            "sort": 4,
            "sceneDesc": "0",
            "dpCode": "sceneData",
            "sceneId": 3543,
            "sceneData": "1746460200f003e803e80000000046460200dc02bc03e800000000"
          }
        ]
      }
    ],
    "plateName": "Theme mood",
    "plateIcon": ""
  }
]
```
