Title: Barcodes, Partkeepr and parts providers(TME) Author: paco Date: 2018-03-08 Type: article _Update 2021-05-29: I don't use Partkeepr anymore. It's been a pain to maintain and update over time. I wrote [this nasty thing][7] which is good enough for me._ Electronic parts are small ... and they get smaller and smaller when you go down the rabbit hole of SMD components. They are also really difficult to organize and catalogue. There are useful tools like [Partkeepr][1] to help you keep things tidy and, most importantly, don't buy things twice because you can't find them or you don't remember where the hell they are (or even don't remember that you have them). The only drawback to that is that you have to manually insert all the parts that you buy ... which is tedious. I basically get my parts for 4 places: * The _slow boat from China_, when piece is important and time is not. * Ebay, basically same thing, although sometimes there are sellers in Europe, which is nice ! * [TME][2], a polish distributor with fairly good prices and good catalogue that I tend to use when I need to be sure what I'm buying. * And [Farnell/Element14][3], when I need something that I cannot find anywhere else ... It turns out that the last 2 have good APIs to query their catalogue. And specifically TME adds a little iQR code to all their packages with some info. With any old webcam you can find, and [zbar][4], you can extract the info on that iQR code easily, and dump it to `stdout`. It looks something like this (this is a little 12V fan): QTY:1 PN:HA50151V4 MFR:SUNON MPN:HA50151V4-000U-999 PO:xxxxxx/x https://www.tme.eu/details/HA50151V4 where: FIELD NAME Desc 0 QTY Quantity 1 PN Part Number 2 MFR Manufacturer 3 MPN Manufacturer part number 4 PO Order Number (at TME) 5 Url of the product at vendor(TME) That's easy to parse, and contact TME's API for more info. I've put together a little python3 script that takes that from `stdin` and makes all the necessary calls (to TME and then to Partkeepr), so I don't have to enter my TME orders by hand anymore. You can find it [here][5] You'll need a token and secret from the distributor. So go to their developer's [page][6] and sing in. It downloads the datasheets too (if they have any) and uploads them to Partkeepr. If the item is already in the db, it just increments the stock. On the git page you can find more info, but it's really easy to use, just pipe the output of zbar to the script like this: zbarcam --raw /dev/video0 | ./parteye.py If I order something from Farnell I'll check if they do something similar, so I can adapt the script. [1]: https://www.partkeepr.org/ [2]: https://www.tme.eu/ [3]: http://farnell.com [4]: http://zbar.sourceforge.net [5]: https://git.e1e0.net/parteye/log.html [6]: https://developers.tme.eu [7]: https://git.e1e0.net/partsdb/log.html