{"id":2796,"date":"2025-03-17T13:20:20","date_gmt":"2025-03-17T13:20:20","guid":{"rendered":"https:\/\/www.makcorps.com\/blog\/?p=2796"},"modified":"2025-04-09T10:23:54","modified_gmt":"2025-04-09T10:23:54","slug":"track-cheapest-hotel-prices-across-vendors-using-google-sheet","status":"publish","type":"post","link":"https:\/\/www.makcorps.com\/blog\/track-cheapest-hotel-prices-across-vendors-using-google-sheet\/","title":{"rendered":"How to Track the Cheapest Hotel Prices Across Top Vendors Using Hotel Price API and Google Sheets"},"content":{"rendered":"\n<p>Are you a travel agent, travel agency, or part of a travel business looking to score the best luxury hotel deals for your clients? You&#8217;re in the right place.<\/p>\n\n\n\n<p>And here\u2019s the good news\u2014you don\u2019t need to know how to code. This solution is simple. Follow the steps below to build it from scratch. Plus, you\u2019ll get a ready-to-use blueprint at the end. Download it, edit it, and start pulling the cheapest hotel prices across top vendors using Makcorps API.<\/p>\n\n\n\n<p>In this tutorial, we\u2019ll be using 10 Big Brands in Sydney to find out which vendor offers the lowest price for each one.<\/p>\n\n\n\n<p>Let\u2019s get into it.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_76 ez-toc-wrap-center counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #e29a12;color:#e29a12\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #e29a12;color:#e29a12\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.makcorps.com\/blog\/track-cheapest-hotel-prices-across-vendors-using-google-sheet\/#What_Youll_Need\" >What You\u2019ll Need:<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.makcorps.com\/blog\/track-cheapest-hotel-prices-across-vendors-using-google-sheet\/#Step_1_Get_Your_Makcorps_API_Key\" >Step 1: Get Your Makcorps API Key<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.makcorps.com\/blog\/track-cheapest-hotel-prices-across-vendors-using-google-sheet\/#Step_2_Prepare_the_Google_Sheet\" >Step 2: Prepare the Google Sheet<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.makcorps.com\/blog\/track-cheapest-hotel-prices-across-vendors-using-google-sheet\/#Step_3_Add_App_Script_Code\" >Step 3: Add App Script Code<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.makcorps.com\/blog\/track-cheapest-hotel-prices-across-vendors-using-google-sheet\/#What_to_do\" >What to do:<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.makcorps.com\/blog\/track-cheapest-hotel-prices-across-vendors-using-google-sheet\/#Step_4_Fetch_Hotel_ID\" >Step 4: Fetch Hotel ID&nbsp;<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.makcorps.com\/blog\/track-cheapest-hotel-prices-across-vendors-using-google-sheet\/#Step_5_Fetch_Hotel_Price_Data\" >Step 5: Fetch Hotel Price Data<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.makcorps.com\/blog\/track-cheapest-hotel-prices-across-vendors-using-google-sheet\/#Step_6_Fetch_the_Cheapest_Vendors_List\" >Step 6: Fetch the Cheapest Vendors List<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.makcorps.com\/blog\/track-cheapest-hotel-prices-across-vendors-using-google-sheet\/#Get_Your_Blueprint_Automate_Everything_Fast\" >Get Your Blueprint &amp; Automate Everything Fast<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/www.makcorps.com\/blog\/track-cheapest-hotel-prices-across-vendors-using-google-sheet\/#Wrapping_Up\" >Wrapping Up:<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"What_Youll_Need\"><\/span>What You\u2019ll Need:<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A free account on <strong><a href=\"https:\/\/www.makcorps.com\/\">MakCorps.com<\/a><\/strong><\/li>\n\n\n\n<li>Google Sheet<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_1_Get_Your_Makcorps_API_Key\"><\/span>Step 1: Get Your Makcorps API Key<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>First, <a href=\"https:\/\/makcorps.com\/signup.html\" target=\"_blank\" rel=\"noopener\">sign up<\/a> for a free account on Makcorps.com.&nbsp;<\/p>\n\n\n\n<p>Verify your email address.&nbsp;<\/p>\n\n\n\n<p>Once you\u2019re in, check your email for your API key.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXcxzwrl90MTQMr2zpdShj9--j_P-O_Q_lD26ftyP2hu_nT1KQtQ9E55Fijsn7cbLaYB3hEPahSH1pKPXLT-9SdMsnlYQr3UGhOjViVBQ36maMQL-Lnkmn16ch-J1bR70xE1MEjuyg?key=1bAsCVWOCHCjwZv9_TNMYQGi\" alt=\"\"\/><\/figure>\n\n\n\n<p>A free account gives you 15 API calls to get started. If you need more, you can upgrade anytime to access more credits. Check out the pricing from <a href=\"https:\/\/makcorps.com\/#sectionPricing\" target=\"_blank\" rel=\"noopener\">here<\/a>.&nbsp;<\/p>\n\n\n\n<p>With your API key ready, make sure you also save the two API endpoints we\u2019ll be using throughout this process:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Hotel Mapping API<\/strong> \u2013 This helps you pull the hotel ID. (Full details are in the <a href=\"https:\/\/docs.makcorps.com\/mapping-api-hotel-city-ids\" target=\"_blank\" rel=\"noopener\">documentation<\/a>.)<\/li>\n\n\n\n<li><strong>Hotel Price API<\/strong> \u2013 This gets you price comparison data. You\u2019ll need the hotel ID from the first API to use this one. (More info in the <a href=\"https:\/\/docs.makcorps.com\/hotel-price-apis\/hotel-api-search-by-hotel-id\" target=\"_blank\" rel=\"noopener\">documentation<\/a>.)<\/li>\n<\/ol>\n\n\n\n<p>Keep both handy. We\u2019ll be switching between them as we move forward.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_2_Prepare_the_Google_Sheet\"><\/span>Step 2: Prepare the Google Sheet<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Now, let\u2019s set up your Google Sheet. We\u2019ll create four tabs, each handling a different part of the process.<\/p>\n\n\n\n<p>Here\u2019s what you\u2019ll do:<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>1) input tab<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>In this tab, you\u2019ll list out all the hotel names you want to track.<\/li>\n\n\n\n<li><strong><em>Example: <\/em><\/strong>Enter the hotel names under the <strong>Hotel Name<\/strong> column.<\/li>\n\n\n\n<li>Keep it simple\u2014one hotel name per row and also add the city name with the hotel name.\u00a0<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXdpPGvrC6TXv06rms8RPeNqNlgeZ6mOIzlsOvV0LGhcnQHlkVacfsVNqUbxW9iPAnuoK38jMIQE7Nhe6RfMoq_oMj0hU4VutH6GBPxhAeUYsVQyM-dsyYNR330u1HTcsNOsMqHaQA?key=1bAsCVWOCHCjwZv9_TNMYQGi\" alt=\"\"\/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>2) hotel id output tab<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>This is where you\u2019ll store the hotel IDs that you\u2019ll get from the Hotel Mapping API.<\/li>\n\n\n\n<li>Column A: <strong>Hotel Name<\/strong><\/li>\n\n\n\n<li>Column B: <strong>Hotel ID<\/strong><\/li>\n\n\n\n<li>Leave this empty for now\u2014we\u2019ll automate this in the next step.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXdfF29dnioKg7Uwkm76FCBjKV6tlqK77V0w-eg2F88Ix2JtnK7whtuvGEIMlaFgKrgK5B1470xJN2m8KP6KwPuFkFzxk0dod4o8qoMLPe5ItPPzmHExm3fjSNqYtZUQ-mCY_lMdGA?key=1bAsCVWOCHCjwZv9_TNMYQGi\" alt=\"\"\/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>3) price tracking input tab<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Here\u2019s where you\u2019ll set up the details for pulling price data:\n<ul class=\"wp-block-list\">\n<li>Column A: <strong>Hotel Name<\/strong><\/li>\n\n\n\n<li>Column B: <strong>Hotel ID<\/strong><\/li>\n\n\n\n<li>Column C: <strong>Check-In Date<\/strong><\/li>\n\n\n\n<li>Column D: <strong>Check-Out Date<\/strong><\/li>\n\n\n\n<li>Column E: <strong>Adults<\/strong><\/li>\n\n\n\n<li>Column F: <strong>Rooms<\/strong><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Fill out the <strong>dates, adults, and rooms<\/strong> based on your data needs.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXcdPxDoPjyty8LWAXMUVefYtnD3tyYUmSBU_CnB3J79vP6VEvciLa0Pg3w2qIzOQU8KZduwDraPavJLS4C4WOlfdFYDcH8vKLxEXwQX_dzjiX8KQ__G4MO7yyhoUbXVeZK39wTcmw?key=1bAsCVWOCHCjwZv9_TNMYQGi\" alt=\"\"\/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>4) price tracking output tab<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>This is where the API will send the vendor pricing data. Just add the headers.\n<ul class=\"wp-block-list\">\n<li>Column A: <strong>Hotel Name<\/strong><\/li>\n\n\n\n<li>Column B: <strong>Vendors<\/strong><\/li>\n\n\n\n<li>Column C: <strong>Price<\/strong><\/li>\n\n\n\n<li>Column D: <strong>Tax<\/strong><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXdn6yft4sbQt0aRnzNpi9F7sKYzKFvyiJ1gtPn2xIrbL0K7EJr4dXhIRCDXd-Z5CzOIagU-LmC5SXtcVqhP2NayX2RdiTRkXHUdyZtSkquIkKbVyazlZz5elY0RESjBLRu5v7-6_A?key=1bAsCVWOCHCjwZv9_TNMYQGi\" alt=\"\"\/><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>5) cheapest vendors list tab<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Finally, we\u2019ll filter the cheapest vendor per hotel here.\n<ul class=\"wp-block-list\">\n<li>Column A: <strong>Hotel Name<\/strong><\/li>\n\n\n\n<li>Column B: <strong>Cheapest Vendors<\/strong><\/li>\n\n\n\n<li>Column C: <strong>Price<\/strong><\/li>\n\n\n\n<li>Column D: <strong>Tax<\/strong><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXdXEg3zgMi9UyTAdrzOUYiLHlHedEJhcSqJSuJ3VOx7pRTHICLrq7ai-eymWLo83OT3vy3nO-z9ka2iYmz8gwMWsWgMBby3E_TXsRoS6J4ju4lpCLJbXcKmxoJwxG6w9wNwYMcp-w?key=1bAsCVWOCHCjwZv9_TNMYQGi\" alt=\"\"\/><\/figure>\n\n\n\n<p>This setup will make it easy to pull, organize, and spot the best prices across multiple vendors for each hotel.<\/p>\n\n\n\n<p>The tabs are ready, and next, we\u2019ll use the API to populate the data automatically with code.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_3_Add_App_Script_Code\"><\/span>Step 3: Add App Script Code<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>In this step, you\u2019ll connect your Google Sheet to the Makcorps APIs and automate everything\u2014from pulling hotel IDs to getting the hotel price data.<\/p>\n\n\n\n<p>Below is the code you\u2019ll need. It does the full job:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Extracts hotel IDs using the Hotel Mapping API<\/li>\n\n\n\n<li>Pulls price comparison data using the Hotel Price API<\/li>\n\n\n\n<li>Populates the sheet with hotel prices from multiple vendors<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"What_to_do\"><\/span><strong>What to do:<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Copy the code below.<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>function fetchHotelIDs() {\n\n\u00a0\u00a0var ss = SpreadsheetApp.openById(\"Sheet_Id\"); \/\/ Your actual Spreadsheet ID\n\n\u00a0\u00a0var inputSheet = ss.getSheetByName(\"input\"); \/\/ Sheet name for input\n\n\u00a0\u00a0var outputSheet = ss.getSheetByName(\"hotel id output\"); \/\/ Sheet name for output\n\n\u00a0\u00a0var inputRange = inputSheet.getRange(\"A2:A\" + inputSheet.getLastRow()); \/\/ Dynamic range for hotel names\n\n\u00a0\u00a0var hotelNames = inputRange.getValues();\n\n\u00a0\u00a0var apiResults = &#91;];\n\n\u00a0\u00a0for (var i = 0; i &lt; hotelNames.length; i++) {\n\n\u00a0\u00a0\u00a0\u00a0var hotelName = encodeURIComponent(hotelNames&#91;i]&#91;0]);\n\n\u00a0\u00a0\u00a0\u00a0if (hotelName !== \"\") {\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0var url = \"https:\/\/api.makcorps.com\/mapping?api_key=My API_KEY&amp;name=\" + hotelName;\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0var options = {\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\"method\": \"get\",\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\"muteHttpExceptions\": true\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0};\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0var response = UrlFetchApp.fetch(url, options);\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0var json = JSON.parse(response.getContentText());\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Logger.log(json); \/\/ Log API response for debugging\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if (json &amp;&amp; json.length > 0 &amp;&amp; json&#91;0].hasOwnProperty(\"document_id\")) {\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0apiResults.push(&#91;hotelNames&#91;i]&#91;0], json&#91;0].document_id]);\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0} else {\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0apiResults.push(&#91;hotelNames&#91;i]&#91;0], \"No ID Found\"]);\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\n\n\u00a0\u00a0\u00a0\u00a0} else {\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0apiResults.push(&#91;hotelNames&#91;i]&#91;0], \"Invalid Hotel Name\"]);\n\n\u00a0\u00a0\u00a0\u00a0}\n\n\u00a0\u00a0}\n\n\u00a0\u00a0\/\/ Output results to the 'hotel id output' sheet\n\n\u00a0\u00a0if (apiResults.length > 0) {\n\n\u00a0\u00a0\u00a0\u00a0var outputRange = outputSheet.getRange(2, 1, apiResults.length, 2);\n\n\u00a0\u00a0\u00a0\u00a0outputRange.setValues(apiResults);\n\n\u00a0\u00a0}\n\n}\n\nfunction fetchHotelPrices() {\n\n\u00a0\u00a0var ss = SpreadsheetApp.getActiveSpreadsheet();\n\n\u00a0\u00a0var inputSheet = ss.getSheetByName(\"price tracking input\");\n\n\u00a0\u00a0var outputSheet = ss.getSheetByName(\"price tracking output\");\n\n\u00a0\u00a0var lastRow = inputSheet.getLastRow();\n\n\u00a0\u00a0\/\/ Start writing from the second row to preserve headers\n\n\u00a0\u00a0\/\/ Clear only the data rows, keep the headers intact\n\n\u00a0\u00a0var dataRange = outputSheet.getRange(\"A2:D\" + outputSheet.getLastRow());\n\n\u00a0\u00a0if (outputSheet.getLastRow() > 1) {\u00a0 \/\/ Check if there's data below the header\n\n\u00a0\u00a0\u00a0\u00a0dataRange.clearContent();\n\n\u00a0\u00a0}\n\n\u00a0\u00a0var outputRow = 2;\u00a0 \/\/ Initialize outputRow to start writing from row 2\n\n\u00a0\u00a0for (var i = 2; i &lt;= lastRow; i++) {\n\n\u00a0\u00a0\u00a0\u00a0var hotelName = inputSheet.getRange(i, 1).getValue();\n\n\u00a0\u00a0\u00a0\u00a0var hotelId = inputSheet.getRange(i, 2).getValue();\n\n\u00a0\u00a0\u00a0\u00a0var checkIn = formatDate(inputSheet.getRange(i, 3).getValue());\n\n\u00a0\u00a0\u00a0\u00a0var checkOut = formatDate(inputSheet.getRange(i, 4).getValue());\n\n\u00a0\u00a0\u00a0\u00a0var adults = inputSheet.getRange(i, 5).getValue();\n\n\u00a0\u00a0\u00a0\u00a0var rooms = inputSheet.getRange(i, 6).getValue();\n\n\u00a0\u00a0\u00a0\u00a0var apiUrl = 'https:\/\/api.makcorps.com\/hotel?hotelid=' + hotelId + '&amp;rooms=' + rooms + '&amp;adults=' + adults + '&amp;checkin=' + checkIn + '&amp;checkout=' + checkOut + '&amp;api_key=My API_Key';\n\n\u00a0\u00a0\u00a0\u00a0var options = {\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'method': 'get',\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0'muteHttpExceptions': true\n\n\u00a0\u00a0\u00a0\u00a0};\n\n\u00a0\u00a0\u00a0\u00a0var response = UrlFetchApp.fetch(apiUrl, options);\n\n\u00a0\u00a0\u00a0\u00a0if (response.getResponseCode() == 200) {\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0var json = JSON.parse(response.getContentText());\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if (json &amp;&amp; json.comparison &amp;&amp; json.comparison&#91;0].length > 0) {\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0var comparisonData = json.comparison&#91;0];\u00a0 \/\/ Assuming the data is in the first index\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0comparisonData.forEach(function (vendorData, index) {\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0var vendor = vendorData&#91;'vendor' + (index + 1)];\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0var price = vendorData&#91;'price' + (index + 1)];\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0var tax = vendorData&#91;'tax' + (index + 1)];\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0if (vendor &amp;&amp; price &amp;&amp; tax) {\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0outputSheet.getRange('A' + outputRow + ':D' + outputRow).setValues(&#91;&#91;hotelName, vendor, price, tax]]);\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0outputRow++;\u00a0 \/\/ Increment output row for next data entry\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0});\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0} else {\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0outputSheet.getRange('A' + outputRow + ':D' + outputRow).setValues(&#91;&#91;hotelName, 'No data', 'N\/A', 'N\/A']]);\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0outputRow++;\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}\n\n\u00a0\u00a0\u00a0\u00a0} else {\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0outputSheet.getRange('A' + outputRow + ':D' + outputRow).setValues(&#91;&#91;hotelName, 'Failed to fetch', 'N\/A', 'N\/A']]);\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0outputRow++;\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Logger.log('Failed to fetch data for Hotel ID: ' + hotelId + ' with response: ' + response.getContentText());\n\n\u00a0\u00a0\u00a0\u00a0}\n\n\u00a0\u00a0}\n\n}\n\nfunction formatDate(date) {\n\n\u00a0\u00a0var d = new Date(date);\n\n\u00a0\u00a0var day = ('0' + d.getDate()).slice(-2);\n\n\u00a0\u00a0var month = ('0' + (d.getMonth() + 1)).slice(-2);\n\n\u00a0\u00a0var year = d.getFullYear();\n\n\u00a0\u00a0return year + '-' + month + '-' + day;\n\n}\n\nfunction getCheapestVendors() {\n\n\u00a0\u00a0const ss = SpreadsheetApp.getActiveSpreadsheet();\n\n\u00a0\u00a0const sourceSheet = ss.getSheetByName(\"price tracking output\");\n\n\u00a0\u00a0const targetSheet = ss.getSheetByName(\"cheapest vendors list\");\n\n\u00a0\u00a0const N = 1; \/\/ Change this to 1, 2, or 3 as needed\n\n\u00a0\u00a0const numRows = sourceSheet.getLastRow() - 1; \/\/ exclude header\n\n\u00a0\u00a0if (numRows &lt;= 0) {\n\n\u00a0\u00a0\u00a0\u00a0Logger.log(\"No data found in 'price tracking output'\");\n\n\u00a0\u00a0\u00a0\u00a0return;\n\n\u00a0\u00a0}\n\n\u00a0\u00a0const data = sourceSheet.getRange(2, 1, numRows, 4).getValues();\n\n\u00a0\u00a0const hotelGroups = {};\n\n\u00a0\u00a0data.forEach(row => {\n\n\u00a0\u00a0\u00a0\u00a0const &#91;hotel, vendor, price, tax] = row;\n\n\u00a0\u00a0\u00a0\u00a0const numericPrice = parseFloat(price.replace(\/&#91;^0-9.]\/g, '')) || 0;\n\n\u00a0\u00a0\u00a0\u00a0if (!hotelGroups&#91;hotel]) {\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0hotelGroups&#91;hotel] = &#91;];\n\n\u00a0\u00a0\u00a0\u00a0}\n\n\u00a0\u00a0\u00a0\u00a0hotelGroups&#91;hotel].push({\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0hotel,\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0vendor,\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0price: numericPrice,\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0displayPrice: price,\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0tax\n\n\u00a0\u00a0\u00a0\u00a0});\n\n\u00a0\u00a0});\n\n\u00a0\u00a0const output = &#91;];\n\n\u00a0\u00a0for (let hotel in hotelGroups) {\n\n\u00a0\u00a0\u00a0\u00a0const sorted = hotelGroups&#91;hotel].sort((a, b) => a.price - b.price);\n\n\u00a0\u00a0\u00a0\u00a0const topVendors = sorted.slice(0, N);\n\n\u00a0\u00a0\u00a0\u00a0topVendors.forEach(entry => {\n\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0output.push(&#91;entry.hotel, entry.vendor, entry.displayPrice, entry.tax]);\n\n\u00a0\u00a0\u00a0\u00a0});\n\n\u00a0\u00a0}\n\n\u00a0\u00a0\/\/ Write below the existing header in your \"cheapest vendors list\" sheet\n\n\u00a0\u00a0if (output.length > 0) {\n\n\u00a0\u00a0\u00a0\u00a0targetSheet.getRange(2, 1, output.length, 4).setValues(output);\n\n\u00a0\u00a0}\n\n}<\/code><\/pre>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Go to extension and then the app script.\u00a0<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXfmt-qgDs8okGhv-OmMJFHChkNjW_1CuQYQcFVhNawn-Zl42gZq5xxttFJNgy3a-peQA57YOHppWZ5zMHQls3ZykYVg0dxKufKw6JG1A8-6LYByszx-n4XASg5ioV90w0hNoIiPPA?key=1bAsCVWOCHCjwZv9_TNMYQGi\" alt=\"\"\/><\/figure>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li>In Code.cs paste the code provided.\u00a0<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXcStF2mXhJvTx9QtDShlnHGnv3irNaDXcMdui6NY5yDDvchcv-850YPscDvOc5aj-mi8HrN0vbiVva_KmPfdPYLO4GKGauH6jQD3fivP3PiZ5GsDkV2Q3BC5uI58tk5fXRbHqupfw?key=1bAsCVWOCHCjwZv9_TNMYQGi\" alt=\"\"\/><\/figure>\n\n\n\n<ol start=\"4\" class=\"wp-block-list\">\n<li>Replace <strong>\u201cSheet_Id\u201d <\/strong>with your actual Google Sheet ID.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXccECevc_fMPPS3cZZlt_caPnkeiwl0SygWEnHkZP5DgdKTl9Femwd-Ibb3dMXC-Kklmc9XYfcGNIi1P99pbAqWYauZiA-bchEMM0qHdYb7RqynMYvQbj5RzqbKhOPdS_AeTkWh?key=1bAsCVWOCHCjwZv9_TNMYQGi\" alt=\"\"\/><\/figure>\n\n\n\n<p>This is where you will get your spreadsheet ID:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXewksB2LNByU3LEoJjgpD1d8-_eLWjkou0JiMhNk21WzogUhEDHGWYz-7RGfy1622OU-NXA4-09IzDxahr1gRLRhO-KxD8Am9BMrQA6qqHtGKxC0B7vamOVflPlZZx4Plq8NCX7iw?key=1bAsCVWOCHCjwZv9_TNMYQGi\" alt=\"\"\/><\/figure>\n\n\n\n<ol start=\"5\" class=\"wp-block-list\">\n<li>Replace <strong>\u201cMy API_Key\u201d<\/strong> with your actual API key from Makcorps in the code. API key has to be added twice, to search for \u201cMy API_Key in the code, and replace it with your API key code.\u00a0<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXc5drw2PjQFcJSME0Qx-ZogQlW06InpDlGnkT14SrFHXYn5-eV8puNJTbwLcVNt_hX0FFxu3B8Y2AH--9HGegGwuSXcxTfCe17_TCydffWl0mZ7S6g-UWDqn-e4qKIxQx9vACje?key=1bAsCVWOCHCjwZv9_TNMYQGi\" alt=\"\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_4_Fetch_Hotel_ID\"><\/span>Step 4: Fetch Hotel ID&nbsp;<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>After updating the Code.cs file, select <strong>fetchHotelIDs<\/strong> from the dropdown and click <strong>Run<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXf8hgnDL05cUVKqbP-nKeYQbGT926kUWjbTZXDoZmT-wzIjhFVpAMaVzPywTw4-D1qKch8cytDw3EjI6oNiTbq6NeGO3rt3KJU4E2LMsIUerfabty_5gpCT43P83F-P5rR03NgyCw?key=1bAsCVWOCHCjwZv9_TNMYQGi\" alt=\"\"\/><\/figure>\n\n\n\n<p>The script will now pull all the data and populate it directly into the <strong>hotel id output<\/strong> tab.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXfGl1Z_92Tts0P6FY-NP4FgrqNblEfSgrK7rO4oRz5S8cr6YmdB-u99UuJPQeX5NivghTtTYXsEgQrpMWRHtBmpiuui2iFVJarIa95VTHdffjfQ1klDmR5jcnyKbBQWYEjxkKJ9?key=1bAsCVWOCHCjwZv9_TNMYQGi\" alt=\"\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_5_Fetch_Hotel_Price_Data\"><\/span>Step 5: Fetch Hotel Price Data<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Once you have the hotel IDs, copy the names and IDs from the <strong>\u201chotel id output\u201d<\/strong> tab and paste them into the <strong>\u201cprice tracking input\u201d<\/strong> tab.&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXeHo-XDCHSQqMi8KCe0Z6A3NwOUAVQBwMX7OL6VMLexbqVx9Z_QdWkKHDz66EapPk0_Psw3j7FwHBQvwoU3T95ab9z42f1youOkJ7CS5ECyIMFhBCGZMWLvh7aeoz-rQyHSZ7GMGQ?key=1bAsCVWOCHCjwZv9_TNMYQGi\" alt=\"\"\/><\/figure>\n\n\n\n<p>Then, go back to Apps Script, select <strong>fetchHotelPrices<\/strong> from the dropdown, and run the script.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXdYiGa4kk9Yt5pkxAuIpI5Ndvm1oP9v9i3yBbJmprQ7Jl3tecdYq5-_8G7oucI0Eo3G0zJEh5YaoQM14NQXUnPbrZO6YeWXQCKSfwImhXn_eh2es3Op2YX0C5nKZG8doon-_GzSwg?key=1bAsCVWOCHCjwZv9_TNMYQGi\" alt=\"\"\/><\/figure>\n\n\n\n<p>After it runs, open the <strong>\u201cprice tracking output\u201d<\/strong> tab\u2014you\u2019ll see all the vendor pricing data populated there.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXc0wNVmNOcxz2CvgyrUW_RyHjMC5mCy_KwOI9BFV9nBbs2ZoETqY7LwIFB_7zmbnDPqKs10V5O50TStriTwo3KLqOLfhurEpcnFZ7q3Oh_bsJtTJoqx0Fg9jADrkzoSEMfJHsX-GQ?key=1bAsCVWOCHCjwZv9_TNMYQGi\" alt=\"\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Step_6_Fetch_the_Cheapest_Vendors_List\"><\/span>Step 6: Fetch the Cheapest Vendors List<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>The Hotel Price API has already populated the <strong>\u201cprice tracking output\u201d<\/strong> tab. Now, let\u2019s pull the <strong>cheapest vendors list<\/strong> automatically.<\/p>\n\n\n\n<p>Head back to Apps Script, select <strong>getCheapestVendors<\/strong> from the dropdown, and run the script.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXfdAXH0EUGoPM8clpIhvTKMldLBmmGCXCS32pVLupimdNY3fOyUNloD0IFlYYwE7pUGF3QOo3e9fwFTuPOWIrcparB3loP_yqjwbf12AM6SV9O_-dPsGQJHjMl0ek_xQWN_coickQ?key=1bAsCVWOCHCjwZv9_TNMYQGi\" alt=\"\"\/><\/figure>\n\n\n\n<p>Once it\u2019s done, open the <strong>\u201ccheapest vendors list\u201d<\/strong> tab. You\u2019ll see the lowest-priced vendor for each hotel.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXdIeHt0eSBgZkCpHHuaOEUDtwsZAiYaDOZR1RdeM4xJXpi4F8TKQAAyA7jIlPXIPjDAVLj_7Uw3K5Qa4iyzsG3OQkFh7L5YybJgBS9Opy3lFWQxkijhTCNlQD3cCcs3GuO5QOKo?key=1bAsCVWOCHCjwZv9_TNMYQGi\" alt=\"\"\/><\/figure>\n\n\n\n<p>Want to get 2 or 3 cheapest vendors instead of just one?<br>No problem. You can adjust the number directly in the code. Enter 2 or 3, and you\u2019ll get a list of the top cheapest vendors based on your selection.<\/p>\n\n\n\n<p>To do this search in the code <strong>\u201cconst\u201d <\/strong>and edit the number as per the cheapest vendors you want for each hotel from 1-3.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXePcI4TT107xCzI6tkgUMxFcLfWOnsKqbwo1TKNKAntHCQw-f5rN8LFxsEpfgQpNAan1Rg3KNJwUpLqCEfOYd14XTt6IRvWHTpbACRIGcblPyhq9uVAhBaEB_D54ygDx-bh3IfNBQ?key=1bAsCVWOCHCjwZv9_TNMYQGi\" alt=\"\"\/><\/figure>\n\n\n\n<p>Check out the screenshot\u2014I\u2019ve set it to 3, and you can see how the list now shows the top 3 vendors per hotel.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/lh7-rt.googleusercontent.com\/docsz\/AD_4nXeAgqHJ7bJpeT2ZSKSOoVuSbd6PniYl7Oy2C9PCD2v2hnVL7vsEb1X8qJ7TtLuX4EQ_p9efs0qmoqh0gi7XXp-hicsGSyiNcEElgzdlTf5FVYKwLvgn5wdNYPyOPy1t1XUBA8-FtA?key=1bAsCVWOCHCjwZv9_TNMYQGi\" alt=\"\"\/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Get_Your_Blueprint_Automate_Everything_Fast\"><\/span>Get Your Blueprint &amp; Automate Everything Fast<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>No time for the full build?<br>Download the ready-made blueprint below and get started right away.<\/p>\n\n\n\n<p>\u27a1\ufe0f <a href=\"https:\/\/docs.google.com\/spreadsheets\/d\/1nMC4HcSOpHTtxvrnSxjRRrmtI22BdsI2VQt6PUN6T0c\/copy\" target=\"_blank\" rel=\"noopener\"><strong>Download the Blueprint<\/strong><\/a><\/p>\n\n\n\n<p>Here\u2019s all you need to do:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Add your hotel names and cities.<\/li>\n\n\n\n<li>Plug in your API key and sheet ID.<\/li>\n\n\n\n<li>Choose how many cheapest vendors you want to fetch.<\/li>\n<\/ul>\n\n\n\n<p>Then, run the scripts from Step 6 and your hotel price comparison will be ready\u2014quick and easy.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Wrapping_Up\"><\/span>Wrapping Up:<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Tracking the cheapest hotel prices across top vendors is a powerful move for <a href=\"https:\/\/www.makcorps.com\/blog\/marketing-for-travel-agencies\/\">marketing for travel agencies<\/a> aiming to stand out. Automating this process with Google Sheets and a trusted solution like <a href=\"https:\/\/www.makcorps.com\/\">Makcorps<\/a>, one of the <a href=\"https:\/\/www.makcorps.com\/blog\/hotel-api-provider-companies\/\">top hotel API providers<\/a>, helps you deliver unbeatable deals, drive more bookings, and strengthen your client offers with real-time pricing.<\/p>\n\n\n\n<p>Ready to give your agency the edge? Start building your price tracker now and level up your marketing.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Are you a travel agent, travel agency, or part of a travel business looking to score the best luxury hotel deals for your clients? You&#8217;re in the right place. And here\u2019s the good news\u2014you don\u2019t need to know how to code. This solution is simple. Follow the steps below to build it from scratch. Plus,&#8230;<\/p>\n","protected":false},"author":3,"featured_media":2797,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"footnotes":""},"categories":[49],"tags":[],"class_list":["post-2796","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials"],"_links":{"self":[{"href":"https:\/\/www.makcorps.com\/blog\/wp-json\/wp\/v2\/posts\/2796","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.makcorps.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.makcorps.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.makcorps.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.makcorps.com\/blog\/wp-json\/wp\/v2\/comments?post=2796"}],"version-history":[{"count":2,"href":"https:\/\/www.makcorps.com\/blog\/wp-json\/wp\/v2\/posts\/2796\/revisions"}],"predecessor-version":[{"id":2799,"href":"https:\/\/www.makcorps.com\/blog\/wp-json\/wp\/v2\/posts\/2796\/revisions\/2799"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.makcorps.com\/blog\/wp-json\/wp\/v2\/media\/2797"}],"wp:attachment":[{"href":"https:\/\/www.makcorps.com\/blog\/wp-json\/wp\/v2\/media?parent=2796"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.makcorps.com\/blog\/wp-json\/wp\/v2\/categories?post=2796"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.makcorps.com\/blog\/wp-json\/wp\/v2\/tags?post=2796"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}