@appwrite.io/console

中文文档
21.0.0发布于 2026/11/05BSD-3-ClauseTypeScriptESM + CJS构建来源已验证近 30 天下载 8313

Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API

原始使用文档
文档目录13 节
  1. Installation
  2. npm
  3. CDN
  4. Getting started
  5. Add a Web platform
  6. Initialize the client
  7. Make your first request
  8. Sign in with OAuth
  9. Type safety with models
  10. Error handling
  11. Learn more
  12. Contribution
  13. License

Appwrite Console SDK

License Version X Account Discord

This SDK targets Appwrite server version 2.7.x as shipped on Appwrite Cloud. Self-hosted releases can lag behind Cloud — if you run an older self-hosted build, use a matching older SDK from previous releases when APIs differ.

Appwrite is an open-source backend as a service server that abstracts and simplifies complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Console SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to https://appwrite.io/docs

Appwrite

Installation

npm

npm install @appwrite.io/console

Import the modules you need. The package ships ES modules, CommonJS and TypeScript types:

import { Client, Account } from '@appwrite.io/console';

CDN

Every release is published to https://sdk.appwrite.io/console/21.0.0/.

ES modules

Each service, helper and enum is its own module, so the browser downloads only what you import. A service is served under its name in kebab case, such as TablesDB from tables-db.js, and enums under enums/, such as OAuthProvider from enums/o-auth-provider.js. index.js re-exports everything, so importing it loads every service:

<script type="module">
    import { Client } from 'https://sdk.appwrite.io/console/21.0.0/client.js';
    import { Account } from 'https://sdk.appwrite.io/console/21.0.0/account.js';
    import { OAuthProvider } from 'https://sdk.appwrite.io/console/21.0.0/enums/o-auth-provider.js';
</script>

Script tag

Add the script before any code that uses the SDK. It exposes every export on the global Appwrite object:

<script src="https://sdk.appwrite.io/console/21.0.0/sdk.min.js"></script>
<script>
    const { Client, Account } = Appwrite;
</script>

Subresource integrity

integrity.json in the same directory maps each .js file to its sha384- hash. An integrity attribute checks only the file it is set on. sdk.min.js is a single file, so its hash as the integrity attribute, together with crossorigin="anonymous", covers the whole SDK. ES modules import other modules and shared chunks, so supply their hashes through the integrity field of an import map to cover those too.

jsDelivr

The script tag build is also available from jsDelivr:

<script src="https://cdn.jsdelivr.net/npm/@appwrite.io/[email protected]"></script>

Getting started

Add a Web platform

In the Appwrite Console, open your project and under Add a platform choose Web app. Enter the hostname your app runs on: localhost for local development, and your production domain once you deploy. Appwrite only accepts browser requests from hostnames registered as platforms, so a missing hostname shows up as a CORS error.

Initialize the client

Copy your endpoint and project ID from your project's Settings page.

import { Client } from '@appwrite.io/console';

const client = new Client()
    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1')
    .setProject('<PROJECT_ID>');

For a self-hosted Appwrite, use https://<HOSTNAME>/v1 as the endpoint.

Make your first request

Create a service from the client and call any of its methods. Every method takes a single object of named parameters and returns a promise. See the API reference for every service and method.

import { Account, ID } from '@appwrite.io/console';

const account = new Account(client);

const user = await account.create({
    userId: ID.unique(),
    email: '[email protected]',
    password: 'password',
    name: "Walter O'Brien",
});

console.log(user);

Sign in with OAuth

Enable the provider in the Console under Auth > Settings, then redirect the user to it. The success and failure URLs must be on a hostname you registered as a platform.

import { Account, OAuthProvider } from '@appwrite.io/console';

const account = new Account(client);

account.createOAuth2Session({
    provider: OAuthProvider.Github,
    success: 'https://example.com/success',
    failure: 'https://example.com/failure',
});

Type safety with models

Methods that return rows, such as listRows and getRow, accept a type parameter for your own row shape:

import { TablesDB, type Models } from '@appwrite.io/console';

interface Book extends Models.Row {
    name: string;
    author: string;
    releaseYear?: string;
    genre?: string[];
    isCheckedOut: boolean;
}

const tablesDB = new TablesDB(client);

const result = await tablesDB.listRows<Book>({
    databaseId: '<DATABASE_ID>',
    tableId: '<TABLE_ID>',
});

for (const book of result.rows) {
    console.log(`${book.name} by ${book.author}`);
}

In JavaScript, the same types are available through JSDoc:

import { TablesDB } from '@appwrite.io/console';

const tablesDB = new TablesDB(client);

/**
 * @typedef {import('@appwrite.io/console').Models.Row & {
 *     name: string,
 *     author: string,
 *     isCheckedOut: boolean,
 * }} Book
 */

/** @type {import('@appwrite.io/console').Models.RowList<Book>} */
const result = await tablesDB.listRows({
    databaseId: '<DATABASE_ID>',
    tableId: '<TABLE_ID>',
});

The Appwrite CLI can generate these interfaces from your database schema with appwrite types. See type generation.

Error handling

Failed requests throw an AppwriteException with message, code, type and response properties.

import { AppwriteException } from '@appwrite.io/console';

try {
    const user = await account.get();
    console.log(user);
} catch (error) {
    if (error instanceof AppwriteException) {
        console.error(error.code, error.type, error.message);
    }
}

The response codes page lists every error type.

Learn more

Contribution

This library is auto-generated by the Appwrite SDK Generator. To learn more about how you can help us improve this SDK, please check the contribution guide before sending a pull-request.

License

Please see the BSD-3-Clause license file for more information.

版本与发布记录

@appwrite.io/console 共发布 128 个版本,首次发布于 2023/02/28;过去 12 个月发布了 63 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
21.0.0latest2026/11/052 天前
20.1.0-rc.3next2026/11/052 天前
20.1.0-rc.22026/10/2612 天前
20.1.0-rc.12026/10/2612 天前
20.0.02026/10/1919 天前
19.1.0-rc.12026/10/1325 天前

关于 @appwrite.io/console 的常见问题

@appwrite.io/console 是什么?

Appwrite is an open-source self-hosted backend server that abstracts and simplifies complex and repetitive development tasks behind a very simple REST API

如何安装 @appwrite.io/console?

在项目目录运行 npm install @appwrite.io/console,或使用 pnpm add / yarn add / bun add。

@appwrite.io/console 支持 TypeScript 吗?

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

@appwrite.io/console 支持 ESM 还是 CommonJS?

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

@appwrite.io/console 需要什么版本的 Node.js?

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

@appwrite.io/console 可以商用吗?

@appwrite.io/console 使用 BSD-3-Clause 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。另外不得用原作者名义为衍生产品背书。以上为概括,不构成法律意见,请以许可原文为准。

@appwrite.io/console 的下载量有多少?

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

@appwrite.io/console 还在维护吗?

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