Process with the ShapeDiver Backend API to fetch the GLB files?


Short stupid question… when working with the backend API of ShapeDiver I do not know how to fetch the GLB geometry output out of a session response. Could anyone assist me by pointing me to the method that I am suppose to use as an href.

const res = await sdk.session.init(ticket)

// sample first item of response
const url = Object.values(Object.values(response.outputs)[0].content)[0].href;

fetch(url, {
      mode: "no-cors",
    }).then((response) => {
     //returns a status = 0 | response.ok = false

Many Thanks,

Please note that your model most probably exposes several outputs. You might want to select the one you are looking for by its name. Related reading (there is also a video): Outputs on the API

As an example, this code would iterate through all the outputs and get the href to the first glb found:

let href = "";
for (const outputId in response.outputs) {
    const output = response.outputs[outputId];
    if (!output.content) continue;
    for (const item of output.content) {
        if (item.format === "glb") {
            href = item.href;
    if (href) break;

Thanks Alex,

It is just one output: the geometry… that is why I was a bit direct on the process.

Model (just a box):

The link it outputs… is a 0.glb file that has nothing inside (3kb) while the original file as seen in the image above has a 2652kb of data representing a box:

Is there anything I might be doing wrong on the setup? or does the fetching require credentials?

Thanks again,

These links are time limited, maybe it was already outdated once you triggered the download?
Did you inspect the response from fetch for errors?

For completeness: mode no-cors caused the problem, changing it to cors solved it.