-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Distributors API (TME Prices from API) #295
Comments
My opinion and maybe also @xesscorp (we already had this discussion in past).
|
There is no need to use login/password, you need to create account at https://developers.tme.eu/en/ and then generate application token. In order to query TME API you need this token and secret. Secret is used to calculate request Signature. Python example is there: https://github.com/tme-dev/TME-API/blob/master/Python/call.py |
If there is not limit of search/responses could be interesting to the user. But I think the "good user experience" way to implement is use the the GUI and and the library that wxPython provide to save information of the software. |
I haven't used used KiCost yet, I just found it today. |
So, have a look in |
My opinion about web scraping has started to change given what @mmmaisel told us about Mouser using Distil (#282). It's becoming increasingly difficult to scrape because of things like that, and also there's the continual modifications to the web scrapers as the distributors change the HTML coding of their web pages. I looked at the Mouser API and it's not as bad as it was. It is giving more price/quantity info (up to four price breaks whereas it used to be two). It allows up to 1,000 queries per day and 50 results per query. It does require a key for each user. I haven't looked at the TME API, but I would be surprised if they don't require each individual to have their own key. I've always considered the need for an individual key to be an inconvenience for the user. Maybe there is a way to automate getting the keys from each distributor. In any event, it looks like using distributor APIs may become the only way to access their data as we move forward. |
I think before any step forward this have to be better discussed as "the future of KiCost" to create so standardization about this implementation (if we decide to support API) and do in some way to support future migration to API in the others distributors. |
Any thoughts about how you want to move forward on this @hildogjr? Losing Mouser is a problem because they're the other major US distributor comparable to Digikey. In many cases, they have the best price. With Mouser out of the picture, KiCost is limited to being a tool for ordering from Digikey (in the US). And if Digikey decides to pull a similar trick... I see three alternatives:
With options 2 & 3 , we still have to fake-out the Distil servers to make them believe we're valid users. Do you see any other alternatives? |
I see no other path to follow, but so far I "study the points", my opinion is between (1) and (3). |
|
Could we agree to dismiss (2) and (4) so and discuss about (1) and (3)? " 1. It will be interesting and quicker but we will at least add some additional Python package (I think already saw something to deal with encrypted information). But really, if this is important (I already was " 3. So far I study some code is possible to use the motor of your installed browser (which create the OS dependent code). I don't now how to procedure in this path (yet). |
Also it may be worth considering octopart again. If they are only rate limiting and not hard limiting requests I think 3/sec might be ok. |
I agree that doing some exploratory work with the Octopart API is the best option right now. Trying to fake out a browser to get around things like what Mouser is doing with Distil is just going to be too much work and we'll forever be patching it. There appear to be several Python packages that implement an interface to Octopart. Those might be the easiest way to try it out and see how much Octopart will support the current KiCost functions. As for the need of an API key, maybe we can implement something that makes getting and installing a key easier for the user. And if it's just Octopart (rather than every distributor), then it won't be so bad. Of course, we could get screwed if Octopart limits part searches or closes up entirely, but we're getting screwed right now by Mouser and others making scraping impossible. |
To me a lot of the cool stuff you have done is the build up of the spreadsheet and everything after you have the data (I guess you'd call it user interface). If the interface between getting the part data and processing/displaying the part data were a little cleaner (it may be clean and I just haven't tried hard enough to understand it) you wouldn't be too screwed. It would just be like supporting multiple back ends (part data capture). |
@anderwm, since last year (when I join to the team) @devbisme and others had a bigger effort to split the code, living all the scrape based routines inside I agree that the incredible feature of KiCost is the way that it display the price and informations, allow the users to check (missing here finish the implementation of #4), and the most difficult to implement is the scrape it self (because of the sites changes and robots detections). About the Octapart, I came up with some observations. Since it return with a lot of real distributors, it will create more than one column in the spreadsheet? Will eache distributor scrape module (and future distributor API) be predominant under Octapart (since they will have more information). Are this API suported by #65? |
If Octopart can deliver the data we need (and a preliminary scan of their current API docs suggests that it can), then it should probably replace all the web scrapers currently in use and feed its data into the various columns of the spreadsheet. Then we will need a way for the user to select which distributors they want to use and display only the data for them. Otherwise, the spreadsheet will have hundreds of columns with distributors that nobody uses. I don't know if the API takes the current location of the user into account when gathering distributor data, or if it handles currency conversion. |
On the main page https://octopart.com/ there is a list. |
I tried out Octopart and come to the conclusion that there is all important data available. Octopart API keys are definitely designed to be included into closed-source applications as you have to register the application itself. However, I think it is a bad idea to create an API key for KiCost and include it public available in the code. |
Is there a reason why we would want to keep the API code secret? I mean, some other application or person might start using our code, but would that cause a problem for us? The rate limiting is in effect regardless. I would like to avoid scraping Octopart since that means we would have to keep up with how they format the HTML of their pages. That's one of the hassles with maintaining KiCost now. |
Seems like a bad idea to go back to scraping unless you absolutely have to. Once you get enough users doing it octopart will start cracking down on it too and you will be back where you started. |
I agree with @anderwm about the user signing and the possibility of the Octopart behavior. As @xesscorp, I am not sure about encrypt the tokens, I have more applications installed here that didn't do. If we decide for this path (API in Octopart to start):
|
I also checked Octopart and it looks like it will provide the information we need. You can do a single request with all the part numbers and it will return all the pricing and availability information for all the distributors in less than 200 msec. It doesn't look like the rate limit of 3 requests per second will be an issue. We might be able to replace all the distributor web-scraping code with a single module. The pricing comes back with a field indicating the monetary unit. We might be able to do country-specific pricing with a simple currency-conversion web service and then apply it to the price tables. (That is, if Octopart doesn't already have this built into their API, somewhere.) |
Maybe they have, at least on the web page the currency is always converted to my own (that is not available at Digikey). |
I tried setting my VPN to places like Spain and Mexico, but the prices through the API still came back in US dollars. Maybe it's keyed to something else in the environment. I've attached the little example program I'm using. You might try running it where you are and see if the prices come back in your local currency. (You'll have to run it in Python 2.7.) |
Yes, returned USD (the webpage here return BRL). Could it have same difference if ran by I curious now:
|
Using the link created direct on my browser, also returned USD. So, |
I haven't seen an "obsolete" field in the JSON. Yes, the distributor's ordering code is in the sku. |
@piotrkochan, discussion merge to #314 . |
Feature / Enhancement request
TME Prices should be received via TME API https://developers.tme.eu/en
The text was updated successfully, but these errors were encountered: