@clearblade/iot

中文文档
1.4.4发布于 2026/05/29Apache-2.0TypeScriptCommonJS近 30 天下载 1767

Cloud IoT API client for Node.js

原始使用文档
文档目录11 节
  1. Quickstart
  2. Before you begin
  3. Installing the client library
  4. Setting up service account credentials
  5. BINARYDATA_AND_TIME_GOOGLE_FORMAT env variable (optional)
  6. Using the client library
  7. Samples
  8. Supported Node.js versions
  9. Versioning
  10. Contributing
  11. License

ClearBlade IoT Core: Node.js Client

npm version

Node.js idiomatic client for ClearBlade IoT Core.

ClearBlade IoT Core is a fully managed service for securely connecting and managing IoT devices, from a few to millions. Ingest data from connected devices and build rich applications that integrate with the other big data services of the ClearBlade Platform or the Google Cloud Platform.

Table of contents:

Quickstart

Before you begin

  1. Select or create a Cloud Platform project.
  2. Enable billing for your project.
  3. Enable the ClearBlade IoT Core API.
  4. Set up authentication with a service account so you can access the API from your local workstation.

Installing the client library

npm install @clearblade/iot

Setting up service account credentials

Use one of these docs for this section:

Create a service account in your project and download the credentials .json file. Define an environment variable named CLEARBLADE_CONFIGURATION, which represents the credentials .json file's path. Example:

export CLEARBLADE_CONFIGURATION=/path/to/file.json

As an alternative to using a filepath for your service account credentials, you can take the project, systemKey, token, and url values from your service account's .json file and supply them directly to the constructor:

const client = new DeviceManagerClient({
  credentials: {
    project: '<project>',
    systemKey: '<systemKey>',
    token: '<token>',
    url: '<url>',
  },
});

Use your service account credentials rather than those from the Registry API keys page. You can use one set of service account credentials to target all your project's registries.

BINARYDATA_AND_TIME_GOOGLE_FORMAT env variable (optional)

If you'd like to receive binaryData and timestamps in the same format that the Google IoT Node SDK supplies, you can define an environment variable named BINARYDATA_AND_TIME_GOOGLE_FORMAT. If this env variable is set as true, then it will give the binaryData object's response in byte array form and time in timestamp format, which will have seconds and nanos in it, following Google's structure. It's applicable on the get device state list, modify config, and device config versions methods. By default, this flag's value will be false.

export BINARYDATA_AND_TIME_GOOGLE_FORMAT=true

Using the client library

const iot = require('@clearblade/iot');
const client = new iot.v1.DeviceManagerClient();

async function quickstart() {
  const projectId = await client.getProjectId();
  const parent = client.locationPath(projectId, 'us-central1');
  const [resources] = await client.listDeviceRegistries({parent});
  console.log(`${resources.length} resource(s) found.`);
  for (const resource of resources) {
    console.log(resource);
  }
}
quickstart();

Samples

Samples are in the samples/ directory. Each sample's README.md has instructions for running its sample.

SampleSource codeTry it
Quickstartsource codeOpen in Cloud Shell

The ClearBlade IoT Core Node.js client API reference documentation also contains samples.

Supported Node.js versions

Our client libraries follow the Node.js release schedule. Libraries are compatible with all current active and maintenance versions of Node.js. If you are using an end-of-life version of Node.js, we recommend that you update it as soon as possible to an actively supported LTS version.

ClearBlade's client libraries support legacy versions of Node.js runtimes on a best-efforts basis with the following warnings:

  • Legacy versions are not tested in continuous integration.
  • Some security patches and features cannot be backported.
  • Dependencies cannot be kept up-to-date.

Client libraries targeting some end-of-life versions of Node.js are available and can be installed through npm dist-tags. The dist-tags follow the naming convention legacy-(version). For example, npm install @google-cloud/iot@legacy-8 installs client libraries for versions compatible with Node.js 8.

Versioning

This library follows semantic versioning.

This library is considered to be stable. The code surface will not change in backward-incompatible ways unless necessary (e.g., because of critical security issues) or with an extensive deprecation period. Issues and requests against stable libraries are addressed with the highest priority.

Contributing

Contributions welcome! See the Contributing guide.

License

Apache Version 2.0

See LICENSE

版本与发布记录

@clearblade/iot 共发布 30 个版本,首次发布于 2022/10/25;过去 12 个月发布了 2 个版本。

版本发布日期距今
1.4.4latest2026/05/295 个月前
1.4.32026/05/295 个月前
1.4.22024/06/212 年前
1.4.12024/04/162 年前
1.4.02024/02/012 年前
1.3.12023/09/303 年前

关于 @clearblade/iot 的常见问题

@clearblade/iot 是什么?

Cloud IoT API client for Node.js

如何安装 @clearblade/iot?

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

@clearblade/iot 支持 TypeScript 吗?

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

@clearblade/iot 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@clearblade/iot 需要什么版本的 Node.js?

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

@clearblade/iot 可以商用吗?

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

@clearblade/iot 的下载量有多少?

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

@clearblade/iot 还在维护吗?

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