Data SDK

The DIMO Data SDK is used to access vehicle data via our APIs. Available in TypeScript, Python, and C#.

All of our SDKs are open-source. Check them out in more detail here:

Pre-requisites

  • Sign in or sign up to the DIMO Developer Console ↗ and create a license to obtain a Client ID.

  • Generate and save your API Key and add at least one Redirect URI of your choice.

Requirements before using your Developer License

Using the Data SDKs

1

Install the SDK

npm install @dimo-network/data-sdk

# Or install with yarn
yarn add @dimo-network/data-sdk
The TypeScript Data SDK on npm
2

Import + Initiate the SDK

Import the SDK:

# ES Modules: 
import { DIMO } from '@dimo-network/data-sdk';

# Or Common JS
const { DIMO } = require('@dimo-network/data-sdk/dist/index.cjs';

Initiate the SDK depending on the environment of your interest. We currently support both Production and Dev environments, but recommend using Production at this time.

const dimo = new DIMO('Production');

# or

const dimo = new DIMO('Dev');
3

Perform Auth Function Calls

Use the credentials from your Developer Console application (Step 1) to obtain a Developer JWT, and a Vehicle JWT for vehicle tokenIds that have shared privileged vehicle access with you. You can learn more about these in Authentication.

The domain value is any of the configured redirectUri's you've added in the console.

The private_key value is the API Key you generated.

Get Developer JWT

const developerJwt = await dimo.auth.getToken({
  client_id: '<client_id>',
  domain: '<redirect_uri>',
  private_key: '<api_key>',
});

// The TS/JS data SDK references the "access_token" and formats it 
// in the format you need in later steps

Get Vehicle JWT

const vehicleJwt = await dimo.tokenexchange.getVehicleJwt({
  ...developerJwt,
  tokenId: <vehicle_token_id>
});

For more information on Vehicle JWTs, see: Token Exchange ↗

4

Make Your First API Call

Once authenticated with a Vehicle JWT, you're ready to make your first API call. Try with logging the following to your terminal:

const latestSignals = await dimo.telemetry.query({
  ...vehicleJwt,
  query: `
    query GetSignalsLatest {
      signalsLatest(tokenId: <insert_token_id>) {
        powertrainTransmissionTravelledDistance {
          timestamp
          value
        }
        powertrainType {
          timestamp
          value
        }
        lastSeen
      }
    }
  `
});

console.log(latestSignals)
5

Success! 🎉

You're now ready to customize your app with the SDKs!

Last updated

Was this helpful?