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

## getOutdoorsTracksSegments

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

> 💡 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).
> Note: Currently, cloud capabilities are not available in the Developer Tools environment; you must package the app or debug on a real device.

### Description

Paginated retrieval of device track segments. The difference between end time and start time must be ≤ 7 days. Up to 1000 segments are returned per call. If the number of segments in the time range exceeds 1000, the first 1000 segments are returned along with the start ID for the next page.

### Parameters

`Params`

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `data` | `GetOutdoorsTracksSegmentsParams` | Yes | Request body |

### Return Value

Type: `Promise<TrackSegment[]>`

GetOutdoorsTracksSegmentsResult (see type definitions and the minituya return table for field meanings)

##### TrackSegment

| Property | Type | Description |
| --- | --- | --- |
| `deviceId` | `string` | Device ID |
| `segmentList` | `SegmentItem[]` | List of track segments |
| `lastId` | `number` | If there is a next page, the start ID for the next page |
| `hasMore` | `boolean` | Whether there is a next page |

### Referenced Types

##### `type` GetOutdoorsTracksSegmentsParams

| Property | Type | Description |
| --- | --- | --- |
| `deviceId` | `string` | Device ID |
| `startTime` | `number` | Start time, 13-digit timestamp |
| `endTime` | `number` | End time, 13-digit timestamp |
| `lastId` | `number` | Start ID for the next page; leave empty on the first request |
| `needRated` | `boolean` | Scale conversion |
| `lessMileage` | `number` | Return only tracks with mileage greater than lessMileage |

##### `type` SegmentItem

| Property | Type | Description |
| --- | --- | --- |
| `startTime` | `number` | Segment start time (13-digit timestamp) |
| `endTime` | `number` | Segment end time (13-digit timestamp) |
| `duration` | `number` | Duration |
| `speed` | `number` | Speed |
| `mileage` | `number` | Mileage |
| `battery` | `number` | Battery level |


### Examples

#### Request example

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

getOutdoorsTracksSegments({
  deviceId: 'vdevo16245017293',
  startTime: 1625198100154,
  endTime: 1625198190154,
})
  .then((response) => {
    console.log(response);
  })
  .catch();
```

#### Response example

```json
{
  "deviceId": "vdevo16245017293****",
  "segmentList": [
    {
      "endTime": 1625198190154,
      "battery": 5,
      "speed": 100,
      "duration": 3000,
      "startTime": 1625198100154,
      "mileage": 10
    }
  ],
  "hasMore": false
}
```
