Vehicle Data API Tutorial
The Vehicle Data API lets you work with car data on any platform using a REST API. This tutorial will help you get started and show you how to work with it. By following the steps you will be receiving odometer data from the car simulator.
Endpoint and authentication changes
Note that this documentation reflects the latest best practice to use our REST API to retrieve vehicle data. If you have implemented the REST API
v5
endpoints, you can see the documentation on the REST API v5 (deprecated) page.
Endpoint URL
Note that the REST API base URL is https://sandbox.api.high-mobility.com/v1 when working with the car emulators and https://api.high-mobility.com/v1 for live vehicle data.
When you use the configuration snippets from the platform as shown in this tutorial, you will always be using the right URL automatically.
Create a Cloud App
In "Develop mode" you will find your sandbox apps. In the app details page you are going to set the permissions it requires, manage devices and link virtual vehicles from your garage to test. Let's see how to create a new app.
- Go to the Build tab, select "Develop mode" and click the big plus (+) button, select "Fleet" or "Driver" as the type and then select "Cloud App".
- In the left section, select the permissions that your app needs under the "Permissions" tap.
Note: Each permission must be manually added to each new app. - You can edit your app name and image from the menu icon next to the app name.
Create a Vehicle
In the "Simulation studio" you are able to create vehicles to link with your app and to test with the simulators. Go to the simulation studio and click the big plus (+) button.
Link Vehicle and Retrieve Access Token
Now to use the REST API you will need to create an Access Token. The technical process differs from fleet apps and apps that are built for individual vehicles owners, drivers.
- Follow the Fleet Clearance tutorial steps for fleet vehicles. You can get the VIN of the simulator from its log console.
- To perform a driver consent, implement the OAuth2 API and initiate the consent flow. Here's an article for doing this using Postman.
Send a Request
Once the simulator is open, fire away a request. For example to get the diagnostics state of the vehicle.
If you see that the app lacks permissions, you will need to revisit step two of the "Create an App" section of this document and select the appropriate permissions for your telematics command.
Auto API
Check out the Auto API OpenAPI Specification for all details.
const request = require('request')
request.get({
url: 'https://sandbox.api.high-mobility.com/v1/vehicle-data/autoapi-13/{vin}',
headers: {
Authorization: 'Bearer ' + accessToken
}
}, (error, response, body) => {
console.log('error:', error)
console.log('statusCode:', response && response.statusCode)
console.log('body:', body)
})