Run and configure

Ways to start Calendarpit, command-line options, environment variables, and Docker setup.

Calendarpit serves the API, OAuth, and admin UI from one origin.

The commands below use the packaged distribution. You need no source checkout or build. See Installation for prerequisites and supported platforms.

Ways to run Calendarpit

Docker and Compose

docker run --rm \
  -p 127.0.0.1:4173:4173 \
  -v calendarpit-data:/data \
  ghcr.io/iktakahiro/calendarpit:latest

The container has these defaults:

  • It runs as a non-root user.
  • It sets CALENDARPIT_HOST=0.0.0.0 and CALENDARPIT_PORT=4173.
  • It stores the SQLite database at /data/calendarpit.sqlite.

The published host port stays on loopback. Add environment variables with -e before the image name. Add CLI flags after it:

docker run --rm -p 127.0.0.1:4173:4173 \
  ghcr.io/iktakahiro/calendarpit:latest serve --database :memory:

Related pages:

Installed CLI

Install with Homebrew or place a standalone executable on your PATH. Then run it from your project directory. See Installation for setup.

calendarpit serve --port 4173
calendarpit serve --port 0 --database :memory:

These are alternative startup commands:

  • Run one server per database file.
  • Port 0 lets the OS choose an available port.
  • Read the actual URLs in the startup output:
Calendarpit data: :memory:

Calendarpit v<version>
Data   :memory:
Admin  http://127.0.0.1:38425/
API    http://127.0.0.1:38425/calendar/v3
Health http://127.0.0.1:38425/__calendarpit/health

The packaged executable includes the server, the admin UI assets (including favicon.svg), and the Bun runtime. You need no separate Node.js or Bun installation. Stop the server with Ctrl+C.

Command-line options and environment variables

The CLI syntax is calendarpit [serve] [options]. The serve subcommand is optional.

The CLI prints an error to stderr and exits with code 1 on any of these:

  • an unknown command
  • an unknown flag
  • an invalid option value

Command-line flags take precedence over environment variables.

CLI optionEnvironment variableDefaultDescription
--host <host>CALENDARPIT_HOST127.0.0.1Bind address. Non-loopback addresses (0.0.0.0, ::) must be set explicitly.
-p, --port <n>CALENDARPIT_PORT4173Listen port (0–65535). Use 0 to let the OS choose a free port.
--database <path>CALENDARPIT_DATABASE.calendarpit/calendarpit.sqliteSQLite database file path, or :memory: for a disposable in-memory session. See Storage and restarts.
--config <path>CALENDARPIT_CONFIGBuilt-in fixturePath to a JSON startup fixture. See Fixtures.
--rate-limit <mode>CALENDARPIT_RATE_LIMIToffCalendar API rate-limit simulation: off, production, or error-test. See Calendar API rate limits.
-h, --help——Print help and exit.
-v, --version——Print the version and exit.

Option details:

  • --port 0: The assigned port appears in the startup output.
  • Port 4175: Avoid it if you also run the reference sample app.
  • --config: The file must exist and contain valid JSON. It seeds a new database or a :memory: session.

--config is silently ignored when Calendarpit opens an existing SQLite file.

Additional environment variables

Environment variableDefaultDescription
CALENDARPIT_WATCH_HOSTSLoopback onlyComma-separated extra hostnames allowed as events.watch and calendarList.watch webhook targets.

About CALENDARPIT_WATCH_HOSTS:

  • Example: host.docker.internal when running in Docker.
  • It is an environment variable only. There is no CLI flag.
  • See Watch notifications.

Calendar API rate limits

Calendarpit can answer Calendar API requests with the same quota errors Google returns, so an app can exercise that path locally. The default is off: requests are not limited.

Set the mode with --rate-limit or CALENDARPIT_RATE_LIMIT, or in Settings → Developer. Accepted values are off, production, and error-test. Any other value is rejected at startup. The mode is saved in the workspace and kept across SQLite restarts. On startup, an explicit flag or environment variable replaces the saved mode and is written back. When neither is set, Calendarpit keeps the saved mode. A snapshot without a mode, or with a saved value that is not one of these modes, loads as off.

Reset and fixture load keep the mode and clear the in-memory counters. Counters also clear when the mode changes, and they are not restored after a process restart.

Every /calendar/v3 request with a valid access token counts, including events, calendarList, freeBusy, and watch. A request without a valid access token (missing, unknown, expired, or revoked) is not counted and gets the usual 401. OAuth, /userinfo, and /__calendarpit do not count. quotaUser or x-goog-quota-user (1–40 characters) selects the per-user bucket and overrides the access token's user. Otherwise the token's user is used. primary resolves to the token user's primary calendar. A request that exceeds a limit is rejected and is not counted.

production roughly matches the Calendar API quotas Google publishes for Cloud projects created on or after 1 May 2026 (Usage limits). It is approximate, not identical to Google's behavior:

LimitproductionError
Per minute per user600 requests403 userRateLimitExceeded
Per minute per project10,000 requests429 rateLimitExceeded
Writes per minute per calendar60 requests403 rateLimitExceeded

Quotas use a sliding minute. The published 1,000,000 requests per day is a billing threshold, not a rejection, so production does not fail at that number. Google also says writes to one calendar in quick succession can be limited, without a published figure. production uses 60 writes per minute per calendar for that limit. This number is Calendarpit's estimate.

error-test uses very low limits, so the same 403 and 429 errors happen quickly. Use it to check retry and backoff handling:

Limiterror-testError
Per minute per user4 requests403 userRateLimitExceeded
Per minute per project12 requests429 rateLimitExceeded
Writes per minute per calendar2 requests403 rateLimitExceeded
Per day per user20 requests403 quotaExceeded

Google uses quotaExceeded for per-user Calendar usage limits. The daily limit always counts the access token's user, even when quotaUser is sent.

The daily limit is checked first, then per-calendar writes, then the per-user per-minute limit, then the per-project per-minute limit. Error bodies use Google's usageLimits domain (Handle API errors):

{
  "error": {
    "code": 403,
    "message": "User Rate Limit Exceeded",
    "errors": [
      {
        "domain": "usageLimits",
        "reason": "userRateLimitExceeded",
        "message": "User Rate Limit Exceeded"
      }
    ]
  }
}

rateLimitExceeded uses the message Rate Limit Exceeded. quotaExceeded uses Calendar usage limits exceeded.

Calendarpit adds Retry-After to these responses as a hint. Google's documentation does not specify this header, so clients should still use exponential backoff.

Loopback binding and working directory

Loopback by default. Calendarpit binds to 127.0.0.1 unless you pass --host or CALENDARPIT_HOST.

The admin UI and test control API have no authentication. Binding to 0.0.0.0 exposes them to other machines on your network.

Relative paths. Path resolution depends on how you run Calendarpit:

  • Homebrew and standalone executables: Paths in --database and --config (or their environment variables) resolve from the directory where you start Calendarpit. Run it from your project directory or use absolute paths.
  • Docker: Paths are inside the container. Mount host files before referencing them.

See Troubleshooting for common startup errors.

Admin UI

The admin UI is served at the root of the same origin as the API. The default URL is http://127.0.0.1:4173/. It shows the workspace, request history, and webhook deliveries, and lets you edit test data. See Admin UI.

On this page