How to improve your Booking Queries by search type using Metadata's information
There are two search types that determine how we run a Booking Query to the Seller's system. The type of search is chosen through the input typeSearch: BookingCriteriaType.
1. REFERENCES
If you choose REFERENCES, you should fill in the information in the references node elements or indicate a bookingID.
1.1. Booking Query through BookingID
You can retrieve the information from a single booking through the bookingID returned in BookRS, which should be indicated in HotelCriteriaBookingInput (REFERENCES in typeSearch).
Example:
Get BookingID from Book response:
{
"data": {
"hotelX": {
"book": {
"booking": {
"reference": {
"client": "clientReferenceTest",
"supplier": "supplierReferenceTest",
"bookingID": "bookindIDTest"
},
"price": {
"currency": "EUR",
"net": 800,
"gross": 800,
"binding": false
},
"status": "OK",
},
"errors": null,
"warnings": null
}
}
}
}
Insert it into bookingID in HotelCriteriaBookingInput and add the client (if the access is test access, you have to indicate testMode: true)
{
"criteriaBooking": {
"bookingID": "bookindIDTest",
"typeSearch": "REFERENCES"
},
"settings": {
"client": "myclient"
}
}
1.2. Booking Query without BookingID
You can retrieve the information from several bookings at the same time through the references from Book mutation, which should be indicated in the node references: CriteriaBookingReferencesInput
As you can see, three fields are mandatory ('!'):
- HotelCode (supplier contex)
- Currency (standard ISO 4217 code)
- References, which may have more than one BookReferenceInput - even though they are optional on our side, some may be mandatory for the Seller (you can check this through our Metadata Query):
Metadata Query example applied to References - Please check our API Schema and Documentation in order to check all the queryable fields available:
Request:
{
hotelX {
metadata(criteria: {supplierCodes: ["supplierCode"]}, relay: {}) {
adviseMessage {
code
level
description
}
edges {
node {
metadataData {
supplierCode
booking {
queryableBySupplierReference {
reviewDate
value
}
queryableByClientReference {
reviewDate
value
}
requiresCheckInDateInReferencesSearchType {
reviewDate
value
}
requiresCheckOutDateInReferencesSearchType {
reviewDate
value
}
requiresCheckInDateInReferencesSearchType {
reviewDate
value
}
}
}
}
}
}
}
}
Please, note that in this example, we are using inline variables. You can (as the booking examples) declare variables like "criteriaBooking" and send it via parameter to query. GraphQL variables.
Response
{
"data": {
"hotelX": {
"metadata": {
"adviseMessage": null,
"edges": [
{
"node": {
"metadataData": {
"supplierCode": "supplierCode",
"booking": {
"queryableBySupplierReference": {
"reviewDate": "2018-12-27",
"value": true
},
"queryableByClientReference": {
"reviewDate": "2018-12-27",
"value": true
},
"requiresCheckInDateInReferences": {
"reviewDate": "2021-10-11",
"value": false
},
"requiresCheckOutDateInReferences": {
"reviewDate": "2021-10-11",
"value": false
},
"requiresReservationDateInReferences": {
"reviewDate": "2021-10-11",
"value": false
}
}
}
}
}
]
}
}
}
}
- "queryableBy" fields indicate that the supplier allows searching through these fields.
- "requires" fields indicate whether receiving this information is mandatory on the Seller's API.
- "value" indicates if that Seller requires or allows that specific field.
- "reviewDate" indicates the last time this value was checked against the Seller.
Note: if you are not using bookingID input, you should indicate your accessCode in the HotelCriteriaBookingInput. Language is optional, but, for best results, please indicate it.
2. DATES
You should choose DATES in order to retrieve all the bookings between a date range. In order to do so, you should fill in the following mandatory fields:
- dateType: it indicates if the dates in your request make reference to check-in date or booking date.
- start and end: they indicate the date range to be retrieved (always complying to ISO 8601 yyyy-MM-dd).
Example
{
"criteriaBooking": {
"accessCode": "0",
"language": "en",
"typeSearch": "DATES",
"dates": {
"dateType": "ARRIVAL",
"start": "2022-01-13",
"end": "2022-10-01"
}
}
}
You can check whether a Seller allows Booking by check-in our booking date through our Metadata Query
Metadata Query example applied to Dates- Please check our API Schema and Documentation in order to check all the queryable fields available:
Request:
{
hotelX {
metadata(criteria: {supplierCodes: ["supplierCode"]}, relay: {}) {
adviseMessage {
code
level
description
}
edges {
node {
metadataData {
supplierCode
booking {
queryableByCreationDate {
reviewDate
value
}
queryableByCheckinDate {
reviewDate
value
}
}
}
}
}
}
}
}
Response:
{
"data": {
"hotelX": {
"metadata": {
"adviseMessage": null,
"edges": [
{
"node": {
"metadataData": {
"supplierCode": "supplierCode",
"booking": {
"queryableByCreationDate": {
"reviewDate": "2022-01-13",
"value": true
},
"queryableByCheckinDate": {
"reviewDate": "2022-10-01",
"value": false
}
}
}
}
}
]
}
}
}
}
In the aforementioned example, Metadata informs that this Seller only allows search by booking creation date (booking date), so we should select dateType: BOOKING
{
"criteriaBooking": {
"accessCode": "0",
"language": "en",
"typeSearch": "DATES",
"dates": {
"dateType": "BOOKING",
"start": "2022-01-13",
"end": "2022-10-01"
}
}
}
Note: if you are not using bookingID input, you should indicate your accessCode in the HotelCriteriaBookingInput. Language is optional, but, for best results, please indicate it.