npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@dimo-network/data-sdk

v1.2.2

Published

DIMO Data SDK for JavaScript

Downloads

160

Readme

GitHub Actions Workflow Status GitHub top language GitHub License Downloads Discord X (formerly Twitter) URL

DIMO Data SDK

This is an official DIMO Data SDK written in TypeScript. The objective of this project is to make our API more accessible to the general public.

Installation

Use npm:

npm install @dimo-network/data-sdk

or use yarn instead:

yarn add @dimo-network/data-sdk

Unit Testing

Run npm test or npm run test to execute the Jest tests.

API Documentation

Please visit the DIMO Developer Documentation to learn more about building on DIMO and detailed information on the API.

How to Use the SDK

Import the SDK library:

import { DIMO } from '@dimo-network/data-sdk';

Initiate the SDK:

const dimo = new DIMO('Production');

Developer Registration

As part of the authentication process, you will need to obtain a Developer License via the DIMO Developer Console. To get started with registration, follow the steps below:

  1. Sign up on the DIMO Developer Console.
  2. Get DIMO Credits (DCX) either by paying in your local currency (via Stripe) or paying with a balance (if you have one).
  3. Click on Create app and fill out the details about your project namespace (external-facing, e.g. Drive2Survive LLC.) and your application name (internal, e.g. app-prod)
  4. Generate an API key and add in your preferred redirect URI.

Authentication

The SDK provides you with all the steps needed in the Authentication Flow to obtain a Developer JWT.

Prerequisites for Authentication

  1. A valid Developer License with a client_id
  2. A valid API key, generated via the Developer Console
  3. A proper project set up with TypeScript.

API Authentication

(Option 1 - PREFERRED) getToken Function

This is a utility function call to get a Developer JWT in one step:

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

Once you have the developerJwt, you'll have access to the DIMO API endpoints. For endpoints that require the authorization headers, you can simply pass the results.

// Pass the developerJwt object to a protected endpoint
await dimo.user.get(developerJwt);

// Pass the developerJwt object to a protected endpoint with body parameters
await dimo.tokenexchange.exchange({
  ...developerJwt,
  privileges: [4],
  tokenId: <vehicle_token_id>
});
(Option 2) Credentials.json File

By loading a valid .credentials.json, you can easily call dimo.authenticate() if you prefer to manage your credentials differently. Instead of calling the Auth endpoint, you would directly interact with the SDK main class.

Start by navigating to the SDK directory that was installed, if you used NPM, you can execute npm list -g | dimo to find the directory. In the root directory of the SDK, there will be .credentials.json.example - simply remove the .example extension to proceed with authentication:

// After .credentials.json are provided
const developerJwt = await dimo.authenticate();
// The rest would be the same as option 1

Querying the DIMO REST API

The SDK supports async await and your typical JS Promises. HTTP operations can be utilized in either ways:

// Async Await
async function countCars() {
  try {
    let response = await dimo.identity.countDimoVehicles();
    // Do something with the response
  }
  catch (err) { /* ... */ }
}
countCars();
// JS Promises
dimo.identity.countDimoVehicles().then((result) => {
    return result;
  }).catch((err) => {
  /* ...handle the error... */
});

Query Parameters

For query parameters, simply feed in an input that matches with the expected query parameters:

dimo.devicedefinitions.search({
  query: '<query>',
  makeSlug: '<makeSlug>',
  year: 2021
});

Path Parameters

For path parameters, simply feed in an input that matches with the expected path parameters:

dimo.attestation.createVinVC({
  ...vehicle_jwt,
  tokenId: 117315,
  force: false
})

Vehicle JWT

As the 2nd leg of the API authentication, applications may exchange for short-lived Vehicle JWT for specific vehicles that granted permissions to the app. This uses the DIMO Token Exchange API.

For the end users of your application, they will need to share their vehicle permissions via the DIMO Mobile App or via your implementation of Login with DIMO or even by sharing on the Vehicle NFT directly. Once vehicles are shared, you will be able to get a Vehicle JWT.

const vehicle_jwt = await dimo.tokenexchange.exchange({
  ...auth,
  privileges: [1, 5],
  tokenId: <vehicle_token_id>
});

// Vehicle Status uses privId 1
await dimo.devicedata.getVehicleStatus({
  ...vehicle_jwt,
  tokenId: <vehicle_token_id>
});

// Proof of Movement Verifiable Credentials uses privId 4
await dimo.attestation.createPomVC({
  ...vehicle_jwt,
  tokenId: <vehicle_token_id>
})

// VIN Verifiable Credentials uses privId 5
await dimo.attestation.createVinVC({
  ...vehicle_jwt,
  tokenId: <vehicle_token_id>
});

Querying the DIMO GraphQL API

The SDK accepts any type of valid custom GraphQL queries, but we've also included a few sample queries to help you understand the DIMO GraphQL APIs.

Authentication for GraphQL API

The GraphQL entry points are designed almost identical to the REST API entry points. For any GraphQL API that requires auth headers (Telemetry API for example), you can use the same pattern as you would in the REST protected endpoints.

const vehicleJwt = await dimo.tokenexchange.exchange({
  ...vehicleJwt,
  privileges: [1, 3, 4],
  tokenId: <vehicle_token_id>
});

const something = await dimo.telemetry.query({
  ...vehicleJwt,
  query: `
    query {
      some_valid_GraphQL_query
    }
  `
});

Getting a Vehicle's VIN

In order to get to the VIN of a given vehicle, your application (aka Developer License) will need permissions to view VIN credentials (Privilege ID: 5). As long as you have permissions to view the vehicle's VIN, simply call the getVin utility function.

const getVin = async(vehicle_jwt: any) => {
    return await dimo.telemetry.getVin({
        ...vehicle_jwt,
        tokenId: <vehicle_token_id>
    });
}

This utility function streamlines two calls: Creating a VIN VC on Attestation API and Getting the Latest VIN VC on Telemetry API.

Send a custom GraphQL query

To send a custom GraphQL query, you can simply call the query function on any GraphQL API Endpoints and pass in any valid GraphQL query. To check whether your GraphQL query is valid, please visit our Identity API GraphQL Playground or Telemetry API GraphQL Playground.

const yourQuery = `{ 
    vehicles (first:10) {
      totalCount
    }
}`;

const totalNetworkVehicles = await dimo.identity.query({
  query: yourQuery
});

This GraphQL API query is equivalent to calling dimo.identity.countDimoVehicles().

How to Contribute to the SDK

Read more about contributing here.