TypeScript: Data SDK

Fetch vehicle data using Data SDK

Overview

The DIMO Data SDK is an open-source TypeScript SDK built to facilitate developers in connecting to the API Services. The objective of the Data SDK is to handle things that interacts with the DIMO API.

Data SDK on NPM Registry

Getting Started

To get started with the Data SDK, you should always start by defining which API your application is interested in using. Depending on what you want access to, you may need the following:

  1. access_token: This should be the Developer's JWT. This uses the Developer License public credentials and the private key (API key) of the app. A developer would get this JWT on the backend through Auth.

  2. permissions_token: This is the 2nd layer of security around getting vehicle data. A developer would first need end users to grant permissions to the Developer License, and then get this JWT through Token Exchange. This is sometimes referred as privilege_token.

To learn more about the different JWTs and what they mean, visit the JWT section in Authentication.

Using the SDK

Installation

npm install @dimo-network/data-sdk

Import

The SDK supports either import (ES Modules) or require (Common JS):

import { DIMO } from '@dimo-network/data-sdk';
const { DIMO } = require('@dimo-network/data-sdk/dist/index.cjs';

Initialization

const dimo = new DIMO('Production');

Function Calls

Getting a Developer JWT

// Call to get a Developer JWT
const auth = await dimo.auth.getToken({
  client_id: '<client_id>',
  domain: '<domain>',
  private_key: '<api_key>',
});

Getting a Vehicle JWT

// Call to get a Permissions JWT
await dimo.tokenexchange.exchange({
  ...auth,
  privileges: [1,3,4],
  tokenId: <vehicle_token_id>
});

Contributions

https://github.com/DIMO-Network/data-sdk/blob/master/CONTRIBUTING.md

Last updated

Was this helpful?