Here’s the ironic bummer of it all. I have been watching Adafruit/Digikey’s excellent “All The Internet of Things” videos. Ironic, because in the 2nd episode where Limor discusses public JSON APIs, I can’t find a JSON API for Digikey. Um…so this is why in MakeDigikeyBom I resorted to screen scraping. Well guess what? Screen scraping is considered by the Digikey server to be a spam bot making evil…when all I want to do is automate buying parts from Digikey. Sad. Very sad…
(A note: I have done many posts about MakeDigikeyBom….it’s what I use to go from a Kicad eeschema to ordering parts on Digikey…I am a novice Python developer and all that good stuff. If you want to make a BoM with a more professional tool, run – don’t walk – to Kicost.)
To start again….
How neat is this? Octopart has a BoM tool that accepts a CSV/spreadsheet files of parts to buy. It searches multiple parts sources and returns where the parts can be purchased and how much it costs. To make things even better, they have made it easy to order parts after the search. My goal is to update the current workflow I have to go from Schematic design to order parts (mostly on Digikey) to include Octopart’s BoM tool in the back end. Using Octopart’s BoM tool makes it easiest for me to go from an inventory of parts I need to choosing the quantity/price/vendor for parts to order. In the process, I keep track of my current inventory of parts in an effort to avoid over ordering of parts I use between projects.
The goal of this post is to document the changes I made to MakeDigikeyBoM in order to use Octopart’s BoM tool.
Files for this project are located at this GitHub location.
Oh…before we begin…let me fess up and say the input mechanic I am using is horrible. At this point, I’m hard coding the file path/file names. I was thinking of getting “fancy” and using something like Tkinter … but I left doing so for another occasion. I wanted to move on to something else I am working on…since I see this tool as for my own use, it is trivial for me to go in and modify file locations. Sorry about that!
I’m calling this project “makeBOMCSV.” The biggest improvement is not screen scraping Digikey! MakeDigikeyBoM gets the HTML page and then parses through to get quantity/price info. makeBOMCSV just creates a CSV file that is then loaded into Octopart’s BoM tool. I then rely on Octopart’s BoM tool to go from my order list to ordering from one or more suppliers.
Here is a block diagram for makeBOMCSV:
This function sucks in the rows of the two files:
- XML file made from Kicad Schematic Bom Generator.
- CSV JellyBean parts file. I included the jelly bean parts file I currently use as an example.
Maybe this stuff is useful to you. If so, I am happy! Thanks for reading this far. Please find many things to smile about.