---
name: "getLogs"
mode: "api"
versionRequirements:
  - { name: "@ray-js/lock-sdk", version: "1.0.0" }
title: "getLogs - Get log record list."
summary: "Get log record list."
---

## getLogs

> [VERSION] @ray-js/lock-sdk >= 1.0.0

### Description

Get log record list

### Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `page` | `number` | No | Page number, default 1 |
| `pageSize` | `number` | No | Page size, default 50 |

### Return Value

Type: `Promise<GetLogsResult>`

Paginated log list (fields such as entry and timestamp are assembled by the implementation)

##### GetLogsResult

| Property | Type | Description |
| --- | --- | --- |
| `list` | `LogData[]` | Log data |
| `hasMore` | `boolean` | Has more |
| `total` | `number` | Total count |

### Referenced Types

##### `interface` LogData

| Property | Type | Description |
| --- | --- | --- |
| `logId` | `string` | Unique log ID |
| `time` | `number` | Event time (milliseconds timestamp) |
| `currentUser` | `boolean` | Whether related to the current logged-in user |
| `type` | `"alarm_record" \| "close_record" \| "unlock_record" \| "operation" \| "local_operation" \| "dev_bind"` | Log type |
| `operateType` | `string` | Only valid when the operation type field type equals operation |
| `userId` | `string` | Associated user ID |
| `dpId` | `number` | Associated DP numeric ID |
| `dpCode` | `string` | Associated DP code |
| `data` | `any` | Business data (DP value or other structure) |
| `userName` | `string` | Associated user nickname |
| `bindable` | `boolean` | Whether bindable (valid for unlock_record) |
| `unlockName` | `string` | Unlock method name (unlock_record) |
| `mediaInfo` | `MediaInfo[]` | Attachment media list |
| `unionUnlockInfo` | `UnionUnlockInfo[]` | Combination unlock members (unlock_record) |
| `closeValue` | `"UNDEFINED" \| "VOICE_REMOTE" \| "APP_REMOTE" \| "AUTO" \| "LOCAL_MANUAL" \| "FITTINGS" \| "APP" \| "GEO_FENCE"` | Lock method (close_record) |
| `localRecord` | `LocalUnlockMethodData \| LocalAddUserData \| LocalSettingData \| LocalOperateOtherData` | Local operation details (local_operation) |
| `isHijack` | `boolean` | Duress alarm |
| `unlockMethod` | `"finger" \| "face" \| "password" \| "card" \| "fingerVein" \| "hand" \| "eye"` | Unlock method type (unlock_record) |
| `matterRecord` | `Object` | Matter unlock record |

##### `interface` LocalUnlockMethodData

| Property | Type | Description |
| --- | --- | --- |
| `category` | `0 \| 1 \| 2` | Add/Delete/Update unlock methods |
| `unlockMethod` | `"finger" \| "face" \| "password" \| "card" \| "fingerVein" \| "hand" \| "eye" \| "remoteControl"` | Unlock method type or remote control |
| `unlockId` | `number` | Unlock method ID |
| `isRemoveAll` | `boolean` | Clear all unlock methods of this type |
| `userType` | `0 \| 1 \| 2 \| 3` | Operator type |
| `userId` | `number` | Operator ID |
| `toUserType` | `0 \| 1 \| 2 \| 3` | Target user type |
| `toUserId` | `number` | Target user ID |

##### `interface` LocalAddUserData

| Property | Type | Description |
| --- | --- | --- |
| `category` | `16 \| 17` | Local add/delete users |
| `userType` | `0 \| 1 \| 2 \| 3` | Operator type |
| `userId` | `number` | Operator ID |
| `toUserType` | `0 \| 1 \| 2 \| 3` | Target user type |
| `toUserId` | `number` | Target user ID |

##### `interface` LocalSettingData

| Property | Type | Description |
| --- | --- | --- |
| `category` | `32` | Local settings |
| `type` | `number` | Setting type |
| `data` | `number \| Uint8Array<ArrayBuffer \| SharedArrayBuffer>` | Parsed value or buffer |
| `originData` | `Uint8Array<ArrayBuffer \| SharedArrayBuffer>` | Raw DP buffer |
| `userType` | `0 \| 1 \| 2 \| 3` | Operator type |
| `userId` | `number` | Operator ID |
| `toUserType` | `0 \| 1 \| 2 \| 3` | Target user type |
| `toUserId` | `number` | Target user ID |

##### `interface` LocalOperateOtherData

| Property | Type | Description |
| --- | --- | --- |
| `category` | `number` | Operation category (numeric) |
| `type` | `number` | Operation type |
| `data` | `Uint8Array<ArrayBuffer \| SharedArrayBuffer>` | Operation data |
| `userType` | `0 \| 1 \| 2 \| 3` | Operator type |
| `userId` | `number` | Operator ID |
| `toUserType` | `0 \| 1 \| 2 \| 3` | Target user type |
| `toUserId` | `number` | Target user ID |

##### `type` UnlockMethodType

Unlock method business type literal

```typescript
export type UnlockMethodType =
  | "finger"
  | "face"
  | "password"
  | "card"
  | "fingerVein"
  | "hand"
  | "eye";
```

##### `type` MediaInfo

| Property | Type | Description |
| --- | --- | --- |
| `mediaPath` | `string` | Media logical path |
| `fileKey` | `string` | Object storage file key |
| `fileUrl` | `string` | Accessible URL |
| `mediaBucket` | `string` | Bucket name |
| `mediaKey` | `string` | Media object key |

##### `type` UnionUnlockInfo

| Property | Type | Description |
| --- | --- | --- |
| `userId` | `string` | User ID |
| `userName` | `string` | User nickname |
| `unlockName` | `string` | Unlock method name |
| `sn` | `number` | Protocol SN |
| `type` | `"finger" \| "face" \| "password" \| "card" \| "fingerVein" \| "hand" \| "eye"` | Type |

##### `type` LogData.matterRecord

| Property | Type | Description |
| --- | --- | --- |
| `sn` | `number` | Hardware ID |
| `source` | `number` | Unlock source 0: Tuya App Matter unlock 1: Third-party unlock |
| `type` | `number` | Unlock type 0: Unknown 1: Phone 2: Third-party PIN code |


### Examples

#### Example

```ts
import { getLogs } from '@ray-js/lock-sdk';
const logs = await getLogs({ offset: 0, limit: 20 });
```
