@frequency-chain/api-augment

中文文档
3.0.0发布于 2026/07/22Apache-2.0TypeScriptESM + CJS构建来源已验证近 30 天下载 30.3万

RPC configuration for Frequency for use with Polkadotjs API

原始使用文档
文档目录10 节
  1. Getting Started
  2. Upgrades and Matching Versions
  3. Usage
  4. Contributing
  5. Updating Definitions
  6. Helpful Notes
  7. Fails to Resolve Custom RPCs
  8. Option
  9. Vec
  10. License

Javascript Custom RPC

Contributors Forks Stargazers Issues MIT License NPM @latest NPM @next

Frequency Custom RPC and Types for Polkadot JS API

An easy way to get all the custom rpc and types config to be able to easily use Frequency with the Polkadot JS API library with TypeScript.

Getting Started

  • npm install @frequency-chain/api-augment (API Augmentation Library)
  • npm install @polkadot/api (Polkadot API Library)

Upgrades and Matching Versions

Assuming you are using no deprecated methods, any release version should work against a release version of @frequency-chain/api-augment. If you are working against a development version it is suggested that you match against the commit hash using v0.0.0-[First 6 of the commit hash].

Changelog is maintained in the releases for Frequency.

Usage

For details on use, see the Polkadot API library documentation.

import { options } from "@frequency-chain/api-augment";
import { ApiPromise } from "@polkadot/api";
// ...

const api = await ApiPromise.create({
  ...options,
  // ...
});

Contributing

See CONTRIBUTING.md for more information.

Updating Definitions

Update ./definitions if you have changed any types or RPC calls.

To generate the JS api definitions, run

make js

This command will start a Frequency node in the background and fetch API definitions from it. To stop the Frequency process, use the PID output by the command.

Helpful Notes

Fails to Resolve Custom RPCs

The api augmentation declares the modules used by @polkadot/api. Thus the import for @frequency-chain/api-augment must come before any @polkadot/api so that the Frequency declarations resolve first.

import { options } from "@frequency-chain/api-augment";
// Or
import "@frequency-chain/api-augment";
// Must come BEFORE any imports from @polkadot/api
import { ApiPromise } from "@polkadot/api";

Caches can also wreck this even if you reorder, so watch out.

  • Yarn cache can sometimes cause issues (if you are using yarn): yarn cache clear
  • Sometimes I have found blowing away the node_modules helps as well: rm -Rf node_modules

Option

Optional responses are not mapped to null and instead return an object with a few properties. For more details see the code for the Option class.

const optionalExample = await api.rpc.schemas.getBySchemaId(1);
// Does the Option have a value?
if (!optionalExample.isEmpty) {
  // Get the value
  return optionalExample.value;
}
return null;

Vec

Vector responses are not mapped directly to a JavaScript Array. Instead they are mapped to the Vec class which does extend Array. Thus, you can still use map, forEach, etc... with responses or access the values directing via .values().

License

Distributed under the Apache 2.0 License. See LICENSE for more information.

版本与发布记录

@frequency-chain/api-augment 共发布 785 个版本,首次发布于 2022/09/23;过去 12 个月发布了 16 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
3.0.0latest2026/07/223 个月前
2.1.0-rc2next2026/03/247 个月前
2.1.0-rc12026/03/148 个月前
2.0.12026/03/108 个月前
2.0.02026/02/059 个月前
2.0.0-rc32026/01/1310 个月前

关于 @frequency-chain/api-augment 的常见问题

@frequency-chain/api-augment 是什么?

RPC configuration for Frequency for use with Polkadotjs API

如何安装 @frequency-chain/api-augment?

在项目目录运行 npm install @frequency-chain/api-augment,或使用 pnpm add / yarn add / bun add。

@frequency-chain/api-augment 支持 TypeScript 吗?

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

@frequency-chain/api-augment 支持 ESM 还是 CommonJS?

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

@frequency-chain/api-augment 可以商用吗?

@frequency-chain/api-augment 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@frequency-chain/api-augment 的下载量有多少?

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

@frequency-chain/api-augment 还在维护吗?

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