Resy API examples & templates
(Part of: https://www.val.town/v/vtdocs.resyBot)
Given a valid booking token, this val attempts to make a reservation for the booking token's slot.
There is some retry logic as the API route (rarely) returns an internal server error.
Resy bot
This bot books restaurant reservations via Resy. Use it to snipe reservations at your favorite restaurant!
How to use it
Set up a scheduled val to call it like this:
Create valconst resyBotCron = async () => {
const bookingInfo = await api(@vtdocs.resyBot, {
slug: 'amaro-bar',
city: 'ldn',
day: '2023-07-05',
start: '19:00',
end: '21:00',
partySize: 2,
// Use https://www.val.town/settings/secrets for these!
email: @me.secrets.resyEmail,
password: @me.secrets.resyPassword,
});
// If the val doesn't error, it successfully made a booking!
// Send yourself an email like this:
await @std.email({ text: bookingInfo, subject: 'resy bot made a booking for you!' });
}
How it works
This val makes the same requests that your browser would make when you reserve a slot on Resy (that's why it needs your login info – to request an auth token).
When there isn't a matching slot, this val errors and nothing else happens.
When a booking is available, this val books it and returns a description of the booking so you can email it to yourself (Resy will also email you).
This val will then stop attempting bookings for you until you change one of the arguments you're passing (it concats the non-sensitive arguments and uses this as a key).
Credit to @rlesser and @alp for their existing Resy vals (search for resy
on here).
(Part of: https://www.val.town/v/vtdocs.resyBot)
Get a user's auth token and payment methods.
Get Favorites on Resy
This function fetches your favorite restaurants and venues, as specified in your Hit List.
Inputs
An object
containing:
authToken
- Your authentication token, normally generated from @rlesser.Resy_authenticate.
Returns
A Favorites
object, containing the ids of your favorite venues, defined in the type below.
See other Resy vals I've made.
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.
(Part of: https://www.val.town/v/vtdocs.resyBot)
Given a valid slot, this val generates the booking token that's required to place a reservation.
Authenticate with Resy
This function can be used to generate an authentication token for Resy, which can be used to view favorites, set notifies, or even make reservations.
Inputs
An AuthParams
object containing:
email
- The email address for your Resy account. Probably best to keep private.password
- The password for your Resy account. Definitely keep this private, and place it in a secret.
Returns
An AuthResponse
object containing:
id
- Your Resy account id.token
- Your Resy account token, used to authenticate you in subsequent API calls.
See other Resy vals I've made.
(Part of: https://www.val.town/v/vtdocs.resyBot)
Resy's current public API key.
(Part of: https://www.val.town/v/vtdocs.resyBot)