Getting Started with Node.js

The Node.js SDK is an npm (Node Package Manager) module named HMKit which enables your web application to use car APIs. This tutorial will show you how to work with it and help get you started. By following the steps you will be receiving odometer data from the car simulator.

Introduction and Setup


HMKit Node.js SDK requires node v10.0.0 or higher.


There are sample applications which showcase different features. These can be downloaded on the Samples page.

Add the module

If you already have a Node.js project, download the HMKit package with node package manager by running npm install hmkit.

Create an 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.

  1. 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".
  2. 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.
  3. 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.

Initialise the SDK

For a straightforward example of how to initialise the SDK, download the Node.js Scaffold sample app from GitHub.

  1. Once you have downloaded the SDK or sample app, go to the Apps tab and select the app you created in the previous steps.
  2. Select the "Client certificate" tab.
  3. Copy the snippet.
  4. Insert the snippet into into the Node.js project to initialize the SDK.

The client certificate code in your Node.js project should look something like this:

const HMKit = require('hmkit')

const hmkit = new HMKit('dGVzdM8GqScLvKy/EImRyejR5Ho/i1cFGcuU2yGjuwCtbRntVTRUQySPkIpY2b13yhTrmuk5I3yt8X4DqEMyZZ+NRRR+3Uwmmcs82r2tDPmoW6GJWGHJtTnJ/qIRcSXYBbkUfIsJPhdF91NPy5aM1JQV/cYGHEDH4mdUaXkUdyaMQLCa3yL6ALtUsDj7Vf7YQeiNweRny1RY', 'Ltx2fURBZdSWFSYc0EgbZoE3tnL1mqCEPZ5P1BuycyU=')

Send a Telematics Command

Once the emulator is open, fire away a Telematics command. For example, you can unlock the doors 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.

Read more about Telematics

Auto API

Check out the Node.js code reference for Auto API for further details on how to use vehicle commands.

const response = await hmkit.telematics.sendCommand(
    hmkit.commands.EngineStartStop.getState(), // command helper function
    accessCertificate // access certificate

console.log('bytes:', response.bytes()) // [11, 0, 99, 1, 1, 0, 15, 1, 0, 1, 1, 2, 0, 8, 0, 0, 1, 111, 205, 24, 26, 34]
console.log('object:', response.parse()) // EngineStartStopResponse { status: { value: 'active', timestamp: 2020-01-22T11:51:46.466Z } }

Deployment to Heroku

When deploying your application to a Heroku environment, check the default Node.js version and specify another if necessary (specifying Node.js version in Heroku). At this time, Node.js v6 is the default and you may specify another in your package.json file.

Add this snippet to package.json:

  "engines": {
    "node": "^8.4.0"