# @apimatic/cli 中文文档

规范地址：https://npmcn.com/package/%40apimatic/cli/

版本：2\.2\.0
npm 元数据更新时间：2026-11-05T05:26:29.318Z
中文译文更新时间：2026-11-06T13:41:23.268Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40apimatic/cli
原文对照：https://npmcn.com/package/%40apimatic/cli/?lang=original
项目主页：https://docs.apimatic.io/v4/quickstart/
源码仓库：https://github.com/apimatic/apimatic-cli

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：1.8 MB，692 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- Node.js 要求：\>=22\.14\.0
- 运行依赖：50 个
- 首次发布：2021-11-26T11:01:17.451Z
- 最新版本发布：2026-11-05T05:26:28.896Z
- 近 30 天下载量：3081（2026-10-06 至 2026-11-04，npm 官方下载统计）
- 已发布版本数：80（近 12 个月 39 个）

## 中文简介

APIMatic官方CLI 互联网档案馆的存檔,存档日期2013-12-21.

## 安装

```sh
npm install @apimatic/cli
```

也可以使用：`pnpm add @apimatic/cli`、`yarn add @apimatic/cli`、`bun add @apimatic/cli`

## README

# @apimatic/cli (英语)

APIMatic官方CLI 互联网档案馆的存檔,存档日期2013-12-21.

[![oclif](https://img.shields.io/badge/cli-oclif-brightgreen.svg)](https://oclif.io/) [![Version](https://img.shields.io/npm/v/@apimatic/cli.svg)](https://npmjs.org/package/@apimatic/cli) [![Downloads/week](https://img.shields.io/npm/dw/@apimatic/cli.svg)](https://npmjs.org/package/@apimatic/cli) [![License](https://img.shields.io/npm/l/@apimatic/cli.svg)](https://github.com/apimatic/apimatic-cli/blob/main/LICENSE)

# 所需资源

节点js22.14或更新,每个命令. 安装方式 `@2`:在一个更古老的节点上,npm跳过一个 `latest` 释放 `engines` 失败而一无所有 `@apimatic/cli` 默地安装 CLI v1. 与 `@2` npm只发出警告,所以安装成功,然后CLI拒绝运行,命名为 它找到的版本 .

基特2.38 或更新您的 `PATH`,用于 `sdk generate` 财务报告和审定财务报表 `sdk publish` 更改为 a 在再生过程中生成了SDK. 没有它,命令仍然产生, 警告你 定制不会持续下去.

# 开始

要使用一步步向导开始APIMatic的CLI, 请运行以下命令 :

```sh-session
$ apimatic quickstart
```

# 使用量

```sh-session
$ npm install -g @apimatic/cli@2
$ apimatic COMMAND
running command...
$ apimatic --help [COMMAND]
USAGE
  $ apimatic COMMAND
...
```

# 图标

-   [`apimatic api transform`](https://npmcn.com/package/%40apimatic/cli/#readme-apimatic-api-transform)
-   [`apimatic api validate`](https://npmcn.com/package/%40apimatic/cli/#readme-apimatic-api-validate)
-   [`apimatic auth login`](https://npmcn.com/package/%40apimatic/cli/#readme-apimatic-auth-login)
-   [`apimatic auth logout`](https://npmcn.com/package/%40apimatic/cli/#readme-apimatic-auth-logout)
-   [`apimatic auth status`](https://npmcn.com/package/%40apimatic/cli/#readme-apimatic-auth-status)
-   [`apimatic autocomplete [SHELL]`](https://npmcn.com/package/%40apimatic/cli/#readme-apimatic-autocomplete-shell)
-   [`apimatic help [COMMAND]`](https://npmcn.com/package/%40apimatic/cli/#readme-apimatic-help-command)
-   [`apimatic plugin generate`](https://npmcn.com/package/%40apimatic/cli/#readme-apimatic-plugin-generate)
-   [`apimatic plugin publish`](https://npmcn.com/package/%40apimatic/cli/#readme-apimatic-plugin-publish)
-   [`apimatic portal generate`](https://npmcn.com/package/%40apimatic/cli/#readme-apimatic-portal-generate)
-   [`apimatic portal serve`](https://npmcn.com/package/%40apimatic/cli/#readme-apimatic-portal-serve)
-   [`apimatic publishing profile list`](https://npmcn.com/package/%40apimatic/cli/#readme-apimatic-publishing-profile-list)
-   [`apimatic quickstart`](https://npmcn.com/package/%40apimatic/cli/#readme-apimatic-quickstart)
-   [`apimatic sdk generate`](https://npmcn.com/package/%40apimatic/cli/#readme-apimatic-sdk-generate)
-   [`apimatic sdk publish`](https://npmcn.com/package/%40apimatic/cli/#readme-apimatic-sdk-publish)

## `apimatic api transform`

不同格式之间的 API 规格转换

```
USAGE
  $ apimatic api transform --format
    apimatic|wadl2009|wsdl|swagger10|swagger20|swaggeryaml|oas3|openapi3yaml|apiblueprint|raml|raml10|postman10|postman2
    0|graphqlschema [--file <value>] [--url <value>] [-d <value>] [-f] [-k <value>]

FLAGS
  -d, --destination=<value>  [default: ./] Directory to save the transformed file to
  -f, --force                overwrite changes without asking for user consent.
  -k, --auth-key=<value>     override current authentication state with an authentication key.
      --file=<value>         Path to the API specification file to transform
      --format=<option>      (required) Specification format to transform API specification into
                             <options: apimatic|wadl2009|wsdl|swagger10|swagger20|swaggeryaml|oas3|openapi3yaml|apibluep
                             rint|raml|raml10|postman10|postman20|graphqlschema>
      --url=<value>          URL to the API specification file to transform (publicly accessible)

DESCRIPTION
  Transform API specifications between different formats

  Transform API specifications from one format to another.
  Supports multiple formats including OpenAPI/Swagger, RAML, WSDL, and Postman Collections.

EXAMPLES
  apimatic api transform --format=openapi3yaml --file=./specs/sample.json --destination=./

  apimatic api transform --format=raml --url="https://petstore.swagger.io/v2/swagger.json" --destination=./
```

_参见代码 : [src/ 命令/ api/ transform.ts](https://github.com/apimatic/apimatic-cli/blob/v2.2.0/src/commands/api/transform.ts)_

## `apimatic api validate`

校验合成和语义正确性的 API 规格

```
USAGE
  $ apimatic api validate [--file <value> | --url <value> | -i <value>] [-k <value>]

FLAGS
  -i, --input=<value>     [default: ./] path to the parent directory containing the 'src' directory, which includes API
                          specifications and configuration files.
  -k, --auth-key=<value>  override current authentication state with an authentication key.
      --file=<value>      Path to the API specification file to validate
      --url=<value>       URL to the API specification file to validate (publicly accessible)

DESCRIPTION
  Validate API specification for syntactic and semantic correctness

  Validate the API specification in your 'src/spec' directory, or the one --file or --url points to, to ensure it
  adheres to syntactic and semantic standards.

EXAMPLES
  apimatic api validate

  apimatic api validate --input=./

  apimatic api validate --file=./specs/sample.json

  apimatic api validate --url="https://petstore.swagger.io/v2/swagger.json"
```

_参见代码 : [src/ 命令/ api/ validate.ts](https://github.com/apimatic/apimatic-cli/blob/v2.2.0/src/commands/api/validate.ts)_

## `apimatic auth login`

登录到您的 APIMatic 账户

```
USAGE
  $ apimatic auth login [-k <value>]

FLAGS
  -k, --auth-key=<value>  Sets authentication key for all commands.

DESCRIPTION
  Login to your APIMatic account

  Login using your APIMatic credentials or an API Key

EXAMPLES
  apimatic auth login

  apimatic auth login --auth-key={api-key}
```

_参见代码 : [src/commands/auth/login.ts (中文(简体) )](https://github.com/apimatic/apimatic-cli/blob/v2.2.0/src/commands/auth/login.ts)_

## `apimatic auth logout`

清除本地登录证书.

```
USAGE
  $ apimatic auth logout

DESCRIPTION
  Clears the local login credentials.

  Clears the local login credentials. This will also clear any cached credentials from the CLI.

EXAMPLES
  apimatic auth logout
```

_参见代码 : [src/commands/auth/logout.ts (中文(简体) )](https://github.com/apimatic/apimatic-cli/blob/v2.2.0/src/commands/auth/logout.ts)_

## `apimatic auth status`

查看当前登录的用户 .

```
USAGE
  $ apimatic auth status

DESCRIPTION
  View the currently logged in user.

EXAMPLES
  apimatic auth status
```

_参见代码 : [src/命令/自动/状态.ts](https://github.com/apimatic/apimatic-cli/blob/v2.2.0/src/commands/auth/status.ts)_

## `apimatic autocomplete [SHELL]`

显示自动完成安装指令 .

```
USAGE
  $ apimatic autocomplete [SHELL] [-r]

ARGUMENTS
  [SHELL]  (zsh|bash|powershell) Shell type

FLAGS
  -r, --refresh-cache  Refresh cache (ignores displaying instructions)

DESCRIPTION
  Display autocomplete installation instructions.

EXAMPLES
  $ apimatic autocomplete

  $ apimatic autocomplete bash

  $ apimatic autocomplete zsh

  $ apimatic autocomplete powershell

  $ apimatic autocomplete --refresh-cache
```

_参见代码 : [@oclif/ plugin- auto 完成](https://github.com/oclif/plugin-autocomplete/blob/v3.2.47/src/commands/autocomplete/index.ts)_

## `apimatic help [COMMAND]`

显示动画的帮助 .

```
USAGE
  $ apimatic help [COMMAND...] [-n]

ARGUMENTS
  [COMMAND...]  Command to show help for.

FLAGS
  -n, --nested-commands  Include all nested commands in the output.

DESCRIPTION
  Display help for apimatic.
```

_参见代码 : [@oclif/plugin-帮助](https://github.com/oclif/plugin-help/blob/6.2.46/src/commands/help.ts)_

## `apimatic plugin generate`

为您的 SDK 创建上下文插件 .

```
USAGE
  $ apimatic plugin generate [-i <value>] [-d <value>] [-f] [-k <value>]

FLAGS
  -d, --destination=<value>  [default: <input>/plugin] path where the plugin will be generated.
  -f, --force                overwrite changes without asking for user consent.
  -i, --input=<value>        [default: ./] path to the parent directory containing the 'src' directory, which includes
                             API specifications and configuration files.
  -k, --auth-key=<value>     override current authentication state with an authentication key.

DESCRIPTION
  Generate a context plugin for your SDKs.

  Generate a context plugin that teaches an AI coding assistant how to use your SDKs. Requires an input directory
  containing a `src` directory with your API specification — `apimatic.json` is created if it is not there. It asks for
  the plugin's name on the first run, and for its languages only when `apimatic.json` records none (`sdk publish`
  records them). Later runs read both from `apimatic.json` without asking.

EXAMPLES
  apimatic plugin generate

  apimatic plugin generate --input="./" --destination="./plugin"
```

_参见代码 : [src/命令/插件/基因](https://github.com/apimatic/apimatic-cli/blob/v2.2.0/src/commands/plugin/generate.ts)_

## `apimatic plugin publish`

打印 git 命令, 将您的上下文插件发布到 GitHub .

```
USAGE
  $ apimatic plugin publish [-i <value>] [-d <value>]

FLAGS
  -d, --destination=<value>  [default: <input>/plugin] path where the plugin was generated.
  -i, --input=<value>        [default: ./] path to the parent directory containing the 'src' directory, which includes
                             API specifications and configuration files.

DESCRIPTION
  Print the git commands for publishing your context plugin to GitHub.

  Print the commands that publish a generated context plugin to a GitHub repository. The commands are printed for you to
  run — this command never touches your repository.

EXAMPLES
  apimatic plugin publish

  apimatic plugin publish --input="./" --destination="./plugin"
```

_参见代码 : [src/命令/插件/publish.ts](https://github.com/apimatic/apimatic-cli/blob/v2.2.0/src/commands/plugin/publish.ts)_

## `apimatic portal generate`

生成一个静态 API 文档门户.

```
USAGE
  $ apimatic portal generate [--zip] [-i <value>] [-d <value>] [-f] [-k <value>]

FLAGS
  -d, --destination=<value>  [default: <input>/portal] path where the portal will be generated.
  -f, --force                overwrite changes without asking for user consent.
  -i, --input=<value>        [default: ./] path to the parent directory containing the 'src' directory, which includes
                             API specifications and configuration files.
  -k, --auth-key=<value>     override current authentication state with an authentication key.
      --zip                  write the generated portal as a .zip archive.

DESCRIPTION
  Generate a static API Documentation Portal.

  Builds a documentation portal from the OpenAPI documents and Markdown pages in your 'src' directory.

  Each OpenAPI document at the top of 'src/spec' gets a section of the API reference, and the SDKs are built from one of
  them. To build the SDKs from several, put each in a folder of its own and set 'MergeConfiguration.MergeApis' to true
  in an 'APIMATIC-META.json' beside the folders; each folder then gets a section.

  The portal is built on your machine and written as static files for any static host, served at its root or, when
  'portal.site.url' has a path such as 'https://example.com/docs', at that path. Configure it with 'src/apimatic.json',
  whose 'languages' block gives the portal a page for each SDK language, and whose 'plugin' block, or a 'pluginUrl' in
  its 'portal' block for a plugin hosted elsewhere, a page for the context plugin.

EXAMPLES
  apimatic portal generate

  apimatic portal generate --input=./ --destination=./portal

  apimatic portal generate --zip
```

_参见代码 : [src/commands/portal/generate.ts (中文(简体) )](https://github.com/apimatic/apimatic-cli/blob/v2.2.0/src/commands/portal/generate.ts)_

## `apimatic portal serve`

预览您的 API 文档门户, 并进行活的再装入 .

```
USAGE
  $ apimatic portal serve [-p 23513] [-o] [-i <value>] [-k <value>]

FLAGS
  -i, --input=<value>     [default: ./] path to the parent directory containing the 'src' directory, which includes API
                          specifications and configuration files.
  -k, --auth-key=<value>  override current authentication state with an authentication key.
  -o, --open              open the portal in the default browser.
  -p, --port=23513        [default: 23513] port to serve the portal on.

DESCRIPTION
  Preview your API Documentation Portal with live reload.

  Serves the portal described by 'src/apimatic.json' from your machine, reloading the browser as you edit the Markdown
  pages in 'src/content', reorder them in a 'nav.json', edit the documents in 'src/spec', or change the 'portal',
  'languages' or 'plugin' block of 'apimatic.json'.

  Adding a language or a 'plugin' block, adding or removing a page in 'src/content', creating 'src/static', changing
  which documents are in 'src/spec' or which folders its 'APIMATIC-META.json' merges, or changing the path in
  'portal.site.url', needs the preview restarted.

  Nothing is written to disk; run 'apimatic portal generate' to produce the static files.

EXAMPLES
  apimatic portal serve

  apimatic portal serve --input=./ --port=23513 --open
```

_参见代码 : [sc/命令/门户/服务器](https://github.com/apimatic/apimatic-cli/blob/v2.2.0/src/commands/portal/serve.ts)_

## `apimatic publishing profile list`

列出所有出版配置

```
USAGE
  $ apimatic publishing profile list

DESCRIPTION
  List all publishing profiles

  Display all publishing profiles associated with your account, including each profile's name, ID and enabled languages.

EXAMPLES
  apimatic publishing profile list
```

_参见代码 : [src/commands/出版/简介/列表.ts](https://github.com/apimatic/apimatic-cli/blob/v2.2.0/src/commands/publishing/profile/list.ts)_

## `apimatic quickstart`

创建您的 API 文档门户、 SDK 和上下文插件 .

```
USAGE
  $ apimatic quickstart

DESCRIPTION
  Create your API Documentation Portal, SDKs and Context Plugins.

  Point the CLI at your API specification and it builds a documentation portal, SDKs, and a context plugin that teaches
  an AI coding assistant to use them.

EXAMPLES
  apimatic quickstart
```

_参见代码 : [src/命令/快速启动.ts](https://github.com/apimatic/apimatic-cli/blob/v2.2.0/src/commands/quickstart.ts)_

## `apimatic sdk generate`

为您的 API 生成 SDK

```
USAGE
  $ apimatic sdk generate -l csharp|java|php|python|ruby|typescript|go [-d <value>] [--stability stable|beta]
    [--git-init] [-i <value>] [-f] [-k <value>]

FLAGS
  -d, --destination=<value>  [default: <input>/sdk/<language>] directory the SDK is generated into
  -f, --force                Never ask. Conflicts are resolved using the generator's changes, and an SDK that can't be
                             merged is replaced, with a warning.
  -i, --input=<value>        [default: ./] path to the parent directory containing the 'src' directory, which includes
                             API specifications and configuration files.
  -k, --auth-key=<value>     override current authentication state with an authentication key.
  -l, --language=<option>    (required) Programming language for SDK generation
                             <options: csharp|java|php|python|ruby|typescript|go>
      --git-init             Track the SDK directory with its own git repository so your customizations survive
                             regeneration.
      --stability=<option>   Stability level of the generated SDK. Defaults to the level the language offers.
                             <options: stable|beta>

DESCRIPTION
  Generate an SDK for your API

  Generate a Software Development Kit (SDK) from an API specification.
  C#, TypeScript and Python are available; Java, Ruby, Go and PHP are coming soon.
  To keep your changes to the generated SDK when you regenerate it, install Git 2.38 or later and make the SDK directory
  its own Git repository (--git-init does this for you).

EXAMPLES
  apimatic sdk generate --language=typescript

  apimatic sdk generate --language=csharp --input=./

  apimatic sdk generate --language=python --destination=./my-python-sdk
```

_参见代码 : [src/commands/sdk/generate.ts (中文(简体) )](https://github.com/apimatic/apimatic-cli/blob/v2.2.0/src/commands/sdk/generate.ts)_

## `apimatic sdk publish`

生成并发布 SDK 到软件包注册和/或源寄存器

```
USAGE
  $ apimatic sdk publish [-p <value>] [-v <value>] [-d <value>] [-l csharp|java|php|python|ruby|typescript|go]
    [-f] [-i <value>] [--publish-type package|sourcecode...] [--dry-run] [--stability stable|beta] [--git-init]

FLAGS
  -d, --destination=<value>       [default: <input>/sdk/<language>] path where the sdk will be generated.
  -f, --force                     Never ask. Conflicts are resolved using the generator's changes, and an SDK that can't
                                  be merged is replaced, with a warning.
  -i, --input=<value>             [default: ./] path to the parent directory containing the 'src' directory, which
                                  includes API specifications and configuration files.
  -l, --language=<option>         Language of the SDK to generate and publish.
                                  <options: csharp|java|php|python|ruby|typescript|go>
  -p, --profile-id=<value>        Id of the publishing profile to use.
  -v, --version=<value>           Semantic version of the SDK to publish (e.g. 1.0.0).
      --dry-run                   Generate the SDK locally for review without publishing.
      --git-init                  In guided mode, make the SDK directory a git repository when it isn't one of its own,
                                  so your changes to the SDK are kept. With flags, sdk publish always does this.
      --publish-type=<option>...  One or more publishing targets: 'package' for a package registry, 'sourcecode' for a
                                  git repository.
                                  <options: package|sourcecode>
      --stability=<option>        Stability level of the generated SDK. Defaults to the level the language offers.
                                  <options: stable|beta>

DESCRIPTION
  Generate and publish an SDK to a package registry and/or source repository

  Generate and publish an SDK using a publishing profile configured in the APIMatic App. Requires an input directory
  containing the API specification. Run it with no flags, or with only --git-init, for guided mode, or pass flags for
  CI/CD. When you pass flags, --profile-id, --language, --version, and --publish-type are required.
  Your changes to the SDK are merged before it is published, as sdk generate does with git 2.38 or later: with flags,
  always; in guided mode, add --git-init. Nothing is published while conflicts are left to resolve.

EXAMPLES
  apimatic sdk publish

  apimatic sdk publish --profile-id=a1b2c3d4e5f6a1b2c3d4e5f6 --language=typescript --version=1.0.0 --publish-type=package --publish-type=sourcecode

  apimatic sdk publish --profile-id=b2c3d4e5f6a1b2c3d4e5f6a1 --language=csharp --version=2.0.0 --publish-type=sourcecode

  apimatic sdk publish --profile-id=c3d4e5f6a1b2c3d4e5f6a1b2 --language=python --version=1.0.0 --publish-type=package --dry-run
```

_参见代码 : [sc/命令/sdk/publish.ts](https://github.com/apimatic/apimatic-cli/blob/v2.2.0/src/commands/sdk/publish.ts)_

## 常见问题

### @apimatic/cli 是什么？

APIMatic官方CLI 互联网档案馆的存檔,存档日期2013-12-21\.

### 如何安装 @apimatic/cli？

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

### @apimatic/cli 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @apimatic/cli 支持 ESM 还是 CommonJS？

以 ES Module 形式发布，推荐使用 import 引入。在 CommonJS 项目中，Node\.js 20\.19\+ / 22\.12\+ 可以直接 require\(\) 不含顶层 await 的 ES Module，更早的版本需要改用动态 import\(\)。

### @apimatic/cli 需要什么版本的 Node\.js？

package\.json 的 engines 字段要求 Node\.js \>=22\.14\.0。版本不符时 npm 默认只给出警告，开启 engine-strict 后会拒绝安装。

### @apimatic/cli 可以商用吗？

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

### @apimatic/cli 的下载量有多少？

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

### @apimatic/cli 还在维护吗？

最新版本 2\.2\.0 发布于 2026/11/05（2 天前）；至今共发布 80 个版本，其中过去 12 个月发布了 39 个；首次发布于 2021/11/26。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

