Filter nested get api call data for a search

Hi, @keith , @romanmg , @Jici

In my app the user runs a search similar to expedia for flights. When they search my workflows run to get a response from an api. The API returns nested data that I have been trying to filter into a repeating group.

This has been very difficult.

So far I have a search box that collects the values and displays on a different page like so

However the array is not parsed/filtered into individual segments

The API returns a JSON array that has ‘data’ with ‘slices’ nested within the data and then ‘segment’ and other kinds of data nestled within the slices like that. There are several ‘segment’'s within each slice. (example from postman below)

What would be the best way to filter or parse the data to display individual flights?

I can not use backend API workflows because the number of searches would quickly exceed the limit of the api workflow.

I have tried saving the data as a field within a thing but it just saves ‘data from api’, ‘data from api’, … etc.

After the api call I plan on displaying the data in a repeating group similar to expedia.

Ideally I could save each segment as a thing and variables like departure airport as fields

My main question is how do I ‘filter’ or ‘parse’ each segment (which is essentially a flight) and then display them in a repeating group (where each row has an available flight)?

I am open to using external tools/plugins to get it to work, I just don’t know what to use/implement

Hey @anon31591471, after taking a look at this API (Duffel, which by the way is quite interesting), I don’t really understand your problem. I did a very quick-and-dirty (completely insecure, etc.) implementation of Duffel’s offer_requests and offers (the offer detail endpoint) endpoints and all the data is properly nested exactly the way you’d want it.

Look at this sample page, it implements a search (the search params are hardcoded) and displays (in an ugly way) each offer’s info. I just used formatted text within each cell, but you can put RG’s within RG cells of course to better format list-type data.

Click the Select button on any item in the RG to see “details” (not all of them, obviously), retrieved via the offer endpoint.

In setting up the calls, I just let Bubble automatically interpret everything (obvs, you’d want to set date/time type things to be dates, etc.). In both cases, all of the stuff you need is hanging off of the “data” node of each API response.

I used list shifter to make the expressions a bit easier to deal with (blue list shifter retrieves the offer_request response (which is a scalar object) and the pink one looks at that offer request’s “offers” node, which is a list of "data"s that have all the flight info you need (as lists in some cases).

Note that you don’t have to interact with the Bubble database at all. In fact, since offers expire, the whole point of the Duffel interface is to dynamically fetch offers via the API, on demand.

Here’s the run mode:

You’ll see a button there to view the page in edit mode.


Dude you are an angel thank you so much!! I was just about to give up, first time using bubble and have had a headache for days trying to figure it out! You are amazing, thank you! I’m still trying to figure it out, but I can see it can be done!


Hi @keith ,

I am trying to use liftshifter to only show departing flights in a repeating group. I watched your video on how to use lift shifter but is there a way in list shifter that I can use the program to only select certain items from the api list based off of whether their origin iata_code is the correct airport?

For example, I choose MIA to JFK and in the repeating group list shifter only shows the flights from MIA to JFK and then tags the flight within the segment so that I can show the JFK to MIA flights from the same segment in a separate repeating group in the next page?

I have been working on this for a few days and still can’t figure out how to filter individual items from the api, this is the last thing I need for the website to work, so any and all help is greatly appreciated!


I don’t quite understand your question as the Duffel API requires you to send an origin and destination and only returns offers for those destinations. If the number of slices specified is greater than 1 in the request (e.g., formatted as a round-trip) the offers that come back will have multiple SLICES representing the SEGMENTS.

In your query, you can send the max_connections body parameter if your user wants to limit the number of segments (see Offer Requests | API Reference – Duffel).

But anyway, if you DID desire to filter a list of offers or a list of slices or a list of segments, you just write the expression you need. There’s a :filtered operator on all lists. You might need to get familiar with the “Advanced” filter option (which lets you do much more granular filtering that gets close to what you could do with filters in JavaScript, but not anything super-complex).

However, with these objects being as complicated as they are, you may run into some issues there. So, unless you want to do a little of your own coding, you may not be able to achieve exactly what you want. (So, make the API do the work.)

But I don’t understand your stated need. I’ve updated my example with a new one that’s a little fancier. This new page does a round trip search (so the query has 2 slices, and you get 2 slices back, each of which may have 1 or more segments) and shows how you can display all sorts of info about the various offers using nested Repeating Groups (it’s exactly what I continue to do with text, but it shows how you’d construct that).

And, sorry if you were in there checking the example out immediately. I was just testing some other junk in that page. But I’ll leave it alone now. :slight_smile:

Haha, I am checking it out right now! I was just watching your list popper video when you replied to see if that may help haha

Usually when I have been running the api calls I use the ‘body_id’ from the Duffel Offer Request and then send the id as part of the get request for the duffel offers. In the example it looks like you use the flights returned from the post api call “Duffel Offer Request” instead of the Get duffel offers request. Why do you use the first one instead of the second? or is it interchangeable?

I have tried to use the :filtered and advanced filter but I cannot get it to work because I am trying to filter the list of texts from Duffel with an iata_code text (i.e. PSP).

My basic issue

I have tried to filter the API through postman with parameters but to my knowledge the Duffel API has very limited filtering capabilities.

My main goal/issue (hopefully more simply put): Duffel returns segments that can have multiple flights from origin to destination and multiple return flights from destination to origin. I want to filter the Duffel response by individual items (by stating ‘origin iata_code’=‘PSP’ for example) but I cannot find a way to filter them with :filter, advanced filter, :contains, custom states, or parameters sent through the api. I was hoping that I could filter via the lift shifter but I have not been able to do so.

P.s. I have sent email to Duffel for help filtering via the url parameters in the get call and am waiting for a response.

P.S.S. with the get flight offers API request I often receive different airports than what I enter. (for example I type in PSP and get flights from LAX) and I have sent this to duffel too.

Thanks so much for helping I really appreciate everything you have done. You and your posts from the past have been a lifesaver in learning bubble!

1 Like