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.
<PackageVersion Include="DigikeyApiClient.Core" Version="1.1.1" />
                    
Directory.Packages.props
<PackageReference Include="DigikeyApiClient.Core" />
                    
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 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.
#:package DigikeyApiClient.Core@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=DigikeyApiClient.Core&version=1.1.1
                    
Install as a Cake Addin
#tool nuget:?package=DigikeyApiClient.Core&version=1.1.1
                    
Install as a Cake Tool

<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.  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. 
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 293 4/17/2023
1.1.0 206 3/30/2023

ProductInformation endpoints added.