---
name: "getLogInSpecifiedTime"
mode: "api"
versionRequirements:
  - { name: "@ray-js/ray", version: "1.5.2" }
title: "getLogInSpecifiedTime - Get DP Logs for Specified Time Period"
---

## getLogInSpecifiedTime

> [VERSION] @ray-js/ray >= 1.5.2

### Description

Get DP reporting logs within a specified time range (supports pagination)

### Parameters

`Params`

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `params` | `IGetLogInSpecifiedTime` | Yes | Request parameters |

### Return Value

Type: `Promise<IGetLogInSpecifiedTimeResponse>`

Log data, including total count, DP log list, and whether there is a next page

##### IGetLogInSpecifiedTimeResponse

| Property | Type | Description |
| --- | --- | --- |
| `total` | `number` | Total data |
| `dps` | `Dp[]` | See DP |
| `hasNext` | `boolean` | Has next page |

### Referenced Types

##### `interface` IGetLogInSpecifiedTime

| Property | Type | Description |
| --- | --- | --- |
| `devId` | `string` | Device ID |
| `dpIds` | `string` | DP IDs, separated by commas |
| `offset` | `number` | Pagination offset |
| `limit` | `number` | Page size, up to 1000 |
| `sortType` | `"DESC" \| "ASC"` | Sort order: 'DESC' descending (default) or 'ASC' ascending |
| `startTime` | `string` | Query start timestamp (ms) |
| `endTime` | `string` | End timestamp for the query (ms) |

##### `type` Dp

| Property | Type | Description |
| --- | --- | --- |
| `timeStamp` | `number` | Timestamp format for reported data |
| `dpId` | `number` | DP ID |
| `timeStr` | `string` | Time format converted according to the device time zone: yyyy-MM-dd HH:mm:ss |
| `value` | `string` | DP value |


### Examples

#### Basic usage

```ts
import { getLogInSpecifiedTime } from '@ray-js/ray';

getLogInSpecifiedTime({
  devId: 'vdevo169477319679442',
  dpIds: '1,2',
  offset: 0,
  limit: 50,
  startTime: '1620000000000',
  endTime: '1629999999999',
  sortType: 'DESC',
}).then((res) => {
  console.log('Log data:', res);
}).catch((error) => {
  console.error(error);
});
```
