Speckle V2 REST API auth

I’m just trying to work with the v2 rest api and am unable to get it working after following the docs to Downloading a list of objects here: REST API | Speckle Docs

I notice it says:

  • objects (string): An array of object ids, serialized as a JSON string

but I’m not sure how I’m supposed to get a list of object IDs, before downloading a list of objects that belong to that stream.

My current python code looks like this:

import requests

jwt = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
url = "https://v2.speckle.arup.com/api/getobjects/670577f4c6"
headers = {"Accept":"application/json", "Authentication": jwt}
r = requests.post(url, headers=headers)

Not a python nor REST API expert here, but a quick search in the specklepy repo shows how it’s being used in our python SDK :wink:

Any specific reasons for not using the SDK?

Thanks @teocomi

I might end up using the SDK for python stuff, but since I’ll be doing JS stuff as well, I just wanted to play around and get an idea of what’s changed in v2.

I still don’t understand how to list all objects that are in a stream. In this example, it seems the child objects are already available and we’re just asking for those objects in particular. But what if I just have a stream ID and want to grab all child objects?

Looking at the SDK I also noticed that the authentication header needs to have "Bearer " before the token, which I think I did try, but good to know for sure.

Given a stream id you can get its latest commit’s root object, from there you need to go through the closure table to get the children object ids… @dimitrie or @izzylys or @cristi can elaborate a bit more!

This you can’t - V1 streams are now commits - this little mental switch might help! To get all the objects in a stream, you’ll need to first get all its commits, and then proceed to get their object’s children.

Also to bear in mind data inside a commit (v1 stream) is not a flat list of objects anymore, it’s actually an object graph (tree), and there’s two ways which you can go through it:

  • raw dump of all the children via the rest endpoints, and reconstruct the object graph on the receiving end as you deserialise (this is what our sdks do for you)
  • interactive drilling into it, which you can do via the graphql api (basically like we’re doing in the data explorer in the frontend)