Scripting recipes

A nightly price check, bookings to CSV, a cron job and a CI step, written against the JSON output.

Rules for scripts

  • Sign in with HOSTEMI_TOKEN, not login.
  • Use --json and read the exit code; never parse the tables.
  • Reads never ask. A change needs --yes, and exit 4 means it waits for the host: send the approvalUrl to a person.
  • On exit 1 read error.code; a rate limit says when to try again in error.message.

Bookings to CSV

The report commands print CSV on stdout:

hostemi reports bookings --from 2026-01-01 --to 2026-12-31 > bookings-2026.csv
hostemi reports export --from 2026-01-01 --to 2026-12-31 > revenue-2026.csv

Or shape your own from the JSON (the answer of GET /public/v1/reservations):

hostemi bookings list --from 2026-12-01 --to 2026-12-31 --json \
  | jq -r '.reservations[] | [.arrivalDate, .departureDate, .guest.firstName, .guest.lastName, .status, .totalAmountMinor, .currency] | @csv'

A nightly price check

Pace per listing for the next weeks (nights for sale, sold, free, sold in the last 7 days), saved once a night for comparison:

price-check.sh
#!/bin/sh
set -eu
day=$(date +%F)
hostemi pricing pace --json > "$HOME/hostemi-pace/$day.json"
# one listing in detail: weeks, last year at the same point, booking curve, the lowest price
hostemi pricing signals <listing id> --json > "$HOME/hostemi-pace/$day-lake-house.json"

The signals are numbers only; deciding a price stays with you (or your AI, through a preview).

A cron job

crontab -e
# every night at 05:10, with the key from a file only you can read
10 5 * * * HOSTEMI_TOKEN=$(cat $HOME/.hostemi-key) /usr/local/bin/hostemi pricing pace --json > $HOME/hostemi-pace/latest.json 2>> $HOME/hostemi-pace/errors.log

Use the full path of hostemi (which hostemi): cron has a short PATH.

Close nights from a script

if hostemi block <listing id> 2026-12-24:2026-12-26 --reason "family" --yes --json > out.json; then
  echo "blocked"
else
  code=$?
  if [ "$code" -eq 4 ]; then
    echo "waits for the host: $(jq -r .approvalUrl out.json)"
  else
    echo "failed ($code): $(jq -r .error.message out.json)"
  fi
fi

In the default setting ("Ask before changes") every change from a key waits for the host, so exit 4 is the normal outcome there.

Any API route

hostemi api GET units --json
hostemi api GET reservations --query from=2026-12-01,to=2026-12-31 --json
hostemi api POST /public/v1/blocks --data '{"unitId":"…","firstNight":"2026-12-24","lastNight":"2026-12-26"}' --dry-run

hostemi api uses the same sign-in and the same approval rules: GET reads, anything else asks first (or --yes).

Something missing from this page? Write to [email protected], or use the form on the Help page.