@edlink/typescript

中文文档
2.0.6发布于 2026/11/04UnlicenseTypeScriptCommonJS零依赖近 30 天下载 7.3万

这个Edlink JavaScript & TypeScript SDK是Edlink API的节点JS包装器.

中文使用文档
文档目录4 节
  1. 安装
  2. 授权
  3. 图表 API
  4. 用户认证

埃德林克节点 SDK CI

这个Edlink JavaScript & TypeScript SDK是Edlink API的节点JS包装器.

你可以找到关于 编辑 SDK 文档。 。 。 .

开始

安装

安装 @edlink/typescript 使用软件包 npm 或者说 yarn。 。 。 .

yarn add @edlink/typescript
// Initialize with your Edlink application
// Your credentials can be found on the Edlink Dashboard
import { Edlink } from '@edlink/typescript';

const edlink = new Edlink({
    version: 2,
    client_id: '3a95a779-0ed1-499b-a352-9ea30d0bd5ea',
    client_secret: '[...]'
});

Edlink.up().then(console.log); // Ok

授权

// TokenSets are required to access protected resources
// Integration tokens do not expire and therefore dont have a `refresh_token`
// However be sure to store the the `refresh_token` for person token sets
// You are required to provide both when making requests on behalf of a person

export type TokenSet {
    access_token: string;
    refresh_token?: string;
    expires_in?: number;
    type: TokenSetType;
}

export enum TokenSetType = {
    Integration = 'integration',
    Person = 'person'
}

图表 API

// Graph requests are even easier, just build a TokenSet from the values
// in the Edlink Dashboard

const integration_token_set = {
    access_token: '[...]'
};

const district = await edlink.use(integration_token_set).districts.fetch('3a95a779-0ed1-499b-a352-9ea30d0bd5ea');

for await (const district of edlink.use(integration_token_set).districts.list()) {
    console.log(district);
}

用户认证

// Authenticate a user
// First build your login url to provide to the user.
// This URL doesnt change and can be hardcoded if desired
/**
 * https://ed.link/sso/login
 * ?client_id=[...]
 * &redirect_uri=[...]
 * &state=[...]
 * &response_type=code
 */
// Optionally you may provide a state parameter for Endlink to
// passback to you upon authentication of the user

edlink.loginUrl({ redirect_uri: 'https://oauthdebugger.com/debug' });
// When the user returns to your site you will be provided with a code
// e.g. https://oauthdebugger.com/debug?code=[...]
// Provide this code with the matching `redirect_uri` to recieve a token set

// Store this entire object securely
// You will require more than just the access_token
const person_token_set = await edlink.auth.grant({
    code: '[...]'.
    redirect_uri: 'https://oauthdebugger.com/debug'
});

// You can now make requests on behalf of this user
const profile = await edlink.use(person_token_set).my.profile();

版本与发布记录

@edlink/typescript 共发布 23 个版本,首次发布于 2022/09/23;过去 12 个月发布了 3 个版本。

版本发布日期距今
2.0.6latest2026/11/049 天前
2.0.52026/08/262 个月前
2.0.42026/07/313 个月前
2.0.32025/04/031.6 年前
2.0.22025/01/091.8 年前
2.0.12025/01/081.8 年前

关于 @edlink/typescript 的常见问题

@edlink/typescript 是什么?

这个Edlink JavaScript & TypeScript SDK是Edlink API的节点JS包装器.

如何安装 @edlink/typescript?

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

@edlink/typescript 支持 TypeScript 吗?

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

@edlink/typescript 支持 ESM 还是 CommonJS?

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

@edlink/typescript 需要什么版本的 Node.js?

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

@edlink/typescript 可以商用吗?

@edlink/typescript 使用 Unlicense 许可。作者将代码贡献到公共领域,可不受限制地使用。以上为概括,不构成法律意见,请以许可原文为准。

@edlink/typescript 的下载量有多少?

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

@edlink/typescript 还在维护吗?

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