@amplitude/developer-cli

中文文档
0.7.0发布于 2026/11/05MITCommonJS构建来源已验证近 30 天下载 2386

amp CLI and developer artifacts for managing Amplitude platform primitives via the Developer API

原始使用文档
文档目录7 节
  1. Design tenets
  2. Install
  3. Authentication
  4. Signup
  5. Examples
  6. Project ingestion API key
  7. Smoke test

@amplitude/developer-cli

CLI and developer artifacts for the Amplitude Developer API.

amp manages Amplitude first-class platform primitives (projects, taxonomy, and feature flags) via the Developer API. Related CLIs:

  • ampli — instrumentation and typed SDK codegen
  • amplitude-wizard — onboarding and setup

Design tenets

These guide every change to the CLI (see AGENTS.md for the full version):

  1. Obvious by default. The best surface needs no explanation — discoverable help, consistent verbs, safe defaults, and errors that tell you what to do next.
  2. Code is marketing. This source is public; it is organized for clarity, with small single-purpose modules, familiar naming, and schema-validated inputs.
  3. Test the seams that matter. Pure logic is unit tested and the safety-critical paths (auth precedence, destructive-action confirmation, credential permissions) are covered explicitly.
  4. Two readers: humans and agents. Interactive output maximizes visibility and readability (tables, summaries); piped output is compact and lossless (minimal characters) so agents don't pay tokens for decoration.

Install

npm install -g @amplitude/developer-cli
amp help

Or run without installing:

npx @amplitude/developer-cli help

Authentication

Run amp auth login to authenticate via the OAuth device flow. Omit --profile and the CLI targets the active profile, or default when none is active. Picking a region stays explicit:

amp auth login --region us                       # device flow → "default" profile
amp auth status                                  # active credential, type, expiry
amp context

Profiles bind a credential to a region (its base_url), so an EU token can never be sent to prod. Name one explicitly when you want more than one:

amp auth login --profile eu --region eu          # activates the EU profile
amp auth use prod                                 # switch back (no re-auth)
amp auth list                                     # * marks the active profile
amp logout --profile eu                           # remove one
amp logout --all                                   # remove every profile

A bare amp auth login re-authenticates the active profile in place. Profiles are saved to ~/.amplitude/amp/credentials.json (0600).

Signup

Create an account with explicit inputs. By utilizing this command you agree to the Terms of Service and acknowledge the Privacy Policy applies.

amp auth signup \
  --email [email protected] \
  --full-name "Alex Morgan" \
  --region us \
  --accept-tos

--non-interactive skips browser interaction and waiting for authorization. --json controls output format; piped output is compact JSON.

--accept-tos passes the Terms of Service and Privacy Policy URLs alongside the signup request.

StatusMeaningExit
authorizedCredentials saved; profile active. Tokens stay local.0
requires_authBrowser authorization required. Challenge saved; use the returned polling command.0
needs_informationUnfamiliar requirements returned with their complete schema and supported flag mappings.2

Inspect status before issuing authenticated commands: exit 0 can mean authorization is still required. The continuation includes a readable command and an argument array:

amp auth login poll --profile default --json

See amp auth login poll --help for polling options.

Profiles follow login's rules: select --profile, otherwise the active profile, otherwise default. Signup requires an explicit --region. Successful signup at the same endpoint updates its identity. Changing its endpoint requires --force. Existing credentials and activation remain until authentication succeeds and the replacement is saved, including when signup returns a pending challenge.

Prefer a Personal Access Token? amp auth pat --with-token --region <us|eu> reads a PAT from stdin (or a masked prompt at a terminal) and saves it as a profile — --profile optional (defaults to default), same force-explicit create rule, same store. --with-token is required.

echo "$PAT" | amp auth pat --with-token --region us

For CI or a one-off shell, set a raw token — it overrides stored profiles:

export AMP_TOKEN=amp_...        # amp_… is treated as a PAT, anything else a bearer

AMP_PROFILE selects a stored profile by name; amp auth token prints the active access token to stdout (TOKEN=$(amp auth token)).

Examples

amp context
amp projects list
amp projects api-keys get --project <project_id>
amp events list --project <project_id> --limit 5
amp events create --project <project_id> --event-type my_event --display-name "My Event"
amp flags list --project <project_id> --limit 5
amp flags create --project <project_id> --key my-flag --name "My Flag"
amp flags get --project <project_id> --flag <flag_id>
amp flags archive --project <project_id> --flag <flag_id> --dry-run
amp guides list --project <project_id> --limit 10
amp surveys get --project <project_id> --survey <survey_id> --include-unpublished-changes
amp heatmaps click-map --project <project_id> --page-url https://example.com/pricing
amp zoning zone-metrics --project <project_id> --page-url https://example.com/pricing --metric click_rate_pageview

Project ingestion API key

Explore the project API-key commands with amp projects api-keys --help, or add --json for structured help.

Retrieve a project's primary ingestion API key using your authenticated profile or supplied token:

amp projects api-keys get
amp projects api-keys get --project 12345
amp projects api-keys get --project 12345 --json
AMPLITUDE_API_KEY="$(amp projects api-keys get --project 12345 --raw)"

At a terminal, the command shows the project name, ID, and full key. Piped output is compact API JSON with the key at data.api_key; --json forces JSON in any environment. --raw prints only the key followed by a newline and cannot be combined with --json.

Supply a positive integer project ID. --project-id and --project_id are also accepted. You can omit the selector when the organization has exactly one non-deleted project; otherwise use amp projects list to find its ID.

Retrieval requires projects:read and permission to view the project's API key. The command retrieves the designated project key without creating, rotating, or saving it. Failures leave stdout empty and report the error on stderr.

Smoke test

With a credential available (amp auth login, or AMP_TOKEN set):

pnpm smoke

See docs/cli.md for the full smoke checklist and PAT scope notes.

版本与发布记录

@amplitude/developer-cli 共发布 8 个版本,首次发布于 2026/06/27;过去 12 个月发布了 8 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.7.0latest2026/11/052 天前
0.6.02026/10/318 天前
0.5.02026/10/1721 天前
0.4.02026/10/021 个月前
0.3.12026/09/231 个月前
0.3.02026/09/161 个月前

其他发布通道:beta → 0.2.0。

关于 @amplitude/developer-cli 的常见问题

@amplitude/developer-cli 是什么?

amp CLI and developer artifacts for managing Amplitude platform primitives via the Developer API

如何安装 @amplitude/developer-cli?

在项目目录运行 npm install @amplitude/developer-cli,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 amp,可以用 npx amp 直接运行。

@amplitude/developer-cli 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/amplitude__developer-cli 是否存在。

@amplitude/developer-cli 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@amplitude/developer-cli 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js ^22.13.0 || >=23.5.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@amplitude/developer-cli 可以商用吗?

@amplitude/developer-cli 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@amplitude/developer-cli 的下载量有多少?

根据 npm 官方下载统计,@amplitude/developer-cli 在 2026/10/06 – 2026/11/04 这 30 天内被下载 2,386 次,日均约 80 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@amplitude/developer-cli 还在维护吗?

最新版本 0.7.0 发布于 2026/11/05(2 天前);至今共发布 8 个版本,其中过去 12 个月发布了 8 个;首次发布于 2026/06/27。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。