Skip to main content

APIContext CLI

The APIContext CLI (apimetrics) lets you manage API monitors, projects, workflows, schedules, and more without opening a browser.

How the CLI works

The apimetrics binary is a fork of Restish. Instead of shipping a fixed set of resource subcommands, it loads the APIContext OpenAPI description from the configured server at startup and turns each API operation into its own CLI command at runtime — for example apimetrics list-monitors or apimetrics create-monitor.

Because of this, the available command set is not fixed: it varies by the configured endpoint, the API-description version, and your account tier. A small set of built-in commands (login, project selection, bulk sync) is always present; everything else is generated. See Generated commands for the full explanation and how to discover what is available to you.

Installation

The CLI is distributed only as a GitHub-release binary archive — there is no package-manager install.

  1. Open the APImetrics CLI releases page on GitHub.
  2. Download the archive matching your OS and architecture:
    • macOS: apimetrics-<version>-darwin-amd64 or -darwin-arm64
    • Linux: apimetrics-<version>-linux-amd64 or -linux-arm64
    • Windows: apimetrics-<version>-windows-amd64.zip
  3. Verify the download against the published checksums.txt.
  4. Extract the archive and move the apimetrics binary somewhere on your PATH.
# Example (macOS arm64) — adjust the version/arch to the release you downloaded
tar -xzf apimetrics-1.2.3-darwin-arm64.tar.gz
sudo mv apimetrics /usr/local/bin/
apimetrics --version

Authentication

Authentication uses OAuth 2.0. You do not set an API key in an environment variable, and there is no api configure command — sign in with login instead.

apimetrics login
  • The default interactive login uses the OAuth 2.0 authorization-code flow with PKCE (code_challenge_method=S256). It opens your browser to sign in.
  • For machine-to-machine use, the OAuth client-credentials flow is available.
  • Most commands auto-trigger login when they need credentials, so running login explicitly is rarely required.
  • apimetrics logout clears cached credentials and the active project.

See Authentication for OAuth details and named profiles (-p/--rsh-profile).

Configuration and endpoints

The CLI stores its state in a per-user config directory provided by the OS:

PlatformDefault config dir
macOS~/Library/Application Support/apimetrics
Linux~/.config/apimetrics

Override it with the APIMETRICS_CONFIG_DIR environment variable. The active project is recorded in state.json inside that directory. A separate cache directory holds the cached OpenAPI description and tokens; override it with APIMETRICS_CACHE_DIR.

The endpoint the CLI talks to (and where it discovers the OpenAPI description) is compiled into the binary. You can override the server for a single invocation with the global -s/--rsh-server flag.

Selecting a project

Most commands operate on an active project. Set it once and it is remembered:

# Choose interactively from the projects you can access
apimetrics project select

# Or set it directly by ID (no prompt)
apimetrics project select prj_abc123

# Show the active project
apimetrics project show

See Project for details.

Built-in commands

These commands are always available, regardless of the loaded API description:

CommandWhat it does
apimetrics login / logoutAuthenticate / clear credentials — see Authentication
apimetrics project select / showManage the active project — see Project
apimetrics bulk …Client-side bulk sync of resources — see Bulk

Output and global flags

Every command accepts the Restish --rsh-* global flags. The most important one to know:

# Get machine-readable JSON — note it is -o json, NOT --json
apimetrics list-monitors -o json

First monitor via the CLI

# 1. Authenticate (or let the next command trigger it for you)
apimetrics login

# 2. Select the project to work in
apimetrics project select

# 3. List your monitors (a generated command from the loaded API description)
apimetrics list-monitors -o json

# 4. Discover any other command and its flags
apimetrics --help
apimetrics list-monitors --help

Command reference

What's next?