SDKs overview

Digi-Key provides Software Development Kits (SDKs) and client libraries to facilitate integration with its APIs, enabling developers to programmatically interact with its catalog of electronic components. These tools abstract the underlying RESTful API calls, simplifying tasks such as searching for parts, retrieving real-time pricing and availability, and managing orders. The SDKs are designed to accelerate development by offering pre-built functions and handling authentication mechanisms like OAuth 2.0, which is crucial for secure API access.

The primary use cases for Digi-Key's SDKs revolve around automating procurement processes, integrating supply chain data into enterprise resource planning (ERP) systems, and enhancing product design workflows by providing direct access to component specifications and stock levels. Developers can utilize these libraries to build custom applications that leverage Digi-Key's extensive inventory without needing to manage raw HTTP requests or JSON parsing directly. Comprehensive Digi-Key API documentation is available, detailing endpoints, request/response formats, and authentication procedures.

Official SDKs by language

Digi-Key offers official SDKs and client libraries that support several popular programming languages. These SDKs are developed and maintained by Digi-Key to ensure compatibility and provide developers with a structured way to interact with the Digi-Key API. Each SDK typically includes client classes, data models corresponding to API responses, and helper functions for common operations.

The following table outlines the officially supported SDKs, their respective package managers, installation commands, and general maturity levels, based on information provided in the Digi-Key API Solutions documentation:

Language Package Manager Package Name Install Command Example Maturity
C# NuGet DigiKey.Api Install-Package DigiKey.Api Stable
Python pip digikey-api-client pip install digikey-api-client Stable
Java Maven / Gradle com.digikey:digikey-api-client (Maven) <dependency><groupId>com.digikey</groupId><artifactId>digikey-api-client</artifactId><version>X.Y.Z</version></dependency> Stable
Node.js npm @digikey/api-client npm install @digikey/api-client Stable
PHP Composer digikey/api-php-client composer require digikey/api-php-client Stable
Ruby RubyGems digikey-api-client gem install digikey-api-client Stable

Installation

To begin using a Digi-Key SDK, you typically need to install the corresponding package using your language's standard package manager. Before installation, ensure you have the correct runtime environment and package manager configured on your development machine.

C# (.NET)

For .NET projects, the Digi-Key API client is distributed via NuGet. You can install it using the NuGet Package Manager Console in Visual Studio or via the .NET CLI:

# Using NuGet Package Manager Console
Install-Package DigiKey.Api

# Using .NET CLI
dotnet add package DigiKey.Api

Python

Python developers can install the SDK using pip, Python's package installer:

pip install digikey-api-client

Java

For Java projects, you can add the Digi-Key API client as a dependency in your pom.xml (for Maven) or build.gradle (for Gradle) file. Replace X.Y.Z with the latest SDK version.

<!-- Maven -->
<dependency>
    <groupId>com.digikey</groupId>
    <artifactId>digikey-api-client</artifactId>
    <version>X.Y.Z</version>
</dependency>
// Gradle
implementation 'com.digikey:digikey-api-client:X.Y.Z'

Node.js

Node.js developers can install the client library using npm, the Node.js package manager:

npm install @digikey/api-client

PHP

For PHP applications, Composer is used to manage dependencies:

composer require digikey/api-php-client

Ruby

Ruby projects can install the gem using RubyGems:

gem install digikey-api-client

Quickstart example

This Python quickstart example demonstrates how to set up the Digi-Key API client, authenticate using OAuth 2.0 client credentials, and perform a basic product search. Before running this code, you will need to obtain your client ID and client secret from the Digi-Key Developer Portal and configure a redirect URI for your application.

import os
from digikey_api_client.api_client import ApiClient
from digikey_api_client.configuration import Configuration
from digikey_api_client.api.search_api import SearchApi
from digikey_api_client.models.keyword_search_request import KeywordSearchRequest

# --- Configuration --- #
# Replace with your actual Client ID and Client Secret
# It's recommended to use environment variables for sensitive credentials
CLIENT_ID = os.environ.get("DIGIKEY_CLIENT_ID", "YOUR_CLIENT_ID")
CLIENT_SECRET = os.environ.get("DIGIKEY_CLIENT_SECRET", "YOUR_CLIENT_SECRET")
REDIRECT_URI = os.environ.get("DIGIKEY_REDIRECT_URI", "YOUR_REDIRECT_URI") # e.g., "https://localhost:8080/oauth/callback"

