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?

2 Likes

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.

Hey @sudsy, you mentioned you did not have the need anymore for this, did you find a solution or went for a workaround?

Thanks

Hi, @marcelo1. Nope, no solution unfortunately. It would be really cool, though, if related data could be fetched in a single request up to some arbitrary depth via a query string parameter. It would be super useful and far more efficient to do it server-side than via multiple HTTP requests.

Right, it would be much better. My dream would be a GraphQL endpoint, in case any Bubbler is listening. haha.

I will stick to multiple requests for now then.

Thanks for the response, @sudsy

I just learned that Stripe actually has such functionality. It would be super sweet if there was a way to “expand” objects retrieved via the Bubble Data API.

BTW, what’s the official channel for submitting feature requests? Email to support? Submit a bug report? :man_shrugging:

1 Like

@sudsy

Have you implemented the expand object in a Stripe Get Call?

I’ve been able to do it for a single properties as well as expanding multiple levels

Screen Shot 2021-05-07 at 3.53.21 PM
Screen Shot 2021-05-07 at 3.53.08 PM

But can not figure out how to request multiple properties.

I’ve tried setting it up like this below, and although the call is initialized, the raw response doesn’t show both properties…instead it only shows the expansion of a single property and it is always the second in the setup (in example below, it only shows customer object expansion)

Hi @boston85719,

As this thread is specifically about the Bubble Data API and not Stripe (I just pointed to Stripe as an example of what I’d like to see in Bubble), if you could move your post or create a new thread, I’d be happy to respond.

That would keep things on topic and enable the proper solution to be marked as such, which would help other forum users (as well as duly credit the one who provided the correct answer).

Thanks,

-Steve

2 Likes

Thanks…just got it sorted after using a couple of ideas I thought about last night. I’ll probably end up creating a tip post

1 Like

Any update on such a feature ?

The need is here and users have identified it years ago, I just do not understand how come it was not prioritised it yet. Furthermore, it does not even seems that complicate to put in place.

Hi @boston85719 did you end up getting it sorted out? I’m stuck trying to expand a Stripe GET call and would appreciate the link to your tip post!

expand[customer] or expand[payment_intent]

Whatever field from Stripe you want to expand (if Stripe allows it to be expanded) would use the same approach expand[field_name]