Forum Documentation Showcase Pricing Learn more

Expanding List Item Details in Data API GET Response?

Is there a way to retrieve details of list items associated with a “Thing” using Bubble’s GET data API?

Basically, I have defined a component Thing and subcomponent Thing in the DB. Each component has a name, ID, and various other attributes, one of which is a list of sub components.

When I fetch the component details using Bubble’s data API, it simply lists the Bubble ID of the sub components in the JSON response. What I want is for details of the subcomponents to be listed. Is that possible? Am I overlooking a setting or going about things the wrong way?

Ok, so there appears to be no way to “expand” lists when a Thing is retrieved via the data API, which unfortunately, makes the API less useful than I had hoped. :frowning_face:

As an example, let’s say I wanted to retrieve order details as a single JSON object, where Order and Item are separate Things in the DB. The Order would be fetched, and it would contain (among other data) a list of ID’s of the items purchased. A separate GET request would then need to be sent to retrieve the detail for those Items using the search API.

If all Order data were needed in a single JSON response, I guess one way would be to implement a “proxy” endpoint which retrieves the main Order and Items "in separate requests and then outputs a single JSON with the aggregate data.

Am I overlooking a simpler approach? Anyone have any ideas?

The bubble API returns a results object.
Running this in your console should establish a promise, then return a response, which will have an array of your data.

fetch('https://YOUR_APP.bubbleapps.io/version-test/api/1.1/obj/YOUR_THING')
  .then(res => res.json())
  .then(json => console.log(json));

Hi Scott, thanks for taking the time to reply.

Understood.

My question was about getting related data in a single request. Bubble returns just the unique Bubble ID of related data. One would have to make multiple requests to get all related data. At the time, I think I was looking for something akin to “joining” the results from multiple tables in a single HTTP request.

Anyway, I no longer have this need, but it seems implementing a “proxy” endpoint that issues multiple asynchronous requests “behind the scenes” would be one approach.