Your own booking engine

Price, check and book from the hotel website with the property key: the same data as Hotelgest’s engine.

6 min read

For a hotel website that sells rooms with its own engine instead of Hotelgest’s. The prices, packs and promo codes come from the same service Hotelgest’s booking engine reads, so what your website shows is what the hotel set in the PMS; what changes is the credential, the key the hotel issues. Websites that called the old API (api.hotelgest.com/v1/price/room, /v1/property/…) move here.

From your server, never from the browser

The key opens the property’s data, so it lives on your server and your website talks to your server. The API refuses calls made from a browser on a domain that is not Hotelgest’s, on purpose: a key in front-end code is a key anyone can copy.

The key, and what to grant it

The hotel issues it in the PMS, under Settings → API keys, and chooses the endpoints it may call. The booking engine ones are only reachable when they are granted on purpose — a key issued without a selection does not reach them. Every key issued now answers encrypted: read the encryption guide before the first call.

EndpointWhat your engine uses it for
GET /api/rooms/{pcode}/typesRoom types and their rooms: names, capacity and the ids everything else takes.
GET /api/properties/{pcode}/settings/custom-policiesThe names of the cancellation policies a rate refers to.
GET /api/direct-booking/{pcode}/pricesThe price of each rate for the stay, night by night, with the restrictions that decide whether it can be sold.
GET /api/direct-booking/{pcode}/packsThe packs on sale.
GET /api/direct-booking/{pcode}/promo-codesWhether the code a guest typed exists, and what it takes off.
GET /api/v2/rooms/{pcode}/availabilityWhich rooms are free, to pick the one you book.
POST /api/v5/bookings/{pcode}The booking.

From a search to a booking

  1. 1Price the stayAsk for prices with the arrival and the departure. The answer is keyed by room type; under rate each one lists its rates (room type, board, policy, guests) with the price of each night in priceList. Leave out the rates with motor_excl = 1, the closed ones (_closed = 1), the ones whose _minstay or _maxstay the stay does not meet (a _maxstay of 0 means no limit) and the ones where the stay starts on a date of closedarrival or ends on one of closeddeparture. The room type price leaves none of those out: recompute it from the rates you keep.
  2. 2Apply the promo code, if anyCheck it: an empty list means it does not exist. When it does, check dfrom and dto against the stay and apply value as dtype says: 0 an amount off each night, -1 a percentage off the stay, -2 an amount off the stay.
  3. 3Pick the roomAvailability lists the free rooms of each type. The prices answer also says how many are free, but the booking needs one in particular.
  4. 4BookSend the room, the rate and the night prices you showed. The booking checks availability again and is rejected whole if the room was taken meanwhile; send an Idempotency-Key so a retry never books twice.
In the booking (`rooms[]`)Where it comes from
rtcode, boardId, politicIdThe rate you sold: its rtcode, board and policy.
rcodeA free room of that type, from availability.
adults, children, babiesThe guests; their total is the rate’s occupancy.
paxThe total of guests, as text (kept for compatibility). Required.
ancillaryThe price of each night, from the rate’s priceList, keyed by date.
ancillaryWithDiscountWith a promo code, the night prices after the discount: the booking total is their sum.
promoCodeThe code checked above, as type-value-id-code, where type is fbn for dtype 0, pbn for -1 and ta for -2.
promoCodeManual{ "isActive": false } unless reception applies a manual discount. Required.

Prices are a snapshot

They can change between the search and the booking — the hotel edits a rate, a channel sells the last room. Price again when the guest confirms if the search is old, and treat a rejected booking as “search again”, not as an error to show.