Check Château de Versailles ticket availability
Automatically check Château de Versailles ticket availability on billetterie.chateauversailles.fr. For one visit date on the official Château de Versailles ticket shop, list the entry time slots of one ticket type (Passport by default) with the places left in each slot and every rate the slot offers (full, reduced, youth, child, free) with its price in euros. Also lists every ticket type sold that day, so a caller can pick another one by name or id. A day with no entry tickets on sale (for example a Monday, when the palace is closed) returns no slots and a reason. A date in the past or not yet on sale fails with an error. visitors only sets enoughForVisitors on each slot; it reserves nothing.
Input
date requiredVisit date, YYYY-MM-DD.
language optionalLanguage of the names and rate labels the site returns.
Default: "en"visitors optionalNumber of visitors, used only to set enoughForVisitors on each slot.
Default: 1ticketType optionalTicket type: its id or its name, or part of the name, as listed in ticketTypes (552471 is the Passport ticket). A name that matches several types fails with the list of names.
Default: "552471"Output
date requiredslots requiredticketTypes requiredreason optionalticketType optionalFAQ
Open the Château de Versailles payment page
Take the cart filled with add_to_cart and identified with fill_booking_details on the official Château de Versailles ticket shop to its payment page, and stop there. It never enters payment details and never pays: with dryRun true (the default) it opens the payment form and returns whether it was reached, the total in euros, the payment provider and the cart lines; dryRun false is refused. It ticks the shop's sales conditions box, which the shop asks for before payment. A cart with a total of 0 is confirmed by the shop without payment, so the script stops before that step and says so. An empty cart, or a browser that did not go through fill_booking_details, fails with an error that names the script to run first.
Fill Château de Versailles booking details
Give the visitor details for the cart already filled with add_to_cart on the official Château de Versailles ticket shop, as a guest (no account is created). The shop checks every email address with a 6-digit code it sends to that address, so this runs in two passes on the same browser: first with the email only, which makes the shop send the code and returns status email_code_sent; then again with the same email, the code from that email and the visitor's first and last name, which fills the guest form and returns status details_filled. Returns the fields the shop requires and whether each one is filled. It stops before payment: run complete_booking next. A wrong or expired code fails with an error that says to run the first pass again. An empty cart fails with an error that says to run add_to_cart first.
Add Château de Versailles tickets to the cart
Put tickets for one date, one entry slot and one ticket type (Passport by default) in the cart of the official Château de Versailles ticket shop, with a quantity per rate (full, reduced, youth, child, free). Take the slot and the rates from check_availability: a slot is its slotId or its time (HH:MM), a rate is its priceId or its label. Returns the cart lines (date, slot time, entrance, ticket, rate, quantity, unit price, line total), the cart total in euros and how many seconds the site still holds the cart. The cart lives in this browser: tickets already in it stay there and are listed too. The site holds a cart for about 35 minutes. Nothing is paid or booked. A quantity above what the slot allows, an unknown slot or an unknown rate fails with an error that names the valid ones.
