Skip to content
CLI

Product Metrics CLI

productmetrics, de command line van Product Metrics: elke openbare API-handeling als commando, met JSON-uitvoer en exitcodes voor scripts en agents.

productmetrics is de command line van Product Metrics. Hij roept de openbare API (/api/public/v1) aan en bouwt zijn commando’s, flags en help op uit de eigen lijst met handelingen van de server, dus een nieuwe API-handeling werkt zonder nieuwe CLI-release.

Installeren en starten

Installeer hem vanuit npm (Node.js 22 of later):

pnpm add -g @productmetrics/cli
productmetrics --help
# of één keer, zonder te installeren
pnpm dlx @productmetrics/cli --help

De voorbeelden op deze pagina’s schrijven productmetrics. Standaard praat hij met https://prod-backend.productmetrics.io. productmetrics status toont welke API hij gebruikt.

Inloggen en een commando uitvoeren

# opent de browser; klik op Connect Product Metrics CLI
productmetrics login
# je account (e-mailadres) en properties
productmetrics whoami
# een handeling zoeken
productmetrics capabilities --search settings
productmetrics settings get --property-id <property_id> --json

Het laatste commando toont de instellingen als JSON:

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

Help

# elk commando en elke API-groep
productmetrics --help
# de commando's van één groep
productmetrics google-ads --help
# één commando: verzoek, scope, flags, voorbeelden
productmetrics settings update --help
# hoe een AI-agent productmetrics moet gebruiken
productmetrics help agents

productmetrics, productmetrics help en elke --help tonen dezelfde opbouw: gebruik, commando’s, flags met hun typen, standaardwaarden en toegestane waarden, en voorbeelden.

  • Voeg --json toe voor een machineleesbare beschrijving.
  • Helponderwerpen: productmetrics help agents, productmetrics help exit-codes, productmetrics help json.

Hoe commando’s aansluiten op de API

Elke API-handeling is een commando. De capability-ID geeft het commando: group.command, waarbij _ wordt omgezet in -.

Capability-IDCommando
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

Elke padparameter, queryparameter en elk bodyveld op het hoogste niveau is een flag in kebab-case:

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

productmetrics call <capability-id> voert dezelfde handeling uit op basis van de ID. Zie Commando’s.

Ingebouwde commando’s

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 de korte vorm van productmetrics help agents.

Algemene 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

Waar dingen worden opgeslagen

  • Inloggegevens: ${XDG_CONFIG_HOME:-~/.config}/product-metrics/credentials.json, één item per API-origin, modus 0600 in een map met 0700.
  • Cache van de commandolijst (één uur): ${XDG_CACHE_HOME:-~/.cache}/product-metrics/.

Gebruik het in plaats daarvan vanuit een AI-app

productmetrics mcp-config --client claude|chatgpt|cursor toont de URL van de MCP-server en hoe je die als connector toevoegt. Connectors loggen in via de browser en hebben geen token nodig. Zie MCP.

Volgende stappen