{"id":25245927,"url":"https://github.com/dimo-network/dimo-dotnet-sdk","last_synced_at":"2025-10-26T21:30:28.361Z","repository":{"id":256636021,"uuid":"833720642","full_name":"DIMO-Network/dimo-dotnet-sdk","owner":"DIMO-Network","description":"DIMO Developer SDK for .NET","archived":false,"fork":false,"pushed_at":"2025-01-07T21:22:32.000Z","size":394,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-07T22:55:32.546Z","etag":null,"topics":["api-wrapper","blockchain","connected-vehicles","csharp","dimo","dotnet","sdk","web3"],"latest_commit_sha":null,"homepage":"https://dimo.org/developers","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DIMO-Network.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-25T15:54:23.000Z","updated_at":"2025-01-07T18:23:54.000Z","dependencies_parsed_at":"2024-09-12T06:09:36.358Z","dependency_job_id":"7c26c184-5cd4-4d52-83a4-2b6dc771b771","html_url":"https://github.com/DIMO-Network/dimo-dotnet-sdk","commit_stats":null,"previous_names":["dimo-network/dimo-dotnet-sdk"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DIMO-Network%2Fdimo-dotnet-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DIMO-Network%2Fdimo-dotnet-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DIMO-Network%2Fdimo-dotnet-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DIMO-Network%2Fdimo-dotnet-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DIMO-Network","download_url":"https://codeload.github.com/DIMO-Network/dimo-dotnet-sdk/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238399621,"owners_count":19465491,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-wrapper","blockchain","connected-vehicles","csharp","dimo","dotnet","sdk","web3"],"created_at":"2025-02-12T02:03:36.828Z","updated_at":"2025-10-26T21:30:28.356Z","avatar_url":"https://github.com/DIMO-Network.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DIMO Client for .NET\n\nThis 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.\n\n## Installation\n\nYou 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:\n\nFor Windows Users:\n```\nInstall-Package Dimo.Client\n```\n\nFor Linux/Mac Users:\n```\ndotnet add package Dimo.Client\n```\n\n## API Documentation\n\nPlease visit the DIMO [Developer Documentation](https://docs.Dimo.zone/developer-platform) to learn more about building on DIMO and detailed information on the API.\n\n### Developer Registration\nAs part of the authentication process, you will need to obtain a Developer License via the [DIMO Developer Console](https://console.dimo.xyz/). To get started with registration, follow the steps below:\n1. Sign up on the [DIMO Developer Console](https://console.dimo.xyz/).\n2. Connect a web3 wallet (if you didn't sign up with one)\n3. 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`)\n4. Generate an API key and add in your preferred redirect URI\n\n## Usage\n\nDIMO 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.\n\n### Without Dependency Injection\n\nYou 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.\n```csharp\nusing Dimo.Client;\n\nvar dimoClient = new DimoClientBuilder()\n    .WithEnvironment(DimoEnvironment.Production)\n    .AddRestServices()\n    .AddGraphQLServices()\n    .Build(); \n```\nOr you can add all services at once.\n```csharp\nvar dimoClient = new DimoClientBuilder().AddAllServices().Build();\n```\n\n### With Dependency Injection\n\nYou 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.\n```csharp\nusing Dimo.Client;\n\nservices.AddDimoClient(options =\u003e\n{\n    options.Environment = DimoEnvironment.Production;\n});\n```\n___\n**_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.\n___\n### Configuration\n\nYou can configure the DIMO Client using the `DimoClientOptions` class. Below is an example of how to configure the DIMO Client.\n```csharp\nusing Dimo.Client;\n\nservices.AddDimoClient(options =\u003e\n{\n    options.Environment = DimoEnvironment.Production;\n});\n```\n___\n**_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.\n___\n\n### Services\n\n#### REST Services\n\nThe rest services provide the following functionality:\n\n- Authentication\n- Device Data\n- Device Definitions\n- Vehicle Events\n- Token Exchange\n- Trips\n- Valuations\n- Vehicle Signal Decoding\n\n#### GraphQL Services\n\nThe GraphQL services provide the following functionality:\n- Identity API\n- Telemetry API\n\n### Examples\n\nBelow are examples of how to use the DIMO Client for .NET.\n\n### Authentication\n\nIn order to authenticate and access private API data, you will need to [authenticate with the DIMO Auth Server](https://docs.dimo.zone/developer-platform/getting-started/authentication). The SDK provides you with all the steps needed in the [Wallet-based Authentication Flow](https://docs.dimo.zone/developer-platform/getting-started/authentication/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.\n\n#### Prerequisites for Authentication\n1. A valid Developer License\n2. A valid API key\n\n\u003e 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.\n___\n**_NOTE:_** The wallet related to the API key is different from the spender or holder wallet for your [DIMO Developer License](https://github.com/DIMO-Network/developer-license-donotus). 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.\n___\nThere three ways to authenticate with the DIMO Auth Server based on the steps listed in [Wallet-based Authentication Flow](https://docs.Dimo.zone/developer-platform/getting-started/authentication/wallet-based-authentication-flow):\n\n1. Using `GenerateChallengeAsync`, `SignChallengeAsync`, and `SubmitChallengeAsync` methods.\n\n```csharp\nusing Dimo.Client;\n\nvar dimoClient = new DimoClientBuilder()\n    .AddAllServices()\n    .WithEnvironment(DimoEnvironment.Production)\n    .Build();\n    \n var challenge = await dimoClient.AuthenticationService.GenerateChallengeAsync(\n    clientId: \"\u003cyour client id\u003e\",\n    domain: \"\u003cyour domain\u003e\"\n    );\n\nvar signedChallenge = await dimoClient.AuthenticationService.SignChallengeAsync(\n    message: challenge.Challenge,\n    privateKey: \"\u003cyour private key\u003e\"\n    );\n\nvar auth = await dimoClient.AuthenticationService.SubmitChallengeAsync(\n    clientId: \"\u003cyour client id\u003e\",\n    domain: \"\u003cyour domain\u003e\",\n    state: challenge.State,\n    signature: signedChallenge\n    );\n```\n\n2. Using the `GetTokenAsync` method in the `AuthenticationService` class.\n\n```csharp\nusing Dimo.Client;\n\nvar dimoClient = new DimoClientBuilder()\n    .AddAllServices()\n    .WithEnvironment(DimoEnvironment.Production)\n    .Build();\n    \n var auth = await dimoClient.AuthenticationService.GetTokenAsync(\n    clientId: \"\u003cyour client id\u003e\",\n    domain: \"\u003cyour domain\u003e\",\n    privateKey: \"\u003cyour private key\u003e\"\n    );\n    \nConsole.WriteLine(auth.AccessToken);\n```\n\n3. Using the `GetTokenAsync` method in the `AuthenticationService` class with a `ClientCredentials` object.\n\n```csharp\nusing Dimo.Client;\n\nvar dimoClient = new DimoClientBuilder()\n    .AddAllServices()\n    .WithEnvironment(DimoEnvironment.Production)\n    .WithCredentials(new ClientCredentials\n    {\n        ClientId = \"\u003cyour client id\u003e\",\n        Domain = \"\u003cyour domain\u003e\",\n        PrivateKey = \"\u003cyour private key\u003e\"\n    })\n    .Build();\n\nvar auth = await dimoClient.AuthenticationService.GetTokenAsync();\n\nConsole.WriteLine(auth.AccessToken);\n```\n___\n**_NOTE:_** \n- The `GetTokenAsync` method in the `AuthenticationService` will expect you to set `ClientCredentials` objects on build configuration.\n- When using dependency injection, you can set the `ClientCredentials` object in the `AddDimoClient` method or use Options Pattern to add it configuring an `IOptions\u003cClientCrendentials\u003e`.\n- If you call this method and neither is set it will throw an exception\n___\n\n#### Device Data API\n\n```csharp\nusing Dimo.Client;\n\nvar dimoClient = new DimoClientBuilder()\n    .AddAllServices()\n    .WithEnvironment(DimoEnvironment.Production)\n    .Build();\n\nvar tokenId = 123456; // The token id of the device you want to get the data for\n\nvar auth = await dimoClient.AuthenticationService.GetTokenAsync(\n    clientId: \"\u003cyour client id\u003e\",\n    domain: \"\u003cyour domain\u003e\",\n    privateKey: \"\u003cyour private key\u003e\"    \n    );\n\nvar privilegeToken = await dimoClient.TokenExchangeService.GetPrivilegeTokenAsync(\n    accessToken: auth.AccessToken,\n    tokenId: tokenId,\n    privileges: [ \n        PrivilegeSharing.AllTimeNoLocationData,\n        PrivilegeSharing.Commands, \n        PrivilegeSharing.CurrentLocation, \n        PrivilegeSharing.AllTimeLocation \n    ]); // The privileges you want to get for the device\n\nvar vehicleStatus = await dimoClient.DeviceDataService.GetVehicleStatusAsync(tokenId, privilegeToken.Token);\n\nConsole.WriteLine(vehicleStatus);\n```\n___\n**_NOTE:_**  for the `privileges` parameter you can check the [DIMO API documentation](https://docs.Dimo.zone/developer-platform/rest-api-references/dimo-protocol/token-exchange-api/token-exchange-api-endpoints#references-for-privilege-sharing) for the available privileges.\n___\n#### Querying the GraphQL API\n\nThe 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.\n\n```csharp\nusing Dimo.Client;\n\nvar dimoClient = new DimoClientBuilder()\n    .AddAllServices()\n    .WithEnvironment(DimoEnvironment.Production)\n    .Build();\n\n// Code to authenticate with the DIMO Auth Server and get the privilege token\n// ...\n\nvar query = @\"\n{\n  some_valid_GraphQL_query\n}\n\";\n\nvar variables = new\n{\n    VariableName = \"VariableValue\"\n};\n\nvar result = await dimoClient.TelemetryService.ExecuteQueryAsync\u003cTResponse\u003e(query, variables, privilegeToken.Token);\n\nConsole.WriteLine(result);\n```\n___\n**_NOTE:_**  The `ExecuteQueryAsync` method accepts a generic type `TResponse` which is the type of the response you expect from the GraphQL query.\n___\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdimo-network%2Fdimo-dotnet-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdimo-network%2Fdimo-dotnet-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdimo-network%2Fdimo-dotnet-sdk/lists"}