This block of API calls are used to search and fetch bookings.
After a booking is created it can be retrieved using its id:
>>> response = requests.get('https://api.kaizenep.com/v2/bookings/182503b1-5fdf-400b-99da-e564b932b66b', headers=headers)
>>> response.json()
{
"id": "b98aede7-16e0-4efe-b5e1-10f08406ca84",
"rev": "25-83397e192e5fdfdd890b451867dd3e9c",
"organisation": "org_fry",
"user": "fry",
"bookingItemId": "cf178130-a68a-4f3e-a931-64240f791283",
"bookingOptionId": "d60e783a-cf0a-4b2d-b95c-ee9988c44a5f",
"type": "booking",
"createdDate": "2021-10-12",
"modifiedDate": "2021-10-20"
"fields": [
{
"text_value": "Fry Admin",
"str_value": "Fry Admin",
"key": "wff-hn0gvjcdue",
"label": "Name"
},
{
"text_value": "Test",
"str_value": "Test",
"type": "string",
"key": "wff-x3ew8aryti",
"label": "Please comment"
}
],
"metadata": [
{
"value": "No",
"key": "booking_confirmed"
},
{
"value": "No",
"key": "seat_confirmed"
}
],
"state": {
"id": "ws-i1b1cyhfmi",
"name": "SUBMITTED"
},
"bookingOption": {
"id": "d60e783a-cf0a-4b2d-b95c-ee9988c44a5f",
"name": "A good one (option 1)",
"breadcrumbs": [
{
"id": "cf178130-a68a-4f3e-a931-64240f791283",
"name": "A good one"
},
{
"id": "d60e783a-cf0a-4b2d-b95c-ee9988c44a5f",
"name": "A good one (option 1)"
}
],
"venue": {
"id": "d7741cd0-33e0-4305-b245-3af74f8f2517",
"name": "Venue 1"
},
"bookingType": {
"id": "3e711835-c916-4e7d-983d-bd3fdb6e4418",
"name": "Clinical exam"
},
"metadata": [
{
"value": "1",
"key": "Key 1"
},
{
"value": "2",
"key": "Key 2"
}
],
"bookingItem": {
"id": "cf178130-a68a-4f3e-a931-64240f791283",
"name": "A good one"
}
},
}
The content of a received booking can be controlled by a includeParts argument. These are the possible parts:
all - Includes everything
bookingOption - Includes information about respecive booking option
fields - Includes the application form fields as visible by the API user
allfields - Includes all the application form fields. The “Allow user to manage bookings” is required.
balance - Includes summary balance information
transactions - Includes a list of all related transactions
ownerProfile - Includes the full owner profile
metadata - Includes meta information about the booking such as confirmation and seat reservation
auditLog - Includes audit log of actions
Searching for bookings is done by sending a POST request to the search endpoint. The actual search is controlled by the payload which consts of these parts (all are optional):
filter - This defines the filter applied. For a complete list of available options please look at the OpenApi specification. This does not have and defaults so omitting all filters means it returns everything.
sort - This defines how the results are sorted. Please have a look at the specification which sortings are available
size - This defines how many rows should be returned. At the moment there is no hard limit. The recommended size depends on requested data being returned. If full objects are being returned the size should be less than 1000.
start - This defines the offset when search allowing for pagination.
options This controls whether it returns only user ids or the full objects. If the full objects are returned is it possible to further limit the content using the includeParts as when retrieving one user.
An example request returning only ids:
>>> payload = {
"filter": {
"bookingItem": ["bookingItemId1"],
"createdAfter": "2020-01-01"
},
"size": 10,
"options": {
"includeIds": true,
"includeDocs": false
"includeParts": []
}
}
>>> response = requests.post('https://api.kaizenep.com/v2/bookings/search', json=payload, headers=headers)
>>> response.json()
{
'ids': [
'd84ab1e9-b453-4928-8877-66a4f596a911',
'660ad117-01b7-4c61-807c-a418093013ad',
'e5dca22e-64dd-4a97-b827-27b47111cf58',
'8ed2827f-9eeb-43d4-8024-79be7f8b273c',
'74a559a6-d248-4761-bd4e-d678fc893948',
'28611379-80ba-4d45-806a-139abc5ef85f',
'b9a46329-fed4-4208-a2ed-429d344b1487',
'72d040ab-57a0-45be-b59e-197f42dad7b6',
'509afaea-5d2e-46d6-ae44-c415b0301f22'
],
'size': 10,
'start': 0,
'total': 490
}
An example request returning evaluated bookings:
>>> payload = {
"filter": {
"bookingItem": ["bookingItemId1"],
"createdAfter": "2020-01-01"
},,
"size": 10,
"options": {
"includeIds": false,
"includeDocs": true
"includeParts": []
}
}
>>> response = requests.post('https://api.kaizenep.com/v2/bookings/search', json=payload, headers=headers)
>>> response.json()
{
"docs": [
{
"id": "b98aede7-16e0-4efe-b5e1-10f08406ca84",
"rev": "25-83397e192e5fdfdd890b451867dd3e9c",
"organisation": "org_fry",
"user": "fry",
"bookingItemId": "cf178130-a68a-4f3e-a931-64240f791283",
"bookingOptionId": "d60e783a-cf0a-4b2d-b95c-ee9988c44a5f",
"type": "booking",
"createdDate": "2021-10-12",
"modifiedDate": "2021-10-20"
"state": {
"id": "ws-i1b1cyhfmi",
"name": "SUBMITTED"
},
"bookingOption": {}
},
...
],
'size': 10,
'start': 0,
'total': 490
}
When there is a set of known booking ids it is possible to retrieve them in bulk using the fetch method:
>>> payload = {
"ids": [
'd84ab1e9-b453-4928-8877-66a4f596a911',
'660ad117-01b7-4c61-807c-a418093013ad',
'e5dca22e-64dd-4a97-b827-27b47111cf58',
'8ed2827f-9eeb-43d4-8024-79be7f8b273c',
'74a559a6-d248-4761-bd4e-d678fc893948',
'28611379-80ba-4d45-806a-139abc5ef85f',
'b9a46329-fed4-4208-a2ed-429d344b1487',
'72d040ab-57a0-45be-b59e-197f42dad7b6',
'509afaea-5d2e-46d6-ae44-c415b0301f22'
],
"options": {
"includeParts": []
}
}
>>> response = requests.post('https://api.kaizenep.com/v2/bookings/fetch', json=payload, headers=headers)
>>> response.json()
{
'docs': [
{
"id": "b98aede7-16e0-4efe-b5e1-10f08406ca84",
"rev": "25-83397e192e5fdfdd890b451867dd3e9c",
"organisation": "org_fry",
"user": "fry",
"bookingItemId": "cf178130-a68a-4f3e-a931-64240f791283",
"bookingOptionId": "d60e783a-cf0a-4b2d-b95c-ee9988c44a5f",
"type": "booking",
"createdDate": "2021-10-12",
"modifiedDate": "2021-10-20"
"state": {
"id": "ws-i1b1cyhfmi",
"name": "SUBMITTED"
},
"bookingOption": {}
},
...
]
}
Hint
Best practices
When retrieving large set of data it is recommended to separate the search and fetch into multiple calls. First run the search and let it return the ids - if only ids are returned the size can be in thousands. Next paginate the resulting ids and fetch evaulated objects iteratively. This ensures a fixed result set, faster responses and ability to meausre progress.