Last active
May 24, 2025 18:29
-
-
Save JamesIves/ce8e9d5e83a17eeacdf46b5b7906382c to your computer and use it in GitHub Desktop.
Node (v22) script that queries the Sevenrooms reservation booking system to inform you if a timeslot is available. Reservation times that are marked as is_requestable are removed from the payload as they cannot be booked online and require calling the restaurant.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* π The number of guests in the party. | |
*/ | |
const PARTY_SIZE = 4; | |
/** | |
* π The start date for the reservation search. | |
*/ | |
const START_DATE = "05-30-2025"; // Format: MM-DD-YYYY | |
/** | |
* π Number of days to check for availability. | |
* This is set to 2 days, meaning the search will include the start date and the next day. | |
*/ | |
const NUMBER_OF_DAYS = 2; // Number of days to check for availability | |
/** | |
* β° The desired time slot for the reservation. | |
*/ | |
const TIME_SLOT = "18:00"; | |
/** | |
* π½οΈ The venue ID for the restaurant, this can be found in the network payload when making a reservation on the restaurant website. | |
* This is a unique identifier for the restaurant in the SevenRooms system. | |
*/ | |
const VENUE_ID = "bourbonsteaknashville"; | |
/** | |
* π The API URL for checking availability. | |
*/ | |
const API_URL = `https://www.sevenrooms.com/api-yoa/availability/widget/range?venue=${VENUE_ID}&time_slot=${TIME_SLOT}&party_size=${PARTY_SIZE}&halo_size_interval=64&start_date=${START_DATE}&num_days=${NUMBER_OF_DAYS}&channel=SEVENROOMS_WIDGET&selected_lang_code=en`; | |
/** | |
* π Function to check reservations and log bookable slots. | |
*/ | |
async function checkReservations() { | |
try { | |
const response = await fetch(API_URL); | |
const data = await response.json(); | |
if (data.status === 200 && data.data && data.data.availability) { | |
const availability = data.data.availability; | |
console.log("β Bookable reservations:"); | |
for (const [date, slots] of Object.entries(availability)) { | |
const bookableSlots = slots.filter( | |
(slot) => | |
!slot.is_closed && | |
slot.times.some((time) => time.is_requestable !== true) // Filter out slots where all times are is_requestable: true | |
); | |
if (bookableSlots.length > 0) { | |
console.log(`π Date: ${date}`); | |
bookableSlots.forEach((slot) => { | |
slot.times | |
.filter((time) => time.is_requestable !== true) // Only include times that are not is_requestable: true | |
.forEach((time) => { | |
console.log(` β° Time: ${time.time} (ISO: ${time.time_iso})`); | |
}); | |
}); | |
} | |
} | |
} else { | |
console.log("β No availability found or invalid response."); | |
} | |
} catch (error) { | |
console.error("β οΈ Error fetching reservation data:", error); | |
} | |
} | |
checkReservations(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Script response:
Reservations that are marked as
"is_requestable": true
are removed from the response.