DigikeyApiClient.Core
1.1.1
dotnet add package DigikeyApiClient.Core --version 1.1.1
NuGet\Install-Package DigikeyApiClient.Core -Version 1.1.1
<PackageReference Include="DigikeyApiClient.Core" Version="1.1.1" />
paket add DigikeyApiClient.Core --version 1.1.1
#r "nuget: DigikeyApiClient.Core, 1.1.1"
// Install DigikeyApiClient.Core as a Cake Addin #addin nuget:?package=DigikeyApiClient.Core&version=1.1.1 // Install DigikeyApiClient.Core as a Cake Tool #tool nuget:?package=DigikeyApiClient.Core&version=1.1.1
<div align="center"> <h1>C# DigiKey API Client Library</h1>
</div>
Features
- Makes structured calls to the DigiKey API from .NET projects
- Handles the OAuth2 control flow, logs users in, refreshes tokens when needed, etc.
Basic Usage
var settings = ApiClientSettings.CreateFromConfigFile();
var client = new ApiClientService(settings);
var response = await client.ProductInformation.KeywordSearch("P5555-ND");
var jsonFormatted = JToken.Parse(response).ToString(Newtonsoft.Json.Formatting.Indented);
Console.WriteLine($"Reponse is {jsonFormatted}");
Project Contents
ApiClient - Core client Library that manages a users OAuth2 config file, settings, and authorization flow. It also contains methods for endpoints belonging to the Product Information API.
ApiClient.ConsoleApp - Console app to test the refresh of access tokens using a sample KeywordSearch.
OAuth2Service.ConsoleApp - Console app to do the initial authorization and get a new access and refresh token.
Getting Started
- Clone the repository or download and extract the zip file containing the ApiClient solution.
- You will need to register an application on the DigiKey Developer Portal in order to create your unique Client ID, Client Secret as well as to set your redirection URI.
- In the solution folder copy apiclientexample.config as apiclient.config, and update it with the ClientId, ClientSecret, and RedirectUri values from step 2.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="ApiClient.ClientId"" value="YOUR_CLIENT_ID_HERE" />
<add key="ApiClient.ClientSecret" value="YOUR_CLIENT_SECRET_HERE" />
<add key="ApiClient.RedirectUri" value="YOUR_REDIRECT_URI_HERE" />
<add key="ApiClient.AccessToken" value="" />
<add key="ApiClient.RefreshToken" value="" />
<add key="ApiClient.ExpirationDateTime" value="" />
</appSettings>
</configuration>
- Set the DigikeyProduction environment variable to either true or false for each project you plan to use the ApiClient library in. You can do this by right clicking on the project in Visual Studio and selecting Properties. Then select the Debug tab and add the environment variable in the Environment Variables section.
- Run OAuth2Service.ConsoleApp to set the access token, refresh token and expiration date in apiclient.config.
- Run ApiClient.ConsoleApp to get results from keyword search.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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 was computed. 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 was computed. 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. |
-
net6.0
- Common.Logging (>= 3.4.1)
- Common.Logging.Core (>= 3.4.1)
- Newtonsoft.Json (>= 13.0.3)
- System.Configuration.ConfigurationManager (>= 7.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
ProductInformation endpoints added.