

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 從追蹤器取得裝置的位置歷史記錄
<a name="get-location-history"></a>

 您的 Amazon Location 追蹤器資源會維護所有追蹤裝置的位置歷史記錄 30 天。您可以從追蹤器資源擷取裝置位置歷史記錄，包括所有相關中繼資料。下列範例使用 AWS CLI或 Amazon Location APIs。

------
#### [ API ]

**使用 Amazon Location APIs 從追蹤器取得裝置位置歷史記錄**

從 Amazon Location Trackers APIs使用 `[GetDevicePositionHistory](https://docs.aws.amazon.com/location/latest/APIReference/API_WaypointTracking_GetDevicePositionHistory.html)`操作。

下列範例使用 API URI 請求，從名為 *ExampleTracker* 的追蹤器取得 *ExampleDevice* 的裝置位置歷史記錄，從 `19:05:07`（包含） 開始，並於 `19:20:07`（排除） 結束`2020–10–02`。

```
POST /tracking/v0/trackers/ExampleTracker/devices/ExampleDevice/list-positions 
Content-type: application/json
{
  "StartTimeInclusive": "2020-10-02T19:05:07.327Z",
  "EndTimeExclusive": "2020-10-02T19:20:07.327Z"
}
```

------
#### [ AWS CLI ]

**使用 AWS CLI 命令從追蹤器取得裝置位置歷史記錄**

使用 `[get-device-position-history](https://docs.aws.amazon.com/cli/latest/reference/location/get-device-position-history.html)` 命令。

下列範例使用 從名為 *ExampleTracker* 的追蹤器 AWS CLI 取得 *ExampleDevice* 的裝置位置歷史記錄，從 `19:05:07`（包含） 開始，並於 `19:20:07`（排除） 結束`2020–10–02`。

```
aws location \
    get-device-position-history \
        --device-id "ExampleDevice" \
        --start-time-inclusive "2020-10-02T19:05:07.327Z" \
        --end-time-exclusive "2020-10-02T19:20:07.327Z" \
        --tracker-name "ExampleTracker"
```

------