Would you like to clone this notebook?

When you clone a notebook you are able to make changes without affecting the original notebook.

Cancel

Get Hotel Avail v2

node v10.24.1
version: 1.3.0
endpointsharetweet
This sample app shows how to call the Get Hotel Availability V2 API. This is an orchestrated service that returns rich content for properties including amenities, media, and lead-rates across mulitple content sources. Look to the API Reference for more details: https://beta.developer.sabre.com/docs/rest_apis/hotel/search/get_hotel_avail_v210 See the Content Services for Lodging page for an overview of everything available: https://beta.developer.sabre.com/docs/travel-agency/content-services-for-lodging
// bring in a helper-library called axios that makes API request code cleaner and easier const axios = require('axios'); // search criteria highlighting one way to find properties const searchAirportCode = 'LAS'; const searchCheckIn = '2019-09-01'; const searchCheckOut = '2019-09-05' const requestPayload = { GetHotelAvailRQ: { SearchCriteria: { OffSet: 1, SortBy: 'TotalRate', SortOrder: 'DESC', PageSize: 20, TierLabels: false, GeoSearch: { GeoRef: { Radius: 50, UOM: 'MI', RefPoint: { Value: searchAirportCode, ValueContext: 'CODE', RefPointType: '6', }, }, }, RateInfoRef: { ConvertedRateInfoOnly: false, CurrencyCode: 'USD', BestOnly: '2', PrepaidQualifier: 'IncludePrepaid', StayDateRange: { StartDate: searchCheckIn, EndDate: searchCheckOut, }, Rooms: { Room: [ { Index: 1, Adults: 1, Children: 0, }, ], }, InfoSource: '100,110,112,113', }, HotelPref: { SabreRating: { Min: '3', Max: '5', }, }, ImageRef: { Type: 'MEDIUM', LanguageCode: 'EN', }, }, } }; // make the API request axios({ method: 'post', url: 'https://api-crt.cert.havail.sabre.com/v2.1.0/get/hotelavail', data: JSON.stringify(requestPayload), headers: { 'content-type': 'application/json', accept: 'application/json', authorization: 'Bearer T1RLAQJ05v0bqkNbnIueA8N0e/6rIjk/2xCvwchiRQaQPo/0QDCc4L41AACwvOIp6O+TMhVH3geh9LD3MCvsF1OYW03kYtyUqRGEAN5bHrulrdA+qquoYOg3htVggh/fcX16kOxLTJbl3OnCfYW0MeL7ikhdFMVA9+l9o+ShakiabSyRDGZC1Itc6xvpVz2iz6tA3rwZ64tbM2YwKbzsDndxDT5EcjcwoKDM9Mm9SSnGAzG8ONxP+J8hkgmc10mh4XoSKrP+Ky5JVfQ4TI7IMTcBGzzg0RpOKGS6Dfw*', 'Application-ID': 'SWS1:SBR-CtntSerLgUI:1f06045fcf' } }) .then(function (response) { // HTTP 200 console.log(response.data); DisplayAllHotelNamesAndLeadRates(response.data); }) .catch(function (error) { // HTTP 400 or 500 console.log('Something went wrong'); console.log(`${error.response.status} ... ${error.response.statusText}`); console.log(error.response.data); }); function DisplayAllHotelNamesAndLeadRates(data) { const hotelInfo = data.GetHotelAvailRS.HotelAvailInfos.HotelAvailInfo; hotelInfo.forEach((hotel) => { DisplayHotelName(hotel.HotelInfo); DisplayHotelLeadRates(hotel.HotelRateInfo.RateInfos.RateInfo); }); } function DisplayHotelName(hotelInfo) { console.log(`Name: ${hotelInfo.HotelName}`); } function DisplayHotelLeadRates(hotelRates) { hotelRates.forEach((rate) => { console.log(`>> Rate: ${rate.AmountAfterTax} ... Source: ${rate.RateSource}`); }); }
Loading…

no comments

    sign in to comment