# Configure API client with your credentials
configuration = Configuration(
    client_id=CLIENT_ID,
    client_secret=CLIENT_SECRET,
    redirect_uri=REDIRECT_URI,
    access_token_url="https://api.digikey.com/api/v1/oauth2/token"
)

# Initialize the API client
api_client = ApiClient(configuration)

# --- Authentication (Client Credentials Flow) --- #
# In a real application, you would handle token caching and refreshing.
# For this quickstart, we'll request a new token.
print("Attempting to get OAuth token...")
# (Note: The digikey-api-client might handle token refresh internally based on configuration)
# For a proper client credentials flow, you might directly call a token endpoint
# if the SDK doesn't abstract it for this grant type.

# As per Digi-Key's documentation, client credentials flow often involves a direct POST to the token URL.
# The SDK's 'Configuration' typically manages the access token lifecycle internally
# if set up correctly with client_id, client_secret, and scope.

# Example of how the SDK might implicitly handle token acquisition for client credentials
# when an API call is made, assuming the config is set up.
# If explicit token acquisition is needed for client credentials, it would look similar to:
# token_response = api_client.get_token_from_client_credentials_flow()
# configuration.access_token = token_response['access_token'] # Or similar assignment

# For simplicity, we assume the SDK's `ApiClient` is configured to handle token acquisition
# upon the first authenticated request (or requires explicit steps documented by Digi-Key).
# A common pattern for client credentials is to ensure the configuration object has a valid token.
# If the SDK doesn't automatically fetch it, you'd perform a request like:
# import requests
# auth_data = {
#     'client_id': CLIENT_ID,
#     'client_secret': CLIENT_SECRET,
#     'grant_type': 'client_credentials'
# }
# token_response = requests.post(configuration.access_token_url, data=auth_data).json()
# configuration.access_token = token_response['access_token']

# --- Perform a Search --- #
search_api = SearchApi(api_client)

keyword = "Arduino Uno"
search_request = KeywordSearchRequest(
    keywords=keyword,
    record_count=10,
    record_start=0
)

try:
    print(f"Searching for '{keyword}'...")
    search_response = search_api.keyword_search(keyword_search_request=search_request)

    if search_response and search_response.products:
        print(f"Found {len(search_response.products)} products for '{keyword}':")
        for product in search_response.products:
            print(f"  - Digi-Key Part Number: {product.digi_key_part_number}")
            print(f"    Description: {product.description}")
            print(f"    Manufacturer: {product.manufacturer.name}")
            if product.minimum_order_quantity and product.unit_price:
                print(f"    MOQ: {product.minimum_order_quantity}, Price: {product.unit_price.unit_price}")
            print("---")
    else:
        print(f"No products found for '{keyword}'.")

except Exception as e:
    print(f"An error occurred: {e}")
    # In a real application, handle specific API errors (e.g., rate limits, authentication failures)

This example demonstrates the typical flow: configuring the client with credentials, initializing an API service, and then calling a method to interact with a specific API endpoint (in this case, a keyword search). The os.environ.get calls illustrate a best practice for securely managing sensitive information like API keys and secrets by retrieving them from environment variables.

Community libraries

While Digi-Key provides official SDKs, the open-source community may develop and maintain additional client libraries or tools that interact with the Digi-Key API. These community-contributed projects can sometimes offer support for niche languages, specific frameworks, or alternative approaches to API integration. However, it is important to note that community libraries are not officially supported or maintained by Digi-Key. Their reliability, security, and adherence to the latest API specifications can vary.

When considering a community library, developers should evaluate several factors:

  • Active Maintenance: Check the project's repository (e.g., GitHub) for recent commits, issue resolution, and community engagement.
  • Documentation: Assess the quality and completeness of the library's documentation.
  • Licensing: Understand the open-source license under which the library is distributed.
  • Security: Review the codebase for potential security vulnerabilities, especially if handling sensitive data or authentication tokens.
  • API Version Compatibility: Ensure the library is compatible with the latest Digi-Key API versions to avoid unexpected breaking changes.

As of 2026, Digi-Key's official SDKs cover the most common programming languages for enterprise and web development. Therefore, the need for extensive community-developed alternatives might be less pronounced compared to APIs with fewer officially supported SDKs.