Using availability filters
In this article you will find a list of examples to help you understand how to combine filters when requesting the /findtime endpoint.
Working with the API
Take a look at our API reference to learn more about the different endpoints in the API.
Introduction
Availability filters are included (but optional) when requesting the /findtime endpoint. This is how a request to the /findtime endpoint looks like with filters added:
curl --request POST \
--url https://api.timekit.io/v2/findtime \
--header 'Content-Type: application/json' \
--user :live_api_key_7nzvc7wsBQQISLeFSVhROys9V1bUJ1z7 \
--data '{
"resource_ids": ["78a4d873-2a68-41c6-bdd4-c0ca5b35efd3"],
"filters": { "or": [
{"specific_day_and_time":{"day":"Monday","start":9,"end":13}},
{"specific_day_and_time":{"day":"Wednesday","start":10,"end": 16}}
]},
"future": "2 days",
"length": "30 minutes"
}'
In a few seconds you will learn what these filters mean and how to use them yourself.
Examples
These examples will help you configure your filters so that your particular business-rules are implemented. These examples are based on the assumption that you manually configure either your API calls or the bookings.js widget. You can configure filters on your projects for use in the booking.js widget in our admin panel, but if you need more complex configurations you need to set this up manually.
Common working-hours
Commonly working-hours are 9-18 monday to friday, this can be configured like this:
"filters": { "and": [
{"working-hours":{}},
{"exclude-weekend":{}}
]}
If you have non-common hours, like 17-21 you should use the specific time filter like so:
"filters": { "and": [
{"specific-time":{"start":17,"end":21}},
{"exclude-weekend":{}}
]}
Only specific days
If your business-rules demand only specific days, like Wednesdays and Thursdays 8-14 you should use "or" filters, because "and"'ing Wednesdays and Thursdays will rule everything out because a time-slot is never both Wednesday and Thursday. So this would be the filter you should employ:
"filters": {
"or": [
{"specific-day": "Wednesday"},
{"specific-day": "Thursday"},
],
"and": [
{"specific-time":{"start":8,"end":14}}
]
}
Special hours on specific days
If each day has its own specific hours, you should use specific day and time filters like this:
"filters": {
"or": [
{"specific_day_and_time":{"day":"Monday","start":10,"end":12}},
{"specific_day_and_time":{"day":"Tuesday","start":14,"end":18}},
{"specific_day_and_time":{"day":"Wednesday","start":10,"end":18}},
{"specific_day_and_time":{"day":"Thursday","start":10,"end":16}}
]
}
Specific dates
This is a way of adding only specific dates as available. Here we make May 29th, April 9th and July 4th the only dates available.
"filters": {
"or": [
{ "between_timestamps": {
"start":"2017-05-29T00:00:00+01:00",
"end":"2017-05-30T00:00:00+01:00"
}},
{ "between_timestamps": {
"start":"2017-04-09T00:00:00+01:00",
"end":"2017-04-10T00:00:00+01:00"
}},
{ "between_timestamps": {
"start":"2017-07-04T00:00:00+01:00",
"end":"2017-07-05T00:00:00+01:00"
}},
]
}
For a complete reference of filters please refer to our API reference.
Updated about 6 years ago