Getparts is a Python3 tool takes a supplier barcode value as an input and returns component information. Currently works for most Digi-Key, Mouser, and some LCSC bags.
2D | 1D | |
---|---|---|
Digi-Key | ✔ | ✔ |
Mouser | ✔ | ➖ |
LCSC | ✔ | ❌ |
Nearly every electrical component ordered online will be packaged and marked with a barcode containing relevant part information. Supplier-specific API are starting to emerge, but I needed a single tool that would retrieve part info from a variety of suppliers with and without search API.
An example script is included that lets you use a webcam (laptop or usb webcam) to scan barcodes on component bags (Digikey, Mouser, and LCSC). This barcode value is fed into getparts which then tries a variety of techinques to retrieve the part information. Uses Python3. Works for 2D DataMatrix, QR, and 1D barcodes.
- handles all the API calls and refresh tokens (when necessary).
- is an example using a webcam. There are lots of debug messages to help others troubleshoot their own scripts.
Some setup required. See 👇 for a guide setting up a Digikey/Mouser API and running the python script.
- Digikey: DK provides a fully functional barcode API for product and invoice info. 👍 good job DK!
- ✔ 2D: specific API exists for invoice and product info queries. QR code is data matrix format.
Always starts with[)>
- ✔ 1D: specific API exists for invoice and product info queries. QR code is data matrix format.
- ✔ 2D: specific API exists for invoice and product info queries. QR code is data matrix format.
- Mouser: There's a part number query API, but no native barcode searching.
- ✔ 2D: PN is extracted from DataMatrix (always starts with
>[)>
) and searched using Mouser's API - ➖ 1D: Script can read the barcodes, but currently has no way of telling which barcode value correlates to which property because there are seperate 1D barcodes for
Cust PO
,Line Items
,Mouser P/N
,MFG P/N
,QTY
,COO
, andInvoice No
.
- ✔ 2D: PN is extracted from DataMatrix (always starts with
- LCSC: No API. So we have to scrape.
- ✔ 2D: Some of my LCSC bags have QR barcodes (1 in 10 I'd guess). The QR code contains:
productCode
,orderNo
,pickerNo
,pickTime
, andcheckCode
. So far all the tool can do is search LCSC for the PN but the user needs to navigate the page and extract the info. Need to write a javascript web scraper. - ❌ 1D: String ~10 characters in length. Can't extract anything useful from these.
Since the majority of LCSC bags don't (currently) have QR codes, I'm curious how feasible OCR on the LCSC PN will be. Using tesseract:
it seems doable, but this will heavily depend on user environment. More to come.
- ✔ 2D: Some of my LCSC bags have QR barcodes (1 in 10 I'd guess). The QR code contains:
This tool was developed to aid inventory management via InvenTree