Fetch the customer's data
Now that you are connected to the customer, you must pull their existing data. Fetching the customer's data is a two-step process.
Step 1: Search for all the companies associated with you
GET
in response, you will receive a list of all the companies that are connected to your network.
{
"data": {
"companies": [
{
"name": "Kuphal, Schoen and Maggio",
"company_id": "KT5124848",
"dot_ids": [],
"street": "87370 Nicolas Wall",
"city": "Lake Blairton",
"state": "IN",
"zip": "18773-8821"
}
]
},
"pagination": {
"per_page": 25,
"page_no": 1,
"total": 1
}
}
Now, proceed to step 2.
Step 2: Select the company and start tracking
From the response of the first endpoint, you must select the company for which you want to fetch the data or track. You must then make a call to the following endpoint to pull up the relevant information.
GET
https://api.gomotive.com/v1/freight_visibility/vehicle_association
The response will list all the vehicles that are available for tracking. The vehicles will be listed along with the distance from the location of interest.
{
"pagination": {
"per_page": 100,
"page_no": 1,
"total": 4
},
"data": {
"company_id": "KT7711525",
"dot_ids": [
"fn9wckg0ig",
"en0i9vff1k"
],
"integration_status": "enabled",
"vehicle_details": [
{
"vehicle_id": "1743",
"vehicle_name": "vehicle_a",
"eld_device_id": null,
"eld_identifier": null,
"trailer_id": "happy camper",
"driver": {
"id": 3280,
"first_name": "Haleigh",
"last_name": "Dibbert"
},
"located_at": "2020-04-07T18:50:27Z",
"description": "current location - 109.24 miles from San Francisco, CA",
"distance_origin": {
"value": 109.24,
"unit": "mi"
}
}
]
}
}
Note down the vehicle_id
, and proceed with the next step.
Step 3: Subscribe to the location
Now, that you know to which vehicle you want to subscribe to, you must make a POST call to the following endpoint:
POST
Things to remember when using this endpoint
- If you are subscribing the location of vehicle, follow these requirements:
- Vehicle must be owned by a company.
- Vehicle status must be 'active', and not 'deactivated'.
- This endpoint does not allow overlapping of tracking instances.
- If you are subscribing the location of an asset, follow these requirements:
- Asset status must be 'active', and not 'deactivated'.
- Every asset must have an asset gateway assigned to it.
- The query parameter start_time, must be less than 2 weeks from the current date.
- The minimum difference between the start_time and end_time must be 1 hour.
- The maximum difference between the start_time and the end_time must be 5 days.
in response, you will see the subscription ID for tracking.
{
"data": {
"tracking_subscription_id": 1426
}
}
You may continue to repeat this step for all the vehicles for which you want to track or subscribe their locations.
After subscribing to all the vehicles that you want to track, you may proceed to the last step.
Step 4: Fetch the location of all the subscribed vehicles
To view the locations of all the vehicles for which you've subscribed to, you must make the following APi call:
GET
https://api.gomotive.com/v1/freight_visibility/vehicle_locations
In response, you will see details for all the vehicles that you've subscribed to. Use this data to manage your fleet accordingly.
{
"data": {
"vehicle_details": [
{
"start_time": "2020-04-05T20:05:49Z",
"end_time": "2020-04-07T20:05:49Z",
"load_id": null,
"load_details": null,
"total_distance": null,
"initial_stop": null,
"final_stop": null,
"vehicle_location": {
"lat": 3,
"lon": 4,
"located_at": "2020-04-06T19:50:54Z",
"description": "10.0 km N of SF, CA"
},
"current_driver": {
"id": 4897,
"first_name": "Guiseppe",
"last_name": "Beatty",
"username": null,
"email": "2781ca4915aa@keeptruckin.com",
"driver_company_id": null,
"status": "active",
"role": "driver"
},
"vehicle_id": "32451",
"vehicle_name": "vehicle_13",
"company_id": "KT3206119",
"dot_ids": [],
"trailer_id": null,
"tracking_subscription_id": 1410
},
{
"start_time": "2020-04-05T20:05:49Z",
"end_time": "2020-04-07T20:05:49Z",
"load_id": "271",
"load_details": "is load",
"total_distance": {
"unit": "mi",
"value": 314
},
"initial_stop": {
"lat": 10,
"lon": 9
},
"final_stop": {
"lat": 8,
"lon": 7
},
"vehicle_location": {
"lat": 1,
"lon": 2,
"located_at": "2020-04-06T19:35:53Z",
"description": "20.0 km N of SF, CA"
},
"current_driver": null,
"vehicle_id": "45121",
"vehicle_name": "123eds",
"company_id": "KT3206119",
"dot_ids": [],
"trailer_id": "happy camper",
"tracking_subscription_id": 1409
}
]
},
"pagination": {
"per_page": 25,
"page_no": 1,
"total": 2
}
}
Updated 2 months ago