Skip to content
CLI

Product Metrics CLI

productmetrics, the Product Metrics command line: every public API operation as a command, with JSON output and exit codes for scripts and agents.

productmetrics is the Product Metrics command line. It calls the public API (/api/public/v1) and builds its commands, flags and help from the server’s own list of operations, so a new API operation works without a new CLI release.

By the end of this page you will:

  1. Run productmetrics and read its help
  2. Sign in in a browser
  3. Run your first command and read it as JSON

Install and run

Install it from npm (Node.js 22 or later):

npm install -g @productmetrics/cli
productmetrics --help
# or once, without installing
npx @productmetrics/cli --help

The examples on these pages write productmetrics. By default it talks to https://prod-backend.productmetrics.io. productmetrics status shows which API it uses.

Help

# every command and API group
productmetrics --help
# the commands of one group
productmetrics google-ads --help
# one command: request, scope, flags, examples
productmetrics settings update --help
# how an AI agent should use productmetrics
productmetrics help agents

productmetrics, productmetrics help and every --help print the same layout: usage, commands, flags with their types, defaults and allowed values, and examples.

  • Add --json for a machine-readable description.
  • Help topics: productmetrics help agents, productmetrics help exit-codes, productmetrics help json.

Quickstart

# opens the browser; click Connect Product Metrics CLI
productmetrics login
# your account (email) and properties
productmetrics whoami
# find an operation
productmetrics capabilities --search settings
productmetrics settings get --property-id <property_id> --json

The last command prints the settings as JSON:

{
  "ok": true,
  "data": {
    "labelizer_settings": { … },
    "settings_version": 4,
    …
  },
  "request_id": "…"
}

How commands map to the API

Every API operation is a command. Its capability id gives the command: group.command, with _ turned into -.

Capability idCommand
google_ads.list_accountsproductmetrics google-ads list-accounts
settings.recommend_min_clicksproductmetrics settings recommend-min-clicks
merchant_center.apply_auto_setupproductmetrics merchant-center apply-auto-setup

Each path parameter, query parameter and top-level body field is a kebab-case flag:

FieldFlag
propertyId--property-id
feed_scope--feed-scope
labelizer_settings--labelizer-settings '{…}'

productmetrics call <capability-id> runs the same operation by its id. See Commands.

Built-in commands

CommandWhat it does
productmetrics loginSign in to Product Metrics in a browser
productmetrics logoutSign out of this API origin
productmetrics statusShow which API productmetrics uses and whether you are signed in
productmetrics whoamiCheck the sign-in against the API: your account and properties
productmetrics capabilitiesList every API operation
productmetrics callRun an operation by its id
productmetrics feedbackTell the Product Metrics team what worked or did not
productmetrics mcp-configShow how to add Product Metrics to Claude, ChatGPT or Cursor
productmetrics helpHelp for a command or topic

productmetrics agents is short for productmetrics help agents.

Global flags

FlagWhat it does
--api <origin>The Product Metrics API to use (default https://prod-backend.productmetrics.io, env PM_API_URL)
--jsonPrint one JSON document on stdout ({ok, data, request_id} or {ok: false, error, exit_code})
--select <path>Print only part of the JSON document, e.g. .data.properties[].property_id (implies --json)
-q, --quietPrint only the primary id of the result, or nothing
--verboseLog requests, timings and request ids to stderr (never tokens or bodies)
--no-inputNever prompt or open a browser (on by default without a terminal; env PM_AGENT=1, CI)
--no-colorNo colours (env NO_COLOR)
--refreshFetch the server’s command list again (it is cached for an hour)
-h, --helpShow help; with --json, a machine-readable description
-v, --versionShow the version

Where things are stored

  • Sign-in: ${XDG_CONFIG_HOME:-~/.config}/product-metrics/credentials.json, one entry per API origin, mode 0600 in a 0700 directory.
  • Command list cache (one hour): ${XDG_CACHE_HOME:-~/.cache}/product-metrics/.

Use it from an AI app instead

productmetrics mcp-config --client claude|chatgpt|cursor prints the MCP server URL and how to add it as a connector. Connectors sign in in the browser and need no token. See MCP.

Where next