@assembly-js/node-sdk

中文文档
4.2.4发布于 2026/10/07TypeScriptES Module零依赖近 30 天下载 9211

The Assembly.js Node.JS SDK

原始使用文档
文档目录15 节
  1. For AI coding agents
  2. Installation
  3. Setup
  4. For Custom Apps
  5. For Marketplace Apps
  6. Migration from copilot-node-sdk
  7. Package Installation
  8. Code Changes
  9. Environment Variables
  10. Backwards Compatibility
  11. How to develop this package internally:
  12. Field Deprecations
  13. Deprecated Fields
  14. Migration Guide
  15. Developer Experience

Assembly.js Node SDK

The Assembly.js Node SDK provides easy to call functions written in TypeScript for interacting with the Assembly REST API. Right now this is a TypeScript only package. In the future we will have a Vanilla JS package with a corresponding @types package to go along with it.

This SDK is intended to be used on the server-side only. We do not currently offer a package for client-side development.

For AI coding agents

This section surfaces key resources for LLM-based tools and AI coding agents working with this SDK.

Installation

npm install @assembly-js/node-sdk
# or
yarn add @assembly-js/node-sdk

Setup

Note: Since v4, assemblyApi() is async and must be called with await.

For Custom Apps

import { assemblyApi } from '@assembly-js/node-sdk';

const assembly = await assemblyApi({ apiKey: YOUR_API_KEY_HERE });

For Marketplace Apps

If you're building a Marketplace app you should go through one additional step of fetching a query parameter that gets passed into the App URL when rendered in the dashboard: ?token=TOKEN_IS_HERE

Grab that token from the URL and pass it in to the assemblyApi configuration object.

import { assemblyApi } from '@assembly-js/node-sdk';

const assembly = await assemblyApi({
  apiKey: YOUR_API_KEY_HERE,
  token: searchParams.token,
});

Migration from copilot-node-sdk

If you're migrating from copilot-node-sdk, the following changes are needed:

Package Installation

# Remove old package
npm uninstall copilot-node-sdk

# Install new package
npm install @assembly-js/node-sdk

Code Changes

// Before
import { copilotApi } from 'copilot-node-sdk';
const copilot = copilotApi({ apiKey: YOUR_API_KEY });

// After (note: assemblyApi is async since v4)
import { assemblyApi } from '@assembly-js/node-sdk';
const assembly = await assemblyApi({ apiKey: YOUR_API_KEY });

Environment Variables

Old VariableNew VariableNotes
COPILOT_ENVASSEMBLY_ENVBoth work, new takes precedence
COPILOT_DEBUGASSEMBLY_DEBUGBoth work, new takes precedence

Backwards Compatibility

For a gradual migration, the old names are still available but deprecated:

// These still work but are deprecated
import { copilotApi, type CopilotAPI } from '@assembly-js/node-sdk';

How to develop this package internally:

  1. yarn
  2. yarn generate-api
  3. yarn test to produce a successful response
  4. yarn test:fail to product a response that fails because of a missing env variable.

For additional logging you can set the environment variable ASSEMBLY_DEBUG to any truthy value. This is useful if you'd like to see SDK logs while developing in an application's codebase.

Field Deprecations

Deprecated Fields

The following fields are deprecated and will be removed in a future version of the SDK:

companyId (deprecated in v3.15.0)

  • Replacement: Use companyIds array instead
  • Reason: To support multi-company functionality
  • Affected endpoints: Client operations, App connections, Tasks

recipientId (deprecated in v3.15.0)

  • Replacement: Use clientId and companyId instead
  • Reason: More explicit recipient targeting
  • Affected endpoints: Contracts, Invoices, Notifications, Subscriptions

Migration Guide

Before (deprecated):

// Creating a client with single company
await assembly.createClient({
  companyId: 'company-uuid-here',
  // ... other fields
});

// Creating an invoice with recipient ID
await assembly.createInvoice({
  recipientId: 'recipient-uuid-here',
  // ... other fields
});

After (recommended):

// Creating a client with multiple companies support
await assembly.createClient({
  companyIds: ['company-uuid-here'], // Now an array
  // ... other fields
});

// Creating an invoice with explicit client and company targeting
await assembly.createInvoice({
  clientId: 'client-uuid-here',
  companyId: 'company-uuid-here',
  // ... other fields
});

Developer Experience

When using deprecated fields, you'll see:

  • IDE warnings: TypeScript will show deprecation warnings in your editor
  • JSDoc annotations: Hover over deprecated fields to see migration guidance
  • Continued functionality: Deprecated fields continue to work until removal

版本与发布记录

@assembly-js/node-sdk 共发布 15 个版本,首次发布于 2026/01/29;过去 12 个月发布了 15 个版本。

版本发布日期距今
4.2.4latest2026/10/071 个月前
4.2.3-beta.2beta2026/07/293 个月前
4.2.3-beta.12026/07/283 个月前
4.2.3-beta.02026/07/203 个月前
4.2.22026/07/183 个月前
4.2.2-beta.32026/07/153 个月前

关于 @assembly-js/node-sdk 的常见问题

@assembly-js/node-sdk 是什么?

The Assembly.js Node.JS SDK

如何安装 @assembly-js/node-sdk?

在项目目录运行 npm install @assembly-js/node-sdk,或使用 pnpm add / yarn add / bun add。

@assembly-js/node-sdk 支持 TypeScript 吗?

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

@assembly-js/node-sdk 支持 ESM 还是 CommonJS?

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

@assembly-js/node-sdk 需要什么版本的 Node.js?

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

@assembly-js/node-sdk 可以商用吗?

@assembly-js/node-sdk 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@assembly-js/node-sdk 的下载量有多少?

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

@assembly-js/node-sdk 还在维护吗?

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