@x-money/cli

中文文档
0.2.0发布于 2026/10/30MITES Module

xmoney, the X Money API from the command line

原始使用文档
文档目录9 节
  1. Quick start
  2. Credentials
  3. Commands
  4. Creating things
  5. Pagination
  6. Output and exit codes
  7. Documentation
  8. Support
  9. License

@x-money/cli

xmoney, the X Money API from a terminal. Create checkout sessions, charge linked accounts, issue refunds and payouts, and read anything the API exposes.

Every command is a thin wrapper over @x-money/core, so the two cannot drift apart about what the API offers.

Node 24 or newer.

npm install -g @x-money/cli
xmoney --help

Or run it without installing: npx @x-money/cli --help.

Quick start

xmoney login                      # prompts for a key, stores it on the default profile
xmoney whoami                     # shows which key and base url resolved, key masked
xmoney payments list --limit 10

Credentials

A key is looked for in three places, in order: --api-key, then XMONEY_API_KEY, then the profile on disk. The base url resolves the same way through --base-url and XMONEY_API_BASE_URL, falling back to the profile and then to the SDK default.

Profiles keep keys apart, for example a test-mode key beside a live one. --profile or XMONEY_PROFILE selects one, and the default is named default.

xmoney login --profile test       # prompts for your xmsk_test_ key
xmoney payments list --profile test

The config file lives at $XDG_CONFIG_HOME/xmoney/config.json, or ~/.config/xmoney/config.json when that is unset. It holds secret keys, so it is written 0600 inside a 0700 directory, and an existing file is tightened to 0600 on every write.

Commands

ResourceActions
checkoutscreate, get
exchangescreate, get
accountsget, list, revoke
customersget, list
paymentscreate, get, list, capture, release-authorization, update-authorization
refundscreate, get, list
payoutscreate, get, list, reverse
settlementslist, get, file

Plus login and whoami. xmoney --help prints the full flag reference, and --help works on any command.

This table is checked against the methods @x-money/core exposes, in both directions, so a resource cannot reach the SDK without a command shipping here in the same release.

Creating things

Each create takes typed flags, listed under xmoney --help. Anything they do not cover goes through --data as raw JSON, and --metadata k=v repeats.

xmoney refunds create --payment <payment-id> --amount 500 --reference refund-order-8471
xmoney payouts create --data '{"account_id":"xmac_...","amount":2500}'

Amounts are integers in the currency's smallest unit, so 49999 is $499.99.

Every POST carries a generated idempotency key. Pass --idempotency-key to make a retry safe across invocations, which is what you want when a command is driven by an order id.

With a test key, --test-outcome sends the Xm-Test-Outcome header to force a decline, an expiry, or an authorization error, for example --test-outcome INSUFFICIENT_FUNDS.

Pagination

Lists return one page. --all follows the cursor to the end and returns the accumulated set, so it is a request per page and worth a thought on large accounts.

xmoney payouts list --limit 100 --all

Output and exit codes

Results are JSON on stdout and nothing else, so | jq works. Everything else, prompts and errors included, goes to stderr.

--verbose adds one stderr line per request with its method, path, status, and x-request-id, so a call that succeeded but returned something surprising still leaves an id to quote.

ExitMeaning
0Success.
1The API returned an error. The error object, with its code, status, and request_id, is printed to stderr as JSON.
2The request never got a response: network failure, timeout, or abort.
64The command line or the credentials were wrong: a missing flag, or a key that is not a secret key. Nothing was sent.

Every error the SDK can raise maps to one of these. A stack trace means a bug in the CLI itself.

Documentation

Guides, the API reference, and the webhook catalog are at xmoney.mintlify.site/docs.

Support

Report bugs and ask questions through the X Help Center. Security issues go through the same form; please do not post them publicly.

License

MIT. The full text ships in the package as LICENSE.

版本与发布记录

@x-money/cli 共发布 2 个版本,首次发布于 2026/10/03;过去 12 个月发布了 2 个版本。

版本发布日期距今
0.2.0latest2026/10/304 天前
0.1.02026/10/031 个月前

关于 @x-money/cli 的常见问题

@x-money/cli 是什么?

xmoney,命令行中的X Money API

如何安装 @x-money/cli?

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

@x-money/cli 支持 TypeScript 吗?

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

@x-money/cli 支持 ESM 还是 CommonJS?

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

@x-money/cli 需要什么版本的 Node.js?

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

@x-money/cli 可以商用吗?

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

@x-money/cli 还在维护吗?

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