msx

Finding how many of a specific part you have

Recommended Posts

So i'm often in the case where i'm evaluating the use of a part X in a MOC and i want to know how many i have in my whole collection. Is there an API for that? The closests thing looks like this one:

/api/v3/users/{user_token}/parts/

But it appears to only look into Part Lists and not into Sets.

Is there a way to search the whole collection? (other than retrieving inventory of each and every set? :P )

Share this post


Link to post
Share on other sites

Wasn't aware of this behaviour up to now...
I just tested  /api/v3/users/{user_token}/parts/  with the somehow rare "70496" (I know I've got texactly two of them; one in a  set (8285-1) and one in my loose parts).

It returns only the one from my loose parts. From the description of the function it should " Get a list of all the Parts in the user's LEGO collection. "; so I also understand both (sets and loose parts).

@Nathan, is this an error?

Best regards

Dietmar

Share this post


Link to post
Share on other sites

have you tried:  /api/v3/users/{user_token}/allparts/ ? that would be the logical API for it if you browse the main page.

but that's just a guess I haven't read the API documentation, if there are any.

Share this post


Link to post
Share on other sites

The /parts/ call was intended to search part lists only, I've updated the wording to reflect that.

I've now added an /allparts/ call to search both part lists and set lists combined. This takes into account lost parts, sets in sets etc - it's the same data displayed on the /allparts pages. Be aware that these are extremely cpu intensive calculations and I'm a bit hesitant to expose it to an api, but we'll see how it goes.

Share this post


Link to post
Share on other sites

I tried allparts-function and it returns both of my 70496. In the result I cannot distinguish/find out from where they are coming (from part-list or from setsminus parts of lost-parts) - but the result -as far as this little test can proof- is fine and together with the /parts-function it fits my needs.

Thank you!

Share this post


Link to post
Share on other sites

That level of detail is far too much for the API to handle. If you need it, query the partlists and lost parts separately.

Share this post


Link to post
Share on other sites