Parse api response to get list of dates

Hi guys,

i want to use an API request to disable dates in a date range picker.
(i installed Date/Time/Range Picker (bdk) Plugin | Bubble)
The API Request is Smoobu Api

So with the API Connector i get Screenshot by Lightshot
But i need a list of dates, which are not available (available: 0)
And also when the user pics a date range i need to check the “min_length_of_stay”
So i also need to this field in a working structure. Same for “price” to calculate the price of the date range.

Thanks in advance!

Can you provide the setting of your API Connector call and also, the Raw data? (when you get the result, check at the bottom, you have access to raw data)
At first sight it seem to be an API that return a dictionnary and you will not be able to work with this directly in Bubble API Connector.

@tegernsee.media

From my experiance i would just avoid this API provider. My reasoning be is this particular API call is not suppose to be formatted this way. They return an object within another object (list), what they should be returning is an object with an array of objects.

image

Now since they send a list of objects as nested in an array Bubble will never interpret this correctly. To be clear Bubble follows standard JSON approach while this API does not. The only way i can think off is to introduce a middle-ware service between Bubble and the API to handle correcting this. Or check to see if you can use this call directly with zapier

1 Like

Thanks for your help!

The API Call:


https://login.smoobu.com/api/rates?apartments[]=474036&start_date=2021-03-01&end_date=2021-03-31

Thanks for your help!
Unfortunately I have to rely on this API.
I guess then i need help with a middle-ware service.

Exact or a plugin that will be able to transfert your json into an array instead. and it will not be easy because you will need to loop almost each part.

I hate to disagree with someone so esteemed :slight_smile: … but there ain’t no “standard JSON”. Generally accepted way of doing things, maybe.

But yeah, a bit of a crap API I agree :slight_smile:

I have used Integromat for exactly this. Call their Webhook, Integromat calls the API, sorts all the JSON out, then sends it to Bubble.

Will have a look for you. It will be a lot less painful than trying to loop it all in Bubble.

1 Like

Playing around with it in Integromat now.

Well, that was a monster!

As usual it was fairly simple when you find the right integromat function.

First, Parse the API result to JSON.

Now use the Keys function to extract the Dates (which are Keys).

The crash it all back into JSON with a Create JSON.

Annoyingly I haven’t got the structure right for Bubble, but will sort that today.

In the meantime, I passed text back, and used a regex to split the texts into a list of dates.

(and removed the and " too…)

Whoever thought that this was a good way to do JSON (and the input dates in an array are a bit dumb as well) … needs to have a stern word with themselves.