-
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
Use Partinfo API #346
Comments
So the API uses GraphQL. There are some client libraries available for Python that may make things easier but the basic principle is that you make a Here is an example using import requests
query = """
query ($input: MpnInput!) {
part(mpn: $input) {
mpn {
manufacturer
part
}
type
datasheet
description
image {
url
credit_string
credit_url
}
specs {
key
name
value
}
offers {
sku {
vendor
part
}
description
moq
in_stock_quantity
stock_location
image {
url
credit_string
credit_url
}
specs {
key
name
value
}
prices {
GBP
EUR
USD
}
}
}
}
"""
variables = '{"input": {"part": "NE555P", "manufacturer": "Texas Instruments"}}'
r = requests.post("https://dev-partinfo.kitspace.org/graphql", {"query": query, "variables": variables})
print(r.json()) Here is the same example in the interactive GraphiQL interface where it may be easier to play around a bit. |
Interesting, start to understanding. Five comments:
For now, this answers and the bellow configuration
will restore the KiCost main capabilities, the other infos stay for future implementation. |
Thanks for looking into it.
We can work on that I guess, is it important?
Makes sense, that requires a bit of work on the Partinfo site. We are currently restricted to the 5 vendors supported by Kitspace.
FYI Partinfo also doesn't currently have pagination thus max search results returned are currently 20, is that a problem? |
It is not a problem just return 20 by time. KiCost just have to ask twice... I am a quite of time now, I already update something at |
@kasbah, I am having problem with the API Mouser response (testing in the query system yet) for the part So far I checked, it appear be related to the price break, even on the web page those appear different. But I think is not your code layer. |
Sorry, what is the problem exactly? |
For example IPW60R160P6FKSA1 returned as "0 in stock". |
Just checked, that's down to Octopart unfortunately, they have the wrong stock information for that part at the moment. On a separate issue:
There is no way to get more than 20 results even if you ask twice. |
I imagined that. So don't worry, nothing we can do for this.
|
In the future we can figure out an additional data source for Mouser. Partinfo does support the Farnell API as well, and could improves the stock information for that, but the API limit prevents me from turning it on at the moment. Hopefully I will be able to fix that soon. No, currently it's a hard limit of 20 items for the |
@kasbah, for use the match query I:
What I am doing wrong? And 2 question:
|
You need a list with the proper structure as input. Here you go. I don't think there is a limit on the size of the
|
@kasbah , please gimme a tip / have a look at line 193 of I have the query type
the components query
The code is summarized to
That works at your GraphiQL platform. But I am getting response 400 (Bad request) from my Python code. |
Forgot @kasbah, it was just missing |
@kasbah, Are the server offline? I am getting "504 Gateway Timeout" (also with https://dev-partinfo.kitspace.org/graphql) |
Yes, there was an issue. Should be fixed now. Thanks for letting me know. |
Some alpha code is ready but still need some fix to the cases the PartInfo return no available data for one specific part in one distributor. |
Can you give an example? |
@xesscorp, I think that I have fixed the "add to BOM list" Windows issue. Missing the context menu. |
I downloaded the latest KiCost and ran it under Windows 7 with KiCad 5.1.2. When I ran
After that, I ran KiCad and EESCHEMA. KiCost was in the BOM list and it started running when I clicked on it. So I'm not sure if it actually failed to be added. I also saw KiCost in the context menu when I right-clicked on an .xml file. It's possible KiCost had already been added before I ran the --setup, so I decided to run
If you can get the |
@xesscorp, I had fix the Win issue related do path named at the When you use the context-menu in a .xml file, did the GUI open with the specified file? After this, I will release on PyPI. |
@xesscorp, I create the documentation by your make file (I don't know how to publish it after). Please check it and the |
--unsetup still fails:
|
Fixed the issue and already in I think that I also fix #289 @xesscorp, release or gimme so guidance to release/update https://xesscorp.github.io/KiCost. |
@kasbah, KiCost with PartInfo API is released https://forum.kicad.info/t/new-kicost-release/8074/2 |
FYI there have been over 700 octopart requests resulting from KiCost since I put the service up again. |
Over what time period? |
Do you have some statistic of how much of them was new (not replicated or already cached by you) or the traffic day-by-day? |
Since 27th of June. This only counts cache misses i.e. when it actually makes requests to Octopart. Oh, and it actually also includes people using https://bom-builder.kitspace.org. It does seem like a lot. I should set up some more sensible logging. |
I think, it will be interesting for your:
|
Let's just keep an eye on it for now, I don't have a lot of time to spend on this unfortunately. |
I imagine that "1" was inevitable to the KiCost future. |
@kasbah, how to search by the distributor catalogue number? (Is it possible in the actual API?) If I search only by 386, I get the not correct part. So, in my schematic I fill the two information and KiCost prioritize Is it possible something similar? (Allow my to get a specific part for the catalog number in one distributor?) |
Use |
I am reopening until add this feature. |
I was already using sku, I just had to change the query logic to prioritize "stock codes". @kasbah, could you give me some direction about use https://github.com/kitspace/electro-grammar on Python in local machine (without unnecessary query from your server)? |
The Antlr4 port is pretty much abandoned. I did have an earlier experiment to port to Python using Lark but it's not finished either. The best way to go about finishing it would probably be to port the test-suite to Python first of all. |
@kasbah, I was improving some behaviors and checking about the query responses. I am sharing a log of the full batch test (I always used the match query): See the 'TPS71725QDRV' manufacture part number, for example, it's return as "not found" because, at least on Digikey the complete code is 'TPS71725QDRVRQ1'. Previous versions of KiCost dealt with this by some string match but I don't now if is possible now. As far I checked is the same for all the reported "not found" parts that not the '{'sku': {'part': '694-9374', 'vendor': 'RS'}}', for some reason your API is return empty price. |
Hey sorry I missed your message. Can you report future issues to the Partinfo GitHub please rather than this hugely long thread. I believe the first issue is already reported. The second one is probably down to Octopart not returning the price info. FYI dev-partinfo is currently not making new Octopart requests because we hit the limit. I have requested a higher limit (which will cost $50 a month). |
As I mentioned on the forum I'd be happy for KiCost users to make use of the Partinfo API.
To cover the API costs when Octopart does ask for payment I suggest we pool money in opencollective.com/kitspace. I estimate that $100 a month will be enough to cover current KiCost users (but we will see of course).
Some more explanation of the current Partinfo schema.
Currently there are 3 query types and all of the return
Part
types. As with the Octopart API thePart
types contains an array ofOffer
types from different retailers with prices. E.g.Returns a single
Part
that matches a manufacturer part number (Mpn
) or retailer stock keeping unit (Sku
). This is considered a match. You can also batch multiple part matches requests and get back multiple parts.We can also search and get back multiple parts.
Here free form text is parsed by Electro Grammar and turned into parametric Octopart searches and also matched against the Common Parts Library.
The text was updated successfully, but these errors were encountered: