LogoLogo
DocsHomeSupportContact
  • Getting Started
    • Introduction
    • Build on DIMO
  • DEVELOPER GUIDE
    • Developer Overview
    • Developer Console
    • Authentication
    • DIMO Developer SDKs
      • Data SDK
      • Login with DIMO SDK
        • React Component
        • Login with DIMO Redirect
        • Core Functionalities
      • TypeScript: Transactions SDK
      • SDK Release Notes
    • Low Code Tools
      • n8n: Getting Started
    • Permissions Contract: SACD
    • DIMO Credits
    • Response Types
    • Rate Limits
    • Developer FAQ
    • Developer Changelogs
    • Troubleshooting Common Issues
  • API References
    • Overview of DIMO API
    • Attestation API
    • Device Definitions API
    • Identity API
      • Schema & Types
      • Scalars
      • Nodes & Objects
        • AftermarketDevice
        • AftermarketDeviceConnection
        • DCN
        • DCNConnection
        • DeveloperLicense
        • DeviceDefinition
        • Earning
        • EarningsConnection
        • Manufacturer
        • Sacd
        • SyntheticDevice
        • Vehicle
        • VehicleConnection
        • VehicleEarnings
        • UserRewards
      • Common Queries
    • Telemetry API
      • Schema & Types
      • Scalars
      • Nodes & Objects
        • Signals
        • SignalsLatest
      • Common Queries
    • Token Exchange API
    • Trips API
    • Valuations API
  • DIMO Hardware
    • Introduction
    • DIMO Hardware Application
    • DIMO Manufacturing License
    • Development & Certification
    • Audits & Assessments
      • Hardware & Security Audit
      • Customer Experience Assessment
      • Integration Testing & Quality Control
      • Final Approval
    • DIMO Device License
      • Device Minting Certificates
    • Essential Documents
      • Hardware & Security Audit Checklist
      • Approved Hardware Auditors
      • DIMO Memorandum of Understanding (MOU)
  • Additional References
    • Developer License
    • DIMO GraphQL Basics
  • Deprecated Resources
    • Guides
      • Developer Journey
      • Quick Start Guide
      • Hello World
      • Code Exchange Flow
    • Data Availability
Powered by GitBook
On this page
  • Pre-requisites
  • Using the Data SDKs

Was this helpful?

  1. DEVELOPER GUIDE
  2. DIMO Developer SDKs

Data SDK

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

PreviousDIMO Developer SDKsNextLogin with DIMO SDK

Last updated 1 month ago

Was this helpful?

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

  • TypeScript/NodeJS Data SDK: |

  • Python Data SDK: |

  • C# Data SDK: |

Pre-requisites

  • Sign in or sign up to the 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.

Using the Data SDKs

1

Install the SDK

npm install @dimo-network/data-sdk

# Or install with yarn
yarn add @dimo-network/data-sdk
pip install dimo-python-sdk
# Windows users:
Install-Package Dimo.Client

# Mac/ Linux users:
dotnet add package Dimo.Client
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');

Import the SDK:

from dimo import DIMO 

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.

dimo = DIMO("Production")

# Or:

dimo = DIMO("Dev")

Without Dependency Injection:

using Dimo.Client;

var dimoClient = new DimoClientBuilder().AddAllServices().Build();

With Dependency Injection:

using Dimo.Client;

services.AddDimoClient(options =>
{
    options.Environment = DimoEnvironment.Production;
});
3

Perform Auth Function Calls

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
auth_header = dimo.auth.get_token(
    client_id = '<client_id>',
    domain = '<redirect_uri>',
    private_key = '<api_key>'
)

# Store the Developer JWT from the auth_header dictionary
dev_jwt = auth_header["access_token"]

var auth = await dimoClient.AuthenticationService.GetTokenAsync(
    clientId: "<your client id>",
    domain: "<your domain>",
    privateKey: "<your private key>",
    address: "<your address>" // This value is the same as clientId
);

Console.WriteLine(auth.AccessToken);

Get Vehicle JWT

const vehicleJwt = await dimo.tokenexchange.getVehicleJwt({
  ...developerJwt,
  tokenId: <vehicle_token_id>
});
# Call to get a Vehicle JWT
get_vehicle_jwt = dimo.token_exchange.exchange(
    developer_jwt = dev_jwt, 
    token_id=<token_id> 
)

# Store the Vehicle JWT from the get_vehicle_jwt response
vehicle_jwt = get_vehicle_jwt['token']
var vehicleTokenId = 123456; // The token id of the vehicle
var vehicleJwt = await dimoClient.TokenExchangeService.GetPrivilegeTokenAsync(
    accessToken: auth.AccessToken,
    tokenId: vehicleTokenId,
    privileges: [ 
        PrivilegeSharing.AllTimeNoLocationData,
        PrivilegeSharing.Commands, 
        PrivilegeSharing.CurrentLocation, 
        PrivilegeSharing.AllTimeLocation 
    ]); // The privileges you want to get for the vehicle
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)
  latest_signals = dimo.telemetry.query(
  vehicle_jwt= vehicle_jwt,
  query= """
    query GetSignalsLatest {
      signalsLatest(tokenId: <insert_token_id>) {
        powertrainTransmissionTravelledDistance {
          timestamp
          value
        }
        powertrainType {
          timestamp
          value
        }
        lastSeen
      }
    }
  """
);

print(latest_signals)
var query = @"
  query GetSignalsLatest {
      signalsLatest(tokenId: <insert_token_id>) {
        powertrainTransmissionTravelledDistance {
          timestamp
          value
        }
        powertrainType {
          timestamp
          value
        }
        lastSeen
      }
    }
";

// Variables are optional
var variables = new
{
    VariableName = "VariableValue"
};

var result = await dimoClient.TelemetryService.ExecuteQueryAsync<TResponse>(query, variables, vehicleJwt.Token);

Console.WriteLine(result);
5

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

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 .

For more information on Vehicle JWTs, see:

Success!

🎉
Authentication
Token Exchange ↗
Github
npm
Github
PyPI
Github
NuGET
DIMO Developer Console ↗
Logonpm: @dimo-network/data-sdknpm
The TypeScript Data SDK on npm
Logodimo-python-sdkPyPI
The Python Data SDK on PyPI
LogoDimo.Client 1.0.5nuget
The .NET Data SDK on NuGET
A sample app configured in the DIMO Developer Console