---
name: "getPetBehaviorStatistics"
mode: "api"
versionRequirements:
  - { name: "@ray-js/ray", version: "1.6.27" }
title: "getPetBehaviorStatistics - Get statistical analysis of pet behavior patterns"
---

## getPetBehaviorStatistics

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

### Description

Get pet behavior indicator statistics

### Parameters

`Params`

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `data` | `GetPetBehaviorStatistics` | Yes | Request parameters: optional device, pet, date range; aggregation options such as dateType, timeAggrType, indicatorCode |

### Return Value

Type: `Promise<PetBehaviorStatistics>`

Promise resolving to statistic items (datetime, value)

##### PetBehaviorStatistics

| Property | Type | Description |
| --- | --- | --- |
| `datetime` | `string` | Statistics date |
| `value` | `number` | Indicator value |

### Referenced Types

##### `type` GetPetBehaviorStatistics

| Property | Type | Description |
| --- | --- | --- |
| `devId` | `string` | Device ID (query by device UUID) |
| `petId` | `number` | Pet ID |
| `beginDate` | `string` | Query start time, e.g., '2025072500' |
| `endDate` | `string` | Query end time, e.g., '2025072523' |
| `dateType` | `string` | Aggregation time: hour - hour, day - day, month - week |
| `timeAggrType` | `string` | Aggregation type: sum - SUM, average - AVG, count - NUM |
| `indicatorCode` | `string` | Indicator, e.g., defecation |


### Examples

#### Request example

```typescript
import { getPetBehaviorStatistics } from '@ray-js/ray';

getPetBehaviorStatistics({
  devId: 'vdevo******',
  petId: 1,
  beginDate: '2025072500',
  endDate: '2025072523',
  dateType: 'hour',
  timeAggrType: 'NUM',
  indicatorCode: 'defecation',
})
  .then((res) => {
    console.log(res);
  })
  .catch(console.error);
```

#### Response example

```json
{
  "datetime": "2025072500",
  "value": 3
}
```
