← All posts

Hostex API - Keeping longer stays possible when bookings change

How a Python service keeps Booking.com check-in restrictions aligned with the openings in our reservation calendar.

A cancellation can turn a short opening into a longer stretch of free nights. The room is available again, but Booking.com can still be carrying the check-in restrictions that applied before the cancellation. We built a checker that revisits those restrictions whenever the reservation calendar changes.

One set of rules for the whole opening

The checker looks at the free nights between reservations as a single span. The length of that span determines which rate plans can accept check-ins. For longer openings, the rule also considers how far away each arrival date is, using Japan time.

Free nights between reservationsPlans that allow check-in
1–2 nights1-, 2-, 3-, 4- and 5-night plans
3–4 nights2-, 3-, 4- and 5-night plans
5–6 nights3-, 4- and 5-night plans
7 nights or more, up to 90 days before arrival4-night, 5-night and Long Stay plans
7 nights or more, over 90 days before arrival5-night and Long Stay plans

Each Booking.com plan still enforces its own minimum stay. A one-night opening can allow check-in on several plans, but a five-night plan still requires five bookable nights. We manage Long Stay check-ins ourselves in gaps of six nights or fewer.

How a reservation change reaches the calendar

When a reservation is created, changed or cancelled, Hostex sends a webhook to a receiver on our EC2 server. The receiver records the event in SQLite. A Python worker reads the receipt, looks up the current reservation through the Hostex Open API, and rechecks the room around the affected dates.

The worker runs continuously under systemd. Its own reconciliation loop checks future dates every 30 minutes and scans a wider part of the calendar at the change of day in Japan. This catches late or missed events and brings newly available dates under the same rules.

Verify the update in Hostex

The worker compares the calculated check-in settings with the per-listing calendars and sends updates only for dates that need a change. Hostex processes those updates asynchronously, so the worker reads the calendar back to confirm the new settings. Its writes are limited to check-in restrictions. Nightly prices, room inventory and minimum stays stay as configured.

The service covers five Kaku rooms and Saku House. We checked the future calendar against the rules before leaving the worker to handle new booking events. When a cancellation opens a longer stay, the relevant rate plans can become available for check-in again.