@raimshq/raims

中文文档
0.1.2发布于 2026/11/02MITTypeScriptESM + CJS零依赖

Official Node.js SDK for the Raims public API.

原始使用文档
文档目录7 节
  1. Install
  2. Quick start
  3. Create a charge
  4. TypeScript
  5. Iterate through pages
  6. Resources
  7. Documentation

Raims Node.js

Official Node.js SDK for the Raims public API, with TypeScript types, ESM and CommonJS modules, and methods organized by resource.

Requires Node.js 22 or later. Uses Node.js HTTP transport and has no production dependencies. Run the SDK on the server and keep API keys out of browsers, version control, and logs.

Install

In the application that will use the SDK:

npm install @raimshq/raims

The package name is @raimshq/raims. TypeScript declarations are included. Keep your application's lockfile to reproduce the installed dependency versions.

To update to the latest stable version:

npm install @raimshq/raims@latest

Read the release notes and test your integration after updating. Future updates are not installed automatically.

If you installed an earlier GitHub archive as raims, replace that dependency with @raimshq/raims and update your import and require paths. The Raims class and resource methods keep the same names.

The GitHub releases also provide raims-node.tgz and SHA256SUMS. To install a downloaded package, verify its checksum and run npm install /path/to/raims-node.tgz.

Quick start

import Raims from '@raimshq/raims';

const apiKey = process.env.RAIMS_API_KEY;
if (!apiKey) throw new Error('Set RAIMS_API_KEY on the server.');

const raims = new Raims(apiKey);
const customers = await raims.customers.list({ page_size: 20 });

for (const customer of customers.list) {
  console.log(customer.id);
}

For CommonJS, use const Raims = require('@raimshq/raims'). The named exports Raims and RaimsClient refer to the same constructor.

The base URL is https://api.raims.com in both environments. The API key determines the company, environment, and permissions; the client does not provide an environment selector. Use a Sandbox key for simulations.

Create a charge

This example uses an existing customer. customerId, chargeDueDate, and chargeIdempotencyKey are values your application defines and persists for the order before sending the request.

const charge = await raims.charges.create({
  customer_id: customerId,
  amount_cents: 15000,
  due_date: chargeDueDate,
  title: 'Order 1234',
}, {
  idempotencyKey: chargeIdempotencyKey,
});

const { statusCode, requestId } = charge.lastResponse;

15000 means BRL 150.00. Resource dates use UTC Unix seconds. After losing a response, retain the same key and every parameter, including the due date. The SDK does not generate idempotency keys or retry writes automatically. HTTP 202 means the result is pending and you must track the resource; it does not confirm payment or completion of the financial operation.

TypeScript

import Raims, { type CreateChargeParams } from '@raimshq/raims';

const params: CreateChargeParams = {
  customer_id: customerId,
  amount_cents: 15000,
  due_date: chargeDueDate,
};

const charge = await raims.charges.create(params, {
  idempotencyKey: chargeIdempotencyKey,
});

Types are also available in the Raims namespace, such as Raims.CreateChargeParams and Raims.Charge. They are generated from the same contract that defines the methods and structural response validation.

Iterate through pages

for await (const charge of raims.charges.list({ page_size: 100 })) {
  await processCharge(charge);
}

const customers = await raims.customers.list().autoPagingToArray({ limit: 200 });

The iterator fetches pages as needed and stops when you leave the loop. await list() returns a page with list, page, nextPage(), and previousPage(). Filters and options are retained for subsequent reads.

Resources

accounts, balances, customers, charges, paymentLinks, refunds, disputes, statements, withdrawals, withdrawalDestinations, webhooks, webhookEventTypes, simulations.charges, and simulations.refunds.

See the reference for each resource's methods.

Documentation

Distributed under the MIT license.

版本与发布记录

@raimshq/raims 共发布 2 个版本,首次发布于 2026/11/02;过去 12 个月发布了 2 个版本。

版本发布日期距今
0.1.2latest2026/11/021 天前
0.0.0-stage2026/11/021 天前

关于 @raimshq/raims 的常见问题

@raimshq/raims 是什么?

官方Node.js SDK用于Raims公共API。

如何安装 @raimshq/raims?

在项目目录运行 npm install @raimshq/raims,或使用 pnpm add / yarn add / bun add。

@raimshq/raims 支持 TypeScript 吗?

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

@raimshq/raims 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@raimshq/raims 需要什么版本的 Node.js?

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

@raimshq/raims 可以商用吗?

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

@raimshq/raims 还在维护吗?

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