DigikeyApiClient.Core 1.1.1

dotnet add package DigikeyApiClient.Core --version 1.1.1
NuGet\Install-Package DigikeyApiClient.Core -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="DigikeyApiClient.Core" Version="1.1.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DigikeyApiClient.Core --version 1.1.1
#r "nuget: DigikeyApiClient.Core, 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.
// 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>

image

</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

  1. Clone the repository or download and extract the zip file containing the ApiClient solution.
  2. 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.
  3. 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>
  1. 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.
  2. Run OAuth2Service.ConsoleApp to set the access token, refresh token and expiration date in apiclient.config.
  3. Run ApiClient.ConsoleApp to get results from keyword search.
Product 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. 
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 195 4/17/2023
1.1.0 149 3/30/2023

ProductInformation endpoints added.