Digikey API Integration

Hello, I would like to retrieve product specifications into ERPNext using the ‘Digikey’ API. Can you please assist me with how to achieve this? I would appreciate your help.

[… just googling curiously …]

You mean this one I suppose:
https://www.digikey.de/en/resources/api-solutions-faqs
offering this link:
https://developer.digikey.com/

Thank you for your response. I don’t know how to integrate this into ‘ErpNext’. Can you help me with that? :slight_smile:

Hello @eatlc

1 Read about the Python convenience module at digikey-api · PyPI
2 Download and install this module with

pip3 install digikey-api

3 Register a sandbox API app at https://developer.digikey.com/
Make sure you define the OAuth Callback to be set to https://localhost:8139/digikey_callback as per the Python digikey-api requirements.
4 Create a Python program with this content, and save it as DigikeyApi.py

import os
import digikey
from digikey.v3.productinformation import KeywordSearchRequest
os.environ['DIGIKEY_CLIENT_ID'] = 'long code'
os.environ['DIGIKEY_CLIENT_SECRET'] = 'short code'
os.environ['DIGIKEY_CLIENT_SANDBOX'] = 'True' #'True' or 'False'
os.environ['DIGIKEY_STORAGE_PATH'] = '/home/your_user_name/'
# Query product number
dkpn = '296-6501-1-ND'
part = digikey.product_details(dkpn)
print(part)
# Search for parts 
search_request = KeywordSearchRequest(keywords='CRCW080510K0FKEA', record_count=10)
result = digikey.keyword_search(body=search_request)
print(result)

5 Invoke the DigikeyApi.py script with

python3 /path/to/DigikeyApi.py

6 On your default browser, which the Python script will invoke, authenticate with the username and password you used to register the sandbox api app.

7 Copy the Auth Code and save it somewhere.

8 On the CLI from where you invoked the Python script, you’ll find the results of the 2 print() statements in your script.

9 Once all of this works, you’d have to embed the Python script into a Frappe back-end script and consume the results rather than print it to the CLI.

1 Like