Server SDK
Get Vehicle Data From DIMO APIs
DIMO Server SDK is a suite of Developer SDKs that allows app developers to access data from the DIMO APIs. Developers have a choice between several popular programming languages such as NodeJS, Typescript, Python, and C#.
How It Works
1
Install the SDK
- JS/TS
- Python
- C#
npm install @dimo-network/data-sdk
yarn add @dimo-network/data-sdk
pip install dimo-python-sdk
- Windows Users:
Install-Package Dimo.Client
- Mac Users:
dotnet add package Dimo.Client
2
Initiate the SDK
- JS/TS
- Python
- C#
import { DIMO } from '@dimo-network/data-sdk';
const dimo = new DIMO('Production');
from dimo import DIMO
dimo = DIMO("Production")
using Dimo.Client;
var dimoClient = new DimoClientBuilder().AddAllServices().Build();
3
Authenticate to get a Developer JWT
Using Your Developer License details, you will first need to authenticate using your client_id
, redirect_uri
, and api_key
.
- JS/TS
- Python
- C#
const developerJwt = await dimo.auth.getDeveloperJwt({
client_id: '<client_id>',
domain: '<redirect_uri>',
private_key: '<api_key>',
});
auth_header = dimo.auth.get_dev_jwt(
client_id = '<client_id>',
domain = '<redirect_uri>',
private_key = '<api_key>'
)
dev_jwt = auth_header["access_token"]
var auth = await dimoClient.AuthenticationService.GetTokenAsync(
clientId: "<client_id>",
domain: "<redirect_uri>",
privateKey: "<api_key>"
);
var devJwt = auth.AccessToken;
4
Getting a Vehicle JWT
- JS/TS
- Python
- C#
const vehicleJwt = await dimo.tokenexchange.getVehicleJwt({
...developerJwt,
tokenId: <token_id>
});
get_vehicle_jwt = dimo.token_exchange.exchange(
developer_jwt = dev_jwt
token_id ="<token_id>"
)
vehicle_jwt = get_vehicle_jwt['token']
var vehicleJwt = await dimoClient.TokenExchangeService.GetPrivilegeTokenAsync(
accessToken: devJwt,
tokenId: <tokenId>,
privileges: [
PrivilegeSharing.AllTimeNoLocationData,
PrivilegeSharing.Commands,
PrivilegeSharing.CurrentLocation,
PrivilegeSharing.AllTimeLocation
]
);
5
Fetching Vehicle Data
- JS/TS
- Python
- C#
const something = await dimo.telemetry.query({
...vehicleJwt,
query: `
query {
some_valid_GraphQL_query
}`
});
telemetry_data = dimo.telemetry.query(
vehicle_jwt=vehicle_jwt,
query= """
query {
some_valid_GraphQL_query
}
"""
)
var query = @"
{
some_valid_GraphQL_query
}
";
var variables = new
{
VariableName = "VariableValue"
};
var result = await dimoClient.TelemetryService.ExecuteQueryAsync<TResponse>(query, variables, vehicleJwt.Token);
Console.WriteLine(result);