{"id":24024772,"url":"https://github.com/cognitedata/cognite-sdk-dotnet","last_synced_at":"2026-01-16T06:18:22.868Z","repository":{"id":37821352,"uuid":"176680731","full_name":"cognitedata/cognite-sdk-dotnet","owner":"cognitedata","description":".NET SDK for Cognite Data Fusion (CDF)","archived":false,"fork":false,"pushed_at":"2025-04-09T14:08:22.000Z","size":21221,"stargazers_count":18,"open_issues_count":7,"forks_count":5,"subscribers_count":78,"default_branch":"master","last_synced_at":"2025-04-09T15:24:18.737Z","etag":null,"topics":["cdf","csharp","dotnet","dotnet-core","dotnet-framework","dotnet-standard","fsharp","sdk","sdk-dotnet"],"latest_commit_sha":null,"homepage":"","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/cognitedata.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-03-20T07:42:49.000Z","updated_at":"2025-04-04T13:48:56.000Z","dependencies_parsed_at":"2023-12-03T15:21:27.562Z","dependency_job_id":"848c50ca-a5e5-4831-aebd-e02586f894ce","html_url":"https://github.com/cognitedata/cognite-sdk-dotnet","commit_stats":null,"previous_names":[],"tags_count":189,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cognitedata%2Fcognite-sdk-dotnet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cognitedata%2Fcognite-sdk-dotnet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cognitedata%2Fcognite-sdk-dotnet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cognitedata%2Fcognite-sdk-dotnet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cognitedata","download_url":"https://codeload.github.com/cognitedata/cognite-sdk-dotnet/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249194680,"owners_count":21228034,"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":["cdf","csharp","dotnet","dotnet-core","dotnet-framework","dotnet-standard","fsharp","sdk","sdk-dotnet"],"created_at":"2025-01-08T15:34:49.924Z","updated_at":"2026-01-16T06:18:22.816Z","avatar_url":"https://github.com/cognitedata.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ca href=\"https://cognite.com/\"\u003e\n    \u003cimg src=\"./cognite_logo.png\" alt=\"Cognite logo\" title=\"Cognite\" align=\"right\" height=\"80\" /\u003e\n\u003c/a\u003e\n\n# CogniteSdk for .NET\n\n![Build and Test](https://github.com/cognitedata/cognite-sdk-dotnet/workflows/Build%20and%20Test/badge.svg)\n[![codecov](https://codecov.io/gh/cognitedata/cognite-sdk-dotnet/branch/master/graph/badge.svg?token=da8aPB6l9U)](https://codecov.io/gh/cognitedata/cognite-sdk-dotnet)\n[![Nuget](https://img.shields.io/nuget/vpre/CogniteSdk)](https://www.nuget.org/packages/CogniteSdk/)\n\nCogniteSdk for .NET is a cross platform asynchronous SDK for accessing the [Cognite Data Fusion](https://docs.cognite.com/) [API (v1)](https://docs.cognite.com/api/v1/) using [.NET Standard 2.0](https://docs.microsoft.com/en-us/dotnet/standard/net-standard) that works for all .NET implementations i.e both [.NET Core](https://en.wikipedia.org/wiki/.NET_Core) and [.NET Framework](https://en.wikipedia.org/wiki/.NET_Framework).\n\n**Unofficial**: please note that this is an unofficial and community driven SDK. Feel free to open issues, or provide PRs if you want to improve the library.\n\nThe SDK may be used from both C# and F#.\n\n- **C# SDK**: The C# SDK is a fluent API using objects and method chaining. Errors will be raised as exceptions. The API is asynchronous and all API methods returns `Task` and is awaitable using `async/await`.\n\n- **F# SDK**: The F# API is written using plain asynchronous functions returning `Task` built on top of the [Oryx](https://github.com/cognitedata/oryx) HTTP handler library.\n\n## Supported Resources\n- Assets\n- TimeSeries \u0026 DataPoints\n- Events\n- Files\n- Raw\n- Sequences\n- Relationships\n- Annotations\n- 3D Models\n- 3D Files\n- 3D Asset Mapping\n- Data sets\n- Extractor Pipelines\n- Transformations\n- Labels\n- Token\n- Groups\n- Units\n- Data Models\n\n### Beta Resources\n- Subscriptions\n- Templates\n\n### Alpha Resources\n- Simulators\n\n## Documentation\n* [Cognite API Documentation](https://api-docs.cognite.com/)\n* [Cognite Developer Guide](https://developer.cognite.com/dev/)\n\n## Installation\n\nCogniteSdk is available as a [NuGet package](https://www.nuget.org/packages/CogniteSdk/). To install:\n\nUsing Package Manager:\n```sh\nInstall-Package CogniteSdk\n```\n\nUsing .NET CLI:\n```sh\ndotnet add package CogniteSdk\n```\n\nOr [directly in Visual Studio](https://docs.microsoft.com/en-us/nuget/quickstart/install-and-use-a-package-in-visual-studio).\n\n## Quickstart\n\nRequests to Cognite Data Fusion are authenticated as submitted by a client using OAuth2 tokens. There are several authentication flows available, check the [Cognite Documentation](https://docs.cognite.com/cdf/access/concepts/authentication_flows_oidc/#:~:text=In%20the%20client%20credentials%20grant,get%20a%20time%2Dlimited%20token.) for more details.\n\nThe SDK does not include any logic to fetch tokens from an Identity Provider. Instead, the SDK expects a valid token to be provided by the user. The SDK will then use this token to authenticate requests to CDF.\n\nAll SDK methods are called with a `Client` object. A valid client requires:\n- `Project Name` - the name of your CDF project e.g `publicdata`.\n- `App ID` - an identifier for your application. It is a free text string. Example: `asset-hierarchy-extractor`\n- `Base URL` - the base URL for the CDF API. Example: `https://api.cognitedata.com`\n- `Bearer Token` - valid OAuth2 token for the CDF project.\n- `HTTP Client` - The [HttpClient](https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpclient?view=netcore-3.1) that will be used for the remote connection. Having this separate from the SDK have many benefits like using e.g [Polly](https://github.com/App-vNext/Polly) for policy handling.\n\nHere's a simple example of how to instantiate a client. For this example we're using [Microsoft Authentication Library](https://www.nuget.org/packages/Microsoft.Identity.Client/) to fetch a token from Azure AD using client credentials flow, but any other method for fetching a token will work as well.\n```c#\nusing CogniteSdk;\nusing Microsoft.Identity.Client;\n\nvar tenantId = Environment.GetEnvironmentVariable(\"TENANT_ID\");\nvar clientId = Environment.GetEnvironmentVariable(\"CLIENT_ID\");\nvar clientSecret = Environment.GetEnvironmentVariable(\"CLIENT_SECRET\");\nvar cluster = Environment.GetEnvironmentVariable(\"CDF_CLUSTER\");\nvar project = Environment.GetEnvironmentVariable(\"CDF_PROJECT\");\n\nvar scopes = new List\u003cstring\u003e{ $\"https://{cluster}.cognitedata.com/.default\" };\n\nvar app = ConfidentialClientApplicationBuilder\n    .Create(clientId)\n    .WithAuthority(AzureCloudInstance.AzurePublic, tenantId)\n    .WithClientSecret(clientSecret)\n    .Build();\n\nvar result = await app.AcquireTokenForClient(scopes).ExecuteAsync();\nvar accessToken = result.AccessToken;\n\nvar httpClient = new HttpClient();\nvar client = Client.Builder.Create(httpClient)\n    .SetAppId(\"dotnet-sdk-client\")\n    .AddHeader(\"Authorization\", $\"Bearer {accessToken}\")\n    .SetProject(project)\n    .SetBaseUrl(new Uri($\"https://{cluster}.cognitedata.com\"))\n    .Build();\n\n// your logic using the client\nvar query = new Assets.AssetQuery\n{\n    Filter = new Assets.AssetFilter { Name = assetName }\n};\nvar result = await client.Assets.ListAsync(query);\n```\n\n\u003e **_NOTE:_** The example above does not handle token refresh. If you need to refresh tokens, you need to implement this yourself or use a library like [Cognite Extractor Utils](https://github.com/cognitedata/dotnet-extractor-utils) that handles this for you.\n\n## Examples\n\nThere are examples for both C# and F# in the Examples folder.\n\n## Developing\n\n### Dotnet Tools\n\nA dotnet tools manifest is used to version tools used by this repo.  Install these tools with:\n\n```sh\ndotnet tool restore\n```\n\nThis will install Paket locally which is used for dependency management.\n\n### Dependencies\n\nDependencies for all projects are handled using [Paket](https://fsprojects.github.io/Paket/). To install dependencies:\n\n```sh\ndotnet paket install\n```\n\nThis will install the main dependencies and sub-dependencies. The main dependencies are:\n\n- [Oryx](https://www.nuget.org/packages/Oryx/) - HTTP Handlers.\n- [Oryx.Cognite](https://www.nuget.org/packages/Oryx.Cognite/) - Oryx HTTP Handlers for Cognite API.\n- [Oryx.SystemTextJson](https://www.nuget.org/packages/Oryx.SystemTextJson/) - JSON handlers for Oryx\n- [Oryx.Protobuf](https://www.nuget.org/packages/Oryx.Protobuf/) - Protobuf handlers for Oryx\n- [CogniteSdk.Protobuf](https://www.nuget.org/packages/CogniteSdk.Protobuf/) - Protobuf definitions for Cognite API.\n- [System.Text.Json](https://www.nuget.org/packages/System.Text.Json/) - for Json support.\n- [Google.Protobuf](https://www.nuget.org/packages/Google.Protobuf) - for Protobuf support.\n\n### Running tests locally\nTo run the tests locally, you can use the following script:\n```sh\nsh ./test.sh\n```\nFor this script, the following AAD environment variables need to be defined:\n- `TEST_TENANT_ID_WRITE`\n- `TEST_CLIENT_ID_WRITE`\n- `TEST_CLIENT_SECRET_WRITE`\n\nYou also need read credentials for the `publicdata` project:\n- `TEST_TENANT_ID_READ`\n- `TEST_CLIENT_ID_READ`\n- `TEST_CLIENT_SECRET_READ`\n\n# Code of Conduct\n\nThis project follows https://www.contributor-covenant.org, see our [Code of Conduct](https://github.com/cognitedata/cognite-sdk-dotnet/blob/master/CODE_OF_CONDUCT.md).\n\n## License\n\nApache v2, see [LICENSE](https://github.com/cognitedata/cognite-sdk-dotnet/blob/master/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcognitedata%2Fcognite-sdk-dotnet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcognitedata%2Fcognite-sdk-dotnet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcognitedata%2Fcognite-sdk-dotnet/lists"}