Dimo.Client 1.1.1

dotnet add package Dimo.Client --version 1.1.1
                    
NuGet\Install-Package Dimo.Client -Version 1.1.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Dimo.Client" Version="1.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Dimo.Client" Version="1.1.1" />
                    
Directory.Packages.props
<PackageReference Include="Dimo.Client" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Dimo.Client --version 1.1.1
                    
#r "nuget: Dimo.Client, 1.1.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Dimo.Client@1.1.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Dimo.Client&version=1.1.1
                    
Install as a Cake Addin
#tool nuget:?package=Dimo.Client&version=1.1.1
                    
Install as a Cake Tool

DIMO Client for .NET

This is a .NET client for the DIMO API. It is a simple wrapper around the DIMO API, which allows you to interact with the DIMO API using .NET.

Installation

You can install the DIMO Client for .NET using NuGet. To install the DIMO Client for .NET, run the following command in the Package Manager Console:

For Windows Users:

Install-Package Dimo.Client

For Linux/Mac Users:

dotnet add package Dimo.Client

API Documentation

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

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. Connect a web3 wallet (if you didn't sign up with 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

Usage

DIMO Client for .NET is can be used with dependency injection or without it. Below are examples of how to use the DIMO Client for .NET with and without dependency injection.

Without Dependency Injection

You can add each service individually to the DIMO Client. Below is an example of how to add the core services, GraphQL services, and Streamr services to the DIMO Client.

using Dimo.Client;

var dimoClient = new DimoClientBuilder()
    .WithEnvironment(DimoEnvironment.Production)
    .AddRestServices()
    .AddGraphQLServices()
    .Build(); 

Or you can add all services at once.

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

With Dependency Injection

You can also use the DIMO Client for .NET with dependency injection. Below is an example of how to add the DIMO Client to the service collection.

using Dimo.Client;

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

NOTE: Using dependency injection grants you access to all individual interfaces that make up the DIMO Client. You can inject them into your services as needed.


Configuration

You can configure the DIMO Client using the DimoClientOptions class. Below is an example of how to configure the DIMO Client.

using Dimo.Client;

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

NOTE: by default, the DIMO Client for .NET uses the Production environment. You can change the environment by setting the Environment property of the DimoClientOptions class.


Services

REST Services

The rest services provide the following functionality:

  • Authentication
  • Device Data
  • Device Definitions
  • Events
  • Token Exchange
  • Trips
  • Users
  • Valuations
  • Vehicle Signal Decoding
GraphQL Services

The GraphQL services provide the following functionality:

  • Identity API
  • Telemetry API
Streamr Services

Coming soon...

Examples

Below are examples of how to use the DIMO Client for .NET.

Authentication

In order to authenticate and access private API data, you will need to authenticate with the DIMO Auth Server. The SDK provides you with all the steps needed in the Wallet-based Authentication Flow in case you need it to build a wallet integration around it. We also offer expedited functions to streamline the multiple calls needed.

Prerequisites for Authentication
  1. A valid Developer License
  2. A valid API key

At its core, the API key is the private key to a Web3 wallet. Unlike traditional wallets, which store physical currency, Web3 wallets store digital assets such as Bitcoin, Ethereum, and NFTs. In DIMO's Developer Console, we provision a randomly-generated Web3 wallet for you as the enabled signer of your Developer License, decoupling the operations from wallets that may have assets in them for extra safety.


NOTE: The wallet related to the API key is different from the spender or holder wallet for your DIMO Developer License. This gives users peace of mind that their assets are safely in their spender wallet, and the Developer License NFT is in their holder wallet.


There three ways to authenticate with the DIMO Auth Server based on the steps listed in Wallet-based Authentication Flow:

  1. Using GenerateChallengeAsync, SignChallengeAsync, and SubmitChallengeAsync methods.
using Dimo.Client;

var dimoClient = new DimoClientBuilder()
    .AddAllServices()
    .WithEnvironment(DimoEnvironment.Production)
    .Build();
    
 var challenge = await dimoClient.AuthenticationService.GenerateChallengeAsync(
    clientId: "<your client id>",
    domain: "<your domain>",
    address: "<your address>",
    );

var signedChallenge = await dimoClient.AuthenticationService.SignChallengeAsync(
    message: challenge.Challenge,
    privateKey: "<your private key>"
    );

var auth = await dimoClient.AuthenticationService.SubmitChallengeAsync(
    clientId: "<your client id>",
    domain: "<your domain>",
    state: challenge.State,
    signature: signedChallenge
    );
  1. Using the GetTokenAsync method in the AuthenticationService class.
using Dimo.Client;

var dimoClient = new DimoClientBuilder()
    .AddAllServices()
    .WithEnvironment(DimoEnvironment.Production)
    .Build();
    
 var auth = await dimoClient.AuthenticationService.GetTokenAsync(
    clientId: "<your client id>",
    domain: "<your domain>",
    privateKey: "<your private key>",
    address: "<your address>"
    );
    
Console.WriteLine(auth.AccessToken);
  1. Using the GetTokenAsync method in the AuthenticationService class with a ClientCredentials object.
using Dimo.Client;

var dimoClient = new DimoClientBuilder()
    .AddAllServices()
    .WithEnvironment(DimoEnvironment.Production)
    .WithCredentials(new ClientCredentials
    {
        Address = "<your address>",
        ClientId = "<your client id>",
        Domain = "<your domain>",
        PrivateKey = "<your private key>"
    })
    .Build();

var auth = await dimoClient.AuthenticationService.GetTokenAsync();

Console.WriteLine(auth.AccessToken);

NOTE:

  • The GetTokenAsync method in the AuthenticationService will expect you to set ClientCredentials objects on build configuration.
  • When using dependency injection, you can set the ClientCredentials object in the AddDimoClient method or use Options Pattern to add it configuring an IOptions<ClientCrendentials>.
  • If you call this method and neither is set it will throw an exception

Device Data API
using Dimo.Client;

var dimoClient = new DimoClientBuilder()
    .AddAllServices()
    .WithEnvironment(DimoEnvironment.Production)
    .Build();

var tokenId = 123456; // The token id of the device you want to get the data for

var auth = await dimoClient.AuthenticationService.GetTokenAsync(
    clientId: "<your client id>",
    domain: "<your domain>",
    privateKey: "<your private key>",
    address: "<your address>"
    );

var privilegeToken = await dimoClient.TokenExchangeService.GetPrivilegeTokenAsync(
    accessToken: auth.AccessToken,
    tokenId: tokenId,
    privileges: [ 
        PrivilegeSharing.AllTimeNoLocationData,
        PrivilegeSharing.Commands, 
        PrivilegeSharing.CurrentLocation, 
        PrivilegeSharing.AllTimeLocation 
    ]); // The privileges you want to get for the device

var vehicleStatus = await dimoClient.DeviceDataService.GetVehicleStatusAsync(tokenId, privilegeToken.Token);

Console.WriteLine(vehicleStatus);

NOTE: for the privileges parameter you can check the DIMO API documentation for the available privileges.


Querying the 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.

using Dimo.Client;

var dimoClient = new DimoClientBuilder()
    .AddAllServices()
    .WithEnvironment(DimoEnvironment.Production)
    .Build();

// Code to authenticate with the DIMO Auth Server and get the privilege token
// ...

var query = @"
{
  some_valid_GraphQL_query
}
";

var variables = new
{
    VariableName = "VariableValue"
};

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

Console.WriteLine(result);

NOTE: The ExecuteQueryAsync method accepts a generic type TResponse which is the type of the response you expect from the GraphQL query.


Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.1 171 2/19/2025
1.1.0 118 1/7/2025
1.0.5 169 10/21/2024
1.0.4 156 10/21/2024
1.0.3 164 10/21/2024
1.0.2 146 10/16/2024
1.0.1 169 10/4/2024
1.0.0 172 9/11/2024
1.0.0-rc.1 94 9/11/2024