@airweave/sdk

中文文档
0.9.62发布于 2026/04/08TypeScriptESM + CJS零依赖近 30 天下载 1.1万

fern shield [![npm shield

原始使用文档
文档目录16 节
  1. Table of Contents
  2. Installation
  3. Reference
  4. Usage
  5. Request and Response Types
  6. Exception Handling
  7. Advanced
  8. Additional Headers
  9. Additional Query String Parameters
  10. Retries
  11. Timeouts
  12. Aborting Requests
  13. Access Raw Response Data
  14. Runtime Compatibility
  15. Customizing Fetch Client
  16. Contributing

Airweave TypeScript Library

fern shield npm shield

The Airweave TypeScript library provides convenient access to the Airweave APIs from TypeScript.

Table of Contents

Installation

npm i -s @airweave/sdk

Reference

A full reference for this library is available here.

Usage

Instantiate and use the client with the following:

import { AirweaveSDKClient } from "@airweave/sdk";

const client = new AirweaveSDKClient({ apiKey: "YOUR_API_KEY" });
await client.collections.create({
    name: "Finance Data",
    readable_id: "finance-data-reports",
});

Request and Response Types

The SDK exports all request and response types as TypeScript interfaces. Simply import them with the following namespace:

import { AirweaveSDK } from "@airweave/sdk";

const request: AirweaveSDK.ListCollectionsGetRequest = {
    ...
};

Exception Handling

When the API returns a non-success status code (4xx or 5xx response), a subclass of the following error will be thrown.

import { AirweaveSDKError } from "@airweave/sdk";

try {
    await client.collections.create(...);
} catch (err) {
    if (err instanceof AirweaveSDKError) {
        console.log(err.statusCode);
        console.log(err.message);
        console.log(err.body);
        console.log(err.rawResponse);
    }
}

Advanced

Additional Headers

If you would like to send additional headers as part of the request, use the headers request option.

const response = await client.collections.create(..., {
    headers: {
        'X-Custom-Header': 'custom value'
    }
});

Additional Query String Parameters

If you would like to send additional query string parameters as part of the request, use the queryParams request option.

const response = await client.collections.create(..., {
    queryParams: {
        'customQueryParamKey': 'custom query param value'
    }
});

Retries

The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long as the request is deemed retryable and the number of retry attempts has not grown larger than the configured retry limit (default: 2).

A request is deemed retryable when any of the following HTTP status codes is returned:

  • 408 (Timeout)
  • 429 (Too Many Requests)
  • 5XX (Internal Server Errors)

Use the maxRetries request option to configure this behavior.

const response = await client.collections.create(..., {
    maxRetries: 0 // override maxRetries at the request level
});

Timeouts

The SDK defaults to a 60 second timeout. Use the timeoutInSeconds option to configure this behavior.

const response = await client.collections.create(..., {
    timeoutInSeconds: 30 // override timeout to 30s
});

Aborting Requests

The SDK allows users to abort requests at any point by passing in an abort signal.

const controller = new AbortController();
const response = await client.collections.create(..., {
    abortSignal: controller.signal
});
controller.abort(); // aborts the request

Access Raw Response Data

The SDK provides access to raw response data, including headers, through the .withRawResponse() method. The .withRawResponse() method returns a promise that results to an object with a data and a rawResponse property.

const { data, rawResponse } = await client.collections.create(...).withRawResponse();

console.log(data);
console.log(rawResponse.headers['X-My-Header']);

Runtime Compatibility

The SDK works in the following runtimes:

  • Node.js 18+
  • Vercel
  • Cloudflare Workers
  • Deno v1.25+
  • Bun 1.0+
  • React Native

Customizing Fetch Client

The SDK provides a way for you to customize the underlying HTTP client / Fetch function. If you're running in an unsupported environment, this provides a way for you to break glass and ensure the SDK works.

import { AirweaveSDKClient } from "@airweave/sdk";

const client = new AirweaveSDKClient({
    ...
    fetcher: // provide your implementation here
});

Contributing

While we value open-source contributions to this SDK, this library is generated programmatically. Additions made directly to this library would have to be moved over to our generation code, otherwise they would be overwritten upon the next generated release. Feel free to open a PR as a proof of concept, but know that we will not be able to merge it as-is. We suggest opening an issue first to discuss with us!

On the other hand, contributions to the README are always very welcome!

版本与发布记录

@airweave/sdk 共发布 302 个版本,首次发布于 2025/02/03;过去 12 个月发布了 106 个版本。

版本发布日期距今
0.9.62latest2026/04/087 个月前
0.9.612026/04/077 个月前
0.9.602026/03/317 个月前
0.9.592026/03/307 个月前
0.9.582026/03/307 个月前
0.9.572026/03/307 个月前

关于 @airweave/sdk 的常见问题

@airweave/sdk 是什么?

[![npm shield

如何安装 @airweave/sdk?

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

@airweave/sdk 支持 TypeScript 吗?

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

@airweave/sdk 支持 ESM 还是 CommonJS?

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

@airweave/sdk 需要什么版本的 Node.js?

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

@airweave/sdk 可以商用吗?

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

@airweave/sdk 的下载量有多少?

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

@airweave/sdk 还在维护吗?

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