How can I get the vendor ID and product ID for a USB device?

On Windows: Assuming your device is connected to the computer, go to "Device manager", find your device, right click on it, select "Properties", go to "Details" tab, select "Hardware IDs" from the drop-down, and you will find an entry of a form:

HID\VID_046D&PID_C05A 

which are correspondingly vendor and product IDs.

On Linux: Run the following command from your terminal:

lsusb

You will see pairs VID:PID near the names of all of the USB devices connected..


How can I get the vendor id and the PID for a USB device?

If you are running Windows then you can USBDeview from NirSoft.

Screenshot showing VendorID and ProductID (PID):

Enter image description here

USBDeview is a small utility that lists all USB devices that currently connected to your computer, as well as all USB devices that you previously used.

For each USB device, extended information is displayed: Device name/description, device type, serial number (for mass storage devices), the date/time that device was added, VendorID, ProductID, and more...

USBDeview also allows you to uninstall USB devices that you previously used, disconnect USB devices that are currently connected to your computer, as well as to disable and enable USB devices.

You can also use USBDeview on a remote computer, as long as you login to that computer with admin user.


Disclaimer

I am not affiliated with NirSoft in any way; I am just an end user of their software.