[#885] Getting available slots for multiple days with REST API

Migrated from Redmine #885 | Author: Erik Borge
Status: New | Priority: High, I’m very impatient | Created: 2022-05-27


Hi.
I’m making a custom booking flow by using the REST API on a website where I need to show a calendar with days where there are available slots. That means I want to disable days where there are no available slots, so the user can only click on days with available slots. For this, I have two pieces of relevant information:

https://user-api-v2.simplybook.me/admin/schedule - Tells me if a given day from a range of dates is a working day (is_day_off): true/false. Here, I can ask for a range of dates, so I could for example find all working days in a month.
https://user-api-v2.simplybook.me/admin/schedule/available-slots - Gives me available slots for a given day. Here, I cannot ask for a range of dates.

The problem is that I cannot directly get all the information I need from one API call. That is, available slots for, let’s say, a month at a time, because the /schedule/available-slots endpoint gives me only slots for a single day. Right now, the only solution I see is to first get all dates with “is_day_off”: false, and for all those days get available slots in a separate call for each day. It could work, but as a result I would need to make like 20 API calls for each month the user navigates to in my calendar, which would generate a lot of unnecessary API calls and potentially generate long loading times on my page to wait for all the calls to go through.

Is there a solution for gettting available slots for a range of dates? Or do I need to make a lot of API calls to get the information I need? I would think this is a pretty normal functionality to have, so if it doesn’t exist it could be an idea to implement it.

Thanks

Erik

Redmine Admin wrote:

hi, there is no way to add possibility to get all slots for custom periods (e.g. for a month) because of huge server load such requests may cause. In your case the only way is to make many API calls and implement some caching mechanism to not do 30 calls each time when you need to show full month to your clients.

Erik Borge wrote:

Ok, thanks.

(Short original content)

Erik Borge wrote:

This can be closed now.