@air/api-sdk

中文文档
0.12.0发布于 2026/11/06MITTypeScriptESM + CJS近 30 天下载 1.1万

Air API SDK - complete SDK for the Air.inc API

原始使用文档
文档目录9 节
  1. Installation
  2. Quick start
  3. Environment variables
  4. Configuration
  5. Resources
  6. Pagination
  7. Error handling
  8. Documentation
  9. License

@air/api-sdk

Typed JavaScript/TypeScript SDK for the Air API.

This is the main package you should install. It re-exports everything from @air/api-core and @air/api-rest.

Installation

npm install @air/api-sdk

Quick start

import { AirApi } from "@air/api-sdk";

const air = new AirApi({
  apiKey: "your-api-key",
  workspaceId: "your-workspace-id",
});

// List boards
const page = await air.boards.list();
console.log(page.data);

Environment variables

Instead of passing options directly, you can set environment variables:

export AIR_API_KEY=your-api-key
export AIR_WORKSPACE_ID=your-workspace-id
const air = new AirApi(); // reads from env

Configuration

const air = new AirApi({
  apiKey: "your-api-key", // or AIR_API_KEY env var
  workspaceId: "your-workspace-id", // or AIR_WORKSPACE_ID env var
  baseURL: "https://api.air.inc/v1", // default
  maxRetries: 3, // default, with exponential backoff
  timeout: 60_000, // default, in milliseconds
  defaultHeaders: {
    // optional, sent with every request
    "user-agent": "my-app/1.0",
    "x-custom-header": "value",
  },
});

Resources

  • Boards: air.boards.* (list, get, create, update, delete, guests, custom fields, share links)
  • Showcases: air.showcases.* (list, get, create, update, updateShareLink, addAssets, removeAsset, addBoards, removeBoard)
  • Assets: air.assets.* (list, get, delete, versions, custom fields, tags, CDN links, share links)
  • Tags: air.tags.* (list, get, create, update, delete)
  • Custom fields: air.customFields.* (list, create, update, delete, values)
  • Discussions: air.discussions.* (list, get, listComments, create, createComment, update, updateComment, deleteComment)
  • Members: air.members.list
  • Roles: air.roles.* (list)
  • Uploads: air.uploads.* (uploadFile with progress tracking, multipart for large files)
  • Imports: air.imports.* (create, getStatus)

Pagination

List methods return a PagePromise that supports auto-pagination:

for await (const asset of air.assets.list({ limit: 50 })) {
  console.log(asset.id);
}

Or manual pagination:

const page = await air.assets.list({ limit: 50 });
console.log(page.data);
if (page.hasNextPage()) {
  const next = await page.getNextPage();
}

Error handling

All API errors extend APIError. Specific error classes are thrown based on HTTP status (400 BadRequestError, 401 AuthenticationError, 403 PermissionError, 404 NotFoundError, 429 RateLimitError, 500+ InternalServerError). Retryable errors are automatically retried with exponential backoff.

Documentation

License

MIT

版本与发布记录

@air/api-sdk 共发布 15 个版本,首次发布于 2026/03/28;过去 12 个月发布了 15 个版本。

版本发布日期距今
0.12.0latest2026/11/062 天前
0.11.02026/10/309 天前
0.10.02026/10/299 天前
0.9.02026/10/2811 天前
0.8.02026/10/2711 天前
0.7.02026/10/2217 天前

关于 @air/api-sdk 的常见问题

@air/api-sdk 是什么?

Air API SDK - complete SDK for the Air.inc API

如何安装 @air/api-sdk?

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

@air/api-sdk 支持 TypeScript 吗?

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

@air/api-sdk 支持 ESM 还是 CommonJS?

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

@air/api-sdk 需要什么版本的 Node.js?

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

@air/api-sdk 可以商用吗?

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

@air/api-sdk 的下载量有多少?

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

@air/api-sdk 还在维护吗?

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