Skip to content

Instantly share code, notes, and snippets.

@JamesIves
Last active May 24, 2025 18:29
Show Gist options
  • Save JamesIves/ce8e9d5e83a17eeacdf46b5b7906382c to your computer and use it in GitHub Desktop.
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.
/**
* πŸŽ‰ 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();
@JamesIves
Copy link
Author

JamesIves commented May 24, 2025

Script response:

❯ node index.js
βœ… Bookable reservations:
πŸ“… Date: 2025-05-30
  ⏰ Time: 9:45 PM (ISO: 2025-05-30 21:45:00)
  ⏰ Time: 10:00 PM (ISO: 2025-05-30 22:00:00)
  ⏰ Time: 10:15 PM (ISO: 2025-05-30 22:15:00)
πŸ“… Date: 2025-05-31
  ⏰ Time: 9:30 PM (ISO: 2025-05-31 21:30:00)
  ⏰ Time: 9:45 PM (ISO: 2025-05-31 21:45:00)
  ⏰ Time: 10:00 PM (ISO: 2025-05-31 22:00:00)
  ⏰ Time: 10:15 PM (ISO: 2025-05-31 22:15:00)

Reservations that are marked as "is_requestable": true are removed from the response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment