Get a Venue's Calendar on Resy

This function fetches the calendar for a given venue on Resy, which gives information on which days the venue is available, sold-out, or closed.

Inputs

An object containing:

  • venue_id - The Resy venue id, either fetched from the website's network data or from @rlesser_getFavorites (Todo: add venue id from url function).
  • num_seats - The number of seats you are checking for availability for. Use 2 as a default if you just want to know when the restaurant is closed.

Returns

A VenueCalendar object, containing:

  • last_calendar_day - A string representing the last day the restaurant has made their calendar available for (normally a few weeks out from today).
  • scheduled - An object containing a list of dates and restaurant statuses. See type below.

See other Resy vals I've made.

Readme
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { fetch } from "https://esm.town/v/std/fetch";
type VenueCalendar = {
last_calendar_day: string;
scheduled: {
date: string;
inventory: {
reservation: "sold-out" | "available" | "closed";
};
}[];
};
export const Resy_getVenueCalendar = async (params: {
venue_id: number;
num_seats: number;
}): Promise<VenueCalendar> => {
const url = "https://api.resy.com";
const query = new URLSearchParams({
venue_id: String(params.venue_id),
num_seats: String(params.num_seats),
start_date: (new Date()).toISOString().slice(0, 10),
end_date: new Date(new Date().setFullYear(new Date().getFullYear() + 1))
.toISOString().slice(0, 10),
});
const response = await fetch(`${url}/4/venue/calendar?${query.toString()}`, {
headers: {
accept: "application/json, text/plain, */*",
"accept-encoding": "gzip, deflate, br",
"accept-language": "en-US,en;q=0.9",
authorization: 'ResyAPI api_key="VbWk7s3L4KiK5fzlO7JD3Q5EYolJI7n5"',
"x-origin": "https://resy.com",
origin: "https://resy.com/",
dnt: "1",
referer: "https://resy.com/",
"content-type": "application/json",
"content-type": "application/x-www-form-urlencoded",
},
});
const data = await response.json();
return data;
};
👆 This is a val. Vals are TypeScript snippets of code, written in the browser and run on our servers. Create scheduled functions, email yourself, and persist small pieces of data — all from the browser.