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.1.tar.gz (11.4 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.1-py3-none-any.whl (26.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: digikey-api-0.2.1.tar.gz
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.8

File hashes

Hashes for digikey-api-0.2.1.tar.gz
Algorithm Hash digest
SHA256 b3d22763a5f65d3ce4d7b24f5c2b16739297365606711140c7da9864b43b5ae6
MD5 f6e8f2c45149d324f5a5ed387805414c
BLAKE2b-256 60cf8df5f7ff9be28c6784fddea09de8f82813993af59f93d5b5b56087ffda1b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: digikey_api-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 26.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.6.8

File hashes

Hashes for digikey_api-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 207338488ab0ea47e32c4ce978472ef4963c9f5a6e23047a0846f819e29accbe
MD5 5bc3034931808105ad9265dae042a379
BLAKE2b-256 74d948296d32db51c96e4584d71550e0a12cf7197a06fa1e3c3888c7afdfeb12

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