Skip to content

ucsbdeepspace/dkbc

 
 

Repository files navigation

Digi-key Api Tools

These are just a few scripts I wrote to look up part information from Digi-key barcodes as well as look up parts by number. I then use this information to create new, simplified, barcodes for my inventory system.

Currently, it supports the barcode search API (1D and 2D barcodes) as well as the part search API. I need to document it all, but it should help get you started if you want to play with the Digi-Key API in python.

Getting Started

dkbc uses the official Digi-Key API. In order to use it, you'll need to register on https://developer.digikey.com. You can use your existing Digi-Key account as well.

Once registered, you'll need to login and create an organization and application.

Digi-Key Login

To create an organization, go to (https://developer.digikey.com/teams) and click on "Create Organization"

Create Organization

Once created, click on "production apps" for the newly created organization

Production Apps

Create production app You can use https://alvarop.com/dkbc/dk_oauth.html as an OAuth Callback URL Select Product Information and Barcode support

Prod App Creation

Click on the new application to get client id and client secret (which will be used for authorization next.)

Production Apps

App Details

Before continuing, you need to setup your python environment (using a virtualenv to sandbox this project and its dependencies)

python3 -m venv venv
source venv/bin/activate
pip install -e .

Now that the environment is configured, you need to get an authorization code from Digi-Key to enable API access. There's a helper script to do it.

Run python -m dkbc.authorize. It will ask you for your client id and client secret. These can be found in your application details from earlier.

Activation Script

After entering the client id and secret, your web browser should automatically open to the Digi-Key website. If you're not logged in, log in again. It will ask for approval for your organization. Click on Allow.

Request for Approval

You will now be redirected to the OAuth callback URL, which will show the authorization code.

OAuth Callback with Authorization Code

That's it! You should be ready to run the examples (or write your own scripts!)

Scanning barcodes

  • Run python examples/scan.py

Manually entering part numbers for search

  • Run python examples/search.py

About

Digikey Barcode API Helper

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 91.0%
  • HTML 9.0%