- Navigation GuideYou are on a Command (operation) page with structural examples. Use the navigation breadcrumb if you would like to return to the Client landing page.
GetDevicePositionCommand
Retrieves a device's most recent position according to its sample time.
Device positions are deleted after 30 days.
Example Syntax
Use a bare-bones client and the command you need to make an API call.
import { LocationClient, GetDevicePositionCommand } from "@aws-sdk/client-location"; // ES Modules import
// const { LocationClient, GetDevicePositionCommand } = require("@aws-sdk/client-location"); // CommonJS import
const client = new LocationClient(config);
const input = { // GetDevicePositionRequest
TrackerName: "STRING_VALUE", // required
DeviceId: "STRING_VALUE", // required
};
const command = new GetDevicePositionCommand(input);
const response = await client.send(command);
// { // GetDevicePositionResponse
// DeviceId: "STRING_VALUE",
// SampleTime: new Date("TIMESTAMP"), // required
// ReceivedTime: new Date("TIMESTAMP"), // required
// Position: [ // Position // required
// Number("double"),
// ],
// Accuracy: { // PositionalAccuracy
// Horizontal: Number("double"), // required
// },
// PositionProperties: { // PositionPropertyMap
// "<keys>": "STRING_VALUE",
// },
// };
GetDevicePositionCommand Input
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
DeviceId Required | string | undefined | The device whose position you want to retrieve. |
TrackerName Required | string | undefined | The tracker resource receiving the position update. |
GetDevicePositionCommand Output
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
$metadata Required | ResponseMetadata | Metadata pertaining to this request. |
Position Required | number[] | undefined | The last known device position. |
ReceivedTime Required | Date | undefined | The timestamp for when the tracker resource received the device position. Uses ISO 8601 format: |
SampleTime Required | Date | undefined | The timestamp at which the device's position was determined. Uses ISO 8601 format: |
Accuracy | PositionalAccuracy | undefined | The accuracy of the device position. |
DeviceId | string | undefined | The device whose position you retrieved. |
PositionProperties | Record<string, string> | undefined | The properties associated with the position. |
Throws
Name | Fault | Details |
---|
Name | Fault | Details |
---|---|---|
AccessDeniedException | client | The request was denied because of insufficient access or permissions. Check with an administrator to verify your permissions. |
InternalServerException | server | The request has failed to process because of an unknown server error, exception, or failure. |
ResourceNotFoundException | client | The resource that you've entered was not found in your AWS account. |
ThrottlingException | client | The request was denied because of request throttling. |
ValidationException | client | The input failed to meet the constraints specified by the AWS service. |
LocationServiceException | Base exception class for all service exceptions from Location service. |