dkurok

What exactly does /api/v3/lego/elements/{id}/ search for

Recommended Posts

Hello,

can someone please explain what exactly the API-function GET /api/v3/lego/elements/{id}/ is used for?

In detail:

- What ID is the parameter in (Lego-Element-ID, LEGO-design-ID,....)?

- What is the result? The part_id seems not to be a Renrickable Part-Number

Try for example 18862 for the {id} . It returns:

{
  "part_id": 11548,
  "color_id": 70,
  "element_id": "6031144",
  "design_id": "88585"
}

So this seems to be LEG-Element-IDs and Design-ID for the queried ID. But the part_id is not a valid Rebrickable-ID/part_num...
To be honest, I'm not so familar with the way especially LEGO is numbering their parts;so maybe someone can explain here or guide me to some ressource to understand...

Best regards

Dietmar

Share this post


Link to post
Share on other sites

Whoops, it was looking up on the internal primary key. I've changed it to lookup the actual element_id as originally intended.

Share this post


Link to post
Share on other sites

Nathan, can you please explain what the function returns?

I still get for example:

api/v3/lego/elements/6031144/

{ "part_id": 11548, "color_id": 70, "element_id": "6031144", "design_id": "88585" }

and then with the returned part_id

/api/v3/lego/parts/11548/

I receive 

{ "detail": "Not found." }  (404)

(I used API V3 testpage on https://rebrickable.com/api/v3/docs/ for making sure I have no errors in my implementation)

So what kind of part_id does lego/elements/{id} return?

Best regards

Dietmar

Share this post


Link to post
Share on other sites

The part_id is an internal representation, you'll have no use for it. I've changed it to show what part it is, and also expanded the color field to be consistent with other calls.

Share this post


Link to post
Share on other sites

Great! I just tested it and now I think I understand what it returns.

Am I right with the following? :

A tupple (LEGO-design-id , LEGO-Color-ID) is mapped equivalent (in the meaning of bidirectional)  to a (LEGO-Element-ID) 

Share this post


Link to post
Share on other sites

It's the part/color that are mapped to the element id. The lego design id is more informational but is used internally when the element is added to assist with finding the correct part to link it to.

Share this post


Link to post
Share on other sites