Data SDK
The DIMO Data SDK is used to access vehicle data via our APIs. Available in TypeScript, Python, and C#.
Last updated
Was this helpful?
The DIMO Data SDK is used to access vehicle data via our APIs. Available in TypeScript, Python, and C#.
Last updated
Was this helpful?
All of our SDKs are open-source. Check them out in more detail here:
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.
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');
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.
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
const vehicleJwt = await dimo.tokenexchange.getVehicleJwt({
...developerJwt,
tokenId: <vehicle_token_id>
});
For more information on Vehicle JWTs, see: Token Exchange ↗
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)
You're now ready to customize your app with the SDKs!