API Integration Problem - Duffel.com

Hello to all!

I’m writing to you today because I’m stuck on an API problem.

I want to create an online airplane tickets booking platform thanks to the Duffel.com API.

I watched several tutorial videos in order to understand how API integration works in Bubble (API connector plugin, different types of requests etc…).

The Duffel API allows you to search for airline tickets via a POST call and returns a list of tickets matching the parameters of the search.

See this page of the documentation: Getting Started with Flights<!-- --> | Duffel Documentation

I have successfully configured the first call to send a request to search for airline tickets by importing this into Bubble :

curl -X POST --compressed “https://api.duffel.com/air/offer_requests?return_offers=false
-H “Accept-Encoding: gzip”
-H “Accept: application/json”
-H “Content-Type: application/json”
-H “Duffel-Version: beta”
-H “Authorization: Bearer myapikey”

My problem: I can’t display the result of this query in my app, even in a simple text element (I tested the query in Postman and it returns a list of airline tickets).
I got a button with a workflow that launch the query, but I don’t know what to do after.

I think that (maybe ?) I’m supposed to configure another GET call to access the search results but… This call must contain a dynamic parameter (the ID of the first query), so I don’t see how to configure it in Bubble.

I think there is something I don’t understand, but I don’t see what.

I’ll stop here before making a long post, but if there is an API expert here who would like to help me I’d love it!

Thanks in advance and have a great day :slight_smile:

Yes. You get returned an id in the Offer Request.

Use that in a GET.

curl -X GET --compressed "https://api.duffel.com/air/offers?offer_request_id=$OFFER_REQUEST_ID&sort=total_amount" 
  -H "Accept-Encoding: gzip" 
  -H "Accept: application/json" 
  -H "Duffel-Version: beta" 
  -H "Authorization: Bearer $YOUR_ACCESS_TOKEN"

Thanks for your answer NigelG!

I’m not sure how I should use these calls.

The fact that there is a POST call first and then a GET call confuses me. Do I need to start a workflow that will dynamically retrieve the ID of the previous Offer request on my page?

So far I’ve only used “simple” APIs, with a single GET request to display the result in text or an image (with the Giphy API for example).

I feel like I’ve tackled something a bit too complex for me ahah…

Yes. So in your workflow you do the POST as Step 1 and then the GET as Step2 using the data from step 1.

You can point Step 2 at the results of Step 1.