GPS Tracking
GPS tracking allows locating vehicles and assets using GPS devices and external providers services. This guide covers integrating GPS based tracking into your applications by leveraging the Motion Tracking Service (MTS) APIs and its default provider integrations.
Consent
For GPS-based tracking, consent is obtained upfront from vehicle owners through paperwork during supplier onboarding.
Integrating smartphone tracking with your applications involves the following steps:
- Create a track: Use CreateTrack to create a new tracking request.
- Start/Stop tracking: Use UpdateTrack to initiate tracking a device to obtain real-time or periodic location data, or to stop tracking a device when it is no longer needed or at the end of the consent period.
- Retrieve Data: GetTraceData to retrieve the device location tracking data.
Call CreateGPSTrack to initiate tracking for a device. The request requires the externalRefId. Note that any created tracks not started within 24 hours will be deleted. See the request body parameters below.
Parameter | Description |
---|---|
vehicleNumber* | A unique id or the GPS device. |
externalRefId | A user-provided id that will be mapped to the trackingId. |
defaultStart | The start of the track. If the flag is passed as true, tracking will start and the API will return a 202. If it's passed as false, tracking won't start and and the response will be 201. |
expiry | The track expiration. The maximum allowed time for the track to stop is 60 days if stop track API is not called. Examples: 2 hours -> 2h, 1 day -> 1d, 50 seconds -> 50s, 3 hours 4 minutes 7 seconds -> 3h4m7s. |
callback | The callback details at which user will receive callback response. |
callback.url* | URL to receive the callback response. Must match the pattern https?://(www\.)?[-a-zA-Z0-9@:%._\+#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.#?&//=]*) |
callback.meta | A meta object that will be part of the callback body. Optional and can contain user-defined data. |
callback.secret | Base64 encoded HMAC secret key. |
Example Request
Example Response
The response includes the data object containing the trackId and trackName.
Call UpdateGPSTrack to start or stop tracking by passing START or STOP in request body. See the request parameters below. You can start or stop a track using the trackID or trackName obtained from the CreateGPSTrack request.
Path Parameters
Parameter | Data Type | Description |
---|---|---|
trackId* or trackName* | string | The unique id for the MTS track. |
Body Parameters
Parameter | Description |
---|---|
operation* | Example: START. Enum: [START, STOP]. The operation to perform. |
callback | Object containing callback details. |
callback.url* | URL to receive the callback response. Must match the pattern https?://(www\.)?[-a-zA-Z0-9@:%._\+#=]{2,256}\.[a-z]{2,4}\b([-a-zA-Z0-9@:%_\+.#?&//=]*) |
callback.meta | A meta object that will be part of the callback body. Optional and can contain user-defined data. |
callback.secret | Base64 encoded HMAC secret key. |
The example request below starts tracking:
On success, the API returns a 202 response with an id.
After the tracking has started, an application will need to call GetTraceData using the trackName or trackId to get the trace points of the device in geojson format.
Developers can use the following APIs to retrieve the tracking status. These APIs returns the status of tracking (started/stopped) associated with the given deviceId with details such as trackingID and the duration of tracking.