Use PyUSB to Find Vendor and Product IDs for USB Devices

As an Amazon Associate this site may earn from qualifying purchases made through the suggested links below.

Vendor and Product IDs

These numbers are part of the USB "device descriptor" spec and are assigned to vendors by the governing body. Here's a big, though incomplete, list by vendor. Discovering and using these values can be handy in talking to USB devices. So far these IDs have helped me read data from 2 different Microsoft USB mice and hack the weight from a Dymo S250 USB scale.

Decimal vs Hexadecimal Caveat

Product and vendor IDs may be expressed in decimal or hexadecimal (number usually starts with 0x). For instance, testing a Microsoft Comfort Mouse 6000 for Business mouse with the Python code below returns:

  • Decimal VendorID=1118 & ProductID=1917
  • Hexadecimal VendorID=0x45e & ProductID=0x77d

Python/PyUSB Code to Find USB Devices

Here's the basic code using version 1.0 of PyUSB. This assumes the PyUSB instructions have been followed and the required version of libUSB and Python are already installed.

Copy and paste the following code and save it to a file. My file is called

import sys
import usb.core
# find USB devices
dev = usb.core.find(find_all=True)
# loop through devices, printing vendor and product ids in decimal and hex
for cfg in dev:
  sys.stdout.write('Decimal VendorID=' + str(cfg.idVendor) + ' & ProductID=' + str(cfg.idProduct) + '\n')
  sys.stdout.write('Hexadecimal VendorID=' + hex(cfg.idVendor) + ' & ProductID=' + hex(cfg.idProduct) + '\n\n')

Finding A Particular Device

  1. Plug in the USB device and run the code above, like python
  2. Unplug the device you're trying to discover
  3. Run python again
  4. Compare the lists to find the device that disappeared between 1 and 3.

Lovingly crafted by orangecoat with some rights reserved, and a promise not to spam you.

Back to top