Skip to main content

Python client for Digikey API

Project description

Python Client for Digikey PartSearch API v2

Search for parts in the Digi-Key catalog by keyword using KeywordSearch. Then make a PartDetails call to retrieve all real time information about the part including pricing. PartDetails works best with Digi-Key part numbers as some manufacturers overlap other manufacturer part numbers.

Pypi Donate

What does it do

digkey-api is an Digkey Part Search API client for Python 3.6+. API response data is returned as Python objects that attempt to make it easy to get the data you want. Not all endpoints have been implemented.

Quickstart

Register

Register an app on the Digikey API portal: Digi-Key API. You will need the client ID and the client secret to use the API. You will also need a Digi-Key account to authenticate, using the Oauth2 process.

Install

pip install digikey-api

export DIGIKEY_CLIENT_ID="client_id"
export DIGIKEY_CLIENT_SECRET="client_secret"
export DIGIKEY_STORAGE_PATH="cache_dir"

Use

Python will automatically spawn a browser to allow you to authenticate using the Oauth2 process. After obtaining a token the library will cache the access token and use the refresh token to automatically refresh your credentials.

import os
import digikey

os.environ['DIGIKEY_CLIENT_ID'] = 'client_id'
os.environ['DIGIKEY_CLIENT_SECRET'] = 'client_secret'
os.environ['DIGIKEY_STORAGE_PATH'] = 'cache_dir'

dkpn = '296-6501-1-ND'
part = digikey.part(dkpn)
print(part)
# <Part mpn=NE555DR>

print(part.manufacturer)
# 'Texas Instruments'

Test

python -m pytest --cov=digikey --doctest-modules --ignore=setup.py
python -m mypy digikey --ignore-missing-imports

Top-level API

  • digikey.search()
  • digikey.part()

Data models

  • digikey.models.KeywordSearchResult
  • digikey.models.Part

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

digikey-api-0.2.2.tar.gz (13.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

digikey_api-0.2.2-py3-none-any.whl (26.8 kB view details)

Uploaded Python 3

File details

Details for the file digikey-api-0.2.2.tar.gz.

File metadata

  • Download URL: digikey-api-0.2.2.tar.gz
  • Upload date:
  • Size: 13.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

File hashes

Hashes for digikey-api-0.2.2.tar.gz
Algorithm Hash digest
SHA256 41728137cfcb18e447c8a78692bf489e0181acaebcab9764ceb4aeca6fe295fb
MD5 234872df5910cb182a4a9ca80b0ce5cd
BLAKE2b-256 e81cd4e89f5a7b08fdbdd30fadebdd34d52a5663665c80cc2ca08c12dda6ad5a

See more details on using hashes here.

File details

Details for the file digikey_api-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: digikey_api-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 26.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

File hashes

Hashes for digikey_api-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 dfbb12fbfa5ced00bde38bebec55c19d7a3d540981cbb5fc8e1bdab87f45d5a1
MD5 11676f0beb474caf8ff7cc6404c8a558
BLAKE2b-256 6586cc3266366725c9aa896f77924e5f103c224e2436d88c9b4c53a6c163f4e5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page