@ikenxuan/amagi 6.0.0 → 6.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  </p>
4
4
 
5
5
  <p align="center">
6
- 抖音、B站、小红书 Web 端数据接口的 Node.js 封装
6
+ 抖音、B站、快手和小红书 Web 端数据接口的强大 Node.js 封装
7
7
  </p>
8
8
 
9
9
  <p align="center">
@@ -20,23 +20,27 @@
20
20
 
21
21
  ---
22
22
 
23
+ `@ikenxuan/amagi` 是一个独立发布的多平台 Node.js 数据获取 SDK,同时也内置了 HTTP 服务器功能。它为应用提供稳定、类型安全且经过严格参数校验的统一数据接口。
24
+
23
25
  ## 特性
24
26
 
25
- - **多平台支持** — 抖音、B站、小红书的主流数据接口
26
- - **双模式调用** SDK 直接调用或启动本地 HTTP 服务
27
- - **类型安全** — 完整的 TypeScript 类型定义,支持 strict 模式
28
- - **参数校验** — 基于 Zod 的严格参数验证,统一响应格式
29
- - **事件驱动** — 全新事件系统,灵活的日志与监控
30
- - **双模块输出** 同时支持 ESM 与 CJS
27
+ - **多平台支持**:深度封装抖音、B站、快手、小红书等平台的主流核心数据接口。
28
+ - **双模式调用**:既可以作为 Node.js SDK 在代码中直接调用,也可以一键启动本地 HTTP 服务供跨语言/跨进程使用。
29
+ - **类型安全**:采用 TypeScript 编写,提供完善的参数与响应类型定义。
30
+ - **参数校验**:底层基于 Zod 进行严格的入参和返回值校验,确保数据格式统一可靠。
31
+ - **事件驱动**:内置全新的事件系统,方便上层业务进行灵活的日志记录、拦截与运行监控。
32
+ - **双模块输出**:完美兼容 CommonJS (CJS) 与 ECMAScript Modules (ESM) 生态。
31
33
 
32
34
  ## 安装
33
35
 
36
+ 推荐使用 `pnpm` 进行安装:
37
+
34
38
  ```bash
35
39
  pnpm add @ikenxuan/amagi
36
40
  ```
37
41
 
38
42
  <details>
39
- <summary>其他包管理器</summary>
43
+ <summary>使用其他包管理器</summary>
40
44
 
41
45
  ```bash
42
46
  # npm
@@ -50,37 +54,68 @@ yarn add @ikenxuan/amagi
50
54
 
51
55
  ## 快速开始
52
56
 
53
- ```ts
57
+ ### 作为 SDK 调用
58
+
59
+ 直接在 Node.js 环境中引入并初始化 Amagi:
60
+
61
+ ```typescript
54
62
  import amagi from '@ikenxuan/amagi'
55
63
 
64
+ // 1. 初始化客户端并配置相关平台的 Cookies
56
65
  const client = amagi({
57
66
  cookies: {
58
67
  bilibili: 'SESSDATA=xxx; ...',
59
68
  douyin: 'ttwid=...; ...',
69
+ // xiaohongshu: '...',
70
+ // kuaishou: '...'
60
71
  }
61
72
  })
62
73
 
63
- // SDK 调用
64
- const video = await client.bilibili.fetcher.fetchVideoInfo({
65
- bvid: 'BV1xx411c7mD'
74
+ // 2. 调用平台专属接口获取数据
75
+ async function fetchVideo() {
76
+ const video = await client.bilibili.fetcher.fetchVideoInfo({
77
+ bvid: 'BV1xx411c7mD'
78
+ })
79
+ console.log(video)
80
+ }
81
+
82
+ fetchVideo()
83
+ ```
84
+
85
+ ### 启动 HTTP 服务
86
+
87
+ 如果希望通过 HTTP API 的形式提供服务(例如给其他非 Node.js 应用调用):
88
+
89
+ ```typescript
90
+ import amagi from '@ikenxuan/amagi'
91
+
92
+ const client = amagi({
93
+ // 配置项...
66
94
  })
67
95
 
68
- // 或启动 HTTP 服务
69
- client.startServer(4567)
96
+ // 一键启动 HTTP 服务器
97
+ client.startServer(4567)
98
+ // 服务将运行在 http://localhost:4567
70
99
  ```
71
100
 
72
- ## 文档
101
+ ## 文档资源
73
102
 
74
- 访问 [amagi-docs.vercel.app](https://amagi-docs.vercel.app) 查看完整文档。
103
+ 更详细的接口说明和高级用法,请参阅在线文档:
75
104
 
76
- - [安装指南](https://amagi-docs.vercel.app/docs/usage/installation)
105
+ - [完整文档](https://amagi-docs.vercel.app)
77
106
  - [快速上手](https://amagi-docs.vercel.app/docs/usage/getting-started)
78
- - [API 参考](https://amagi-docs.vercel.app/docs/usage/api/bilibili)
107
+ - [Apifox 接口参考](https://amagi.apifox.cn)
108
+
109
+ ## 参与贡献
110
+
111
+ 本项目虽然是独立发布的 SDK,但目前的开发进度与维护重心主要受 `karin-plugin-kkk` 插件的业务需求驱动。当该插件出现新业务需要而本接口库尚未封装时,我才会对接口库进行针对性的更新和逻辑封装。目前插件侧的核心业务逻辑已基本完成,因此接口库的主动迭代会相对放缓。
79
112
 
80
- ## 贡献
113
+ 如果你(作为下游开发者)需要封装其他未支持的接口或业务逻辑,你可以选择:
114
+ 1. **自己 Fork 本项目**进行修改和定制。
115
+ 2. 阅读 [开发与贡献文档](https://amagi-docs.vercel.app/docs/dev) 后,向本项目提交 Pull Request 共同完善接口生态。
81
116
 
82
- 欢迎提交 Issue Pull Request。详见 [开发文档](https://amagi-docs.vercel.app/docs/dev)。
117
+ 非常欢迎提交 Issue Pull Request
83
118
 
84
119
  ## 许可证
85
120
 
86
- [GPL-3.0](LICENSE)
121
+ 本项目基于 [GPL-3.0](LICENSE) 协议开源。
@@ -1,4 +1,4 @@
1
- //#region rolldown:runtime
1
+ //#region \0rolldown/runtime.js
2
2
  var __create = Object.create;
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -6,16 +6,12 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
8
  var __copyProps = (to, from, except, desc) => {
9
- if (from && typeof from === "object" || typeof from === "function") {
10
- for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
- key = keys[i];
12
- if (!__hasOwnProp.call(to, key) && key !== except) {
13
- __defProp(to, key, {
14
- get: ((k) => from[k]).bind(null, key),
15
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
16
- });
17
- }
18
- }
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
19
15
  }
20
16
  return to;
21
17
  };
@@ -23,12 +19,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
23
19
  value: mod,
24
20
  enumerable: true
25
21
  }) : target, mod));
26
-
27
22
  //#endregion
28
-
29
- Object.defineProperty(exports, '__toESM', {
30
- enumerable: true,
31
- get: function () {
32
- return __toESM;
33
- }
34
- });
23
+ Object.defineProperty(exports, "__toESM", {
24
+ enumerable: true,
25
+ get: function() {
26
+ return __toESM;
27
+ }
28
+ });