Observed since 20 Oct, 18:05 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
[](https://www.npmjs.com/package/115pan-node) [](https://opensource.org/licenses/MIT) [, featuring QR code login, file management, download URL retrieval, and more.
# Using bun (recommended)
bun add 115pan-node
# Using npm
npm install 115pan-node
# Using yarn
yarn add 115pan-node
# Using pnpm
pnpm add 115pan-node
import { P115Client } from "115pan-node";
// 方式 1: 从 cookies 字符串创建
const client = new P115Client("UID=xxx; CID=xxx; SEID=xxx");
// 方式 2: 从 cookies 文件创建(推荐)
const client = await P115Client.fromPath("./115-cookies.txt");
// 方式 3: 空客户端,稍后登录
const client = new P115Client();
import { P115Client } from "115pan-node";
import qrcodeTerminal from "qrcode-terminal";
const client = new P115Client(undefined, {
cookiesPath: "./115-cookies.txt", // 自动保存 cookies
});
await client.loginWithQrcode(
"web",
(qrcodeUrl, uid) => {
// 在终端打印 ASCII 二维码
qrcodeTerminal.generate(qrcodeUrl, { small: true }, console.log);
console.log(`请用 115 App 扫码登录 (UID: ${uid})`);
},
(status) => {
// status: 0=等待扫码, 1=已扫描待确认, 2=登录成功
console.log("状态:", status);
}
);
console.log("登录成功!用户 ID:", client.userId);
// 列出目录
const result = await client.fsFiles({ cid: 0, limit: 50 });
console.log("文件列表:", result.data);
// 搜索文件
const search = await client.fsSearch({ search_value: "关键词", cid: 0 });
// 创建文件夹
await client.fsMkdir({ cid: 0, file_name: "新建文件夹" });
// 移动文件
await client.fsMove({ fid: "文件ID", pid: "目标目录ID" });
// 复制文件
await client.fsCopy({ fid: "文件ID", pid: "目标目录ID" });
// 删除文件/文件夹
await client.fsDelete({ fid: "文件ID" });
// 获取文件下载链接
const download = await client.downloadUrlWeb({ pickcode: "文件提取码" });
console.log("下载地址:", download.file_url);
// 批量获取
const batch = await client.downloadUrlApp({ pickcode: "code1,code2,code3" });
// 获取分享链接信息
const info = await client.shareInfo({ share_code: "分享码" });
// 保存分享文件到网盘
await client.shareReceive({
share_code: "分享码",
receive_code: "提取码",
fid: "文件ID",
cid: "目标目录ID"
});
主客户端类,提供所有 API 方法。
new P115Client(cookies?, options?)
cookies: 可选,cookies 字符串或对象options:
cookiesPath: cookies 文件路径,自动读写checkForRelogin: 是否在收到 405 响应时自动重新登录P115Client.fromPath(path, options?): Promise<P115Client>
从文件读取 cookies 并创建客户端实例。
| 方法 | 说明 |
|---|---|
fsFiles({ cid, limit, offset, ... }) | 列出目录内容 |
fsSearch({ search_value, cid, ... }) | 搜索文件 |
fsMkdir({ cid, file_name }) | 创建文件夹 |
fsMove({ fid, pid }) | 移动文件 |
fsCopy({ fid, pid }) | 复制文件 |
fsDelete({ fid }) | 删除文件 |
fsRename({ fid, file_name }) | 重命名 |
fsInfo({ fid }) | 获取文件信息 |
fsGetPath({ fid }) | 获取文件路径 |
| 方法 | 说明 |
|---|---|
downloadUrlWeb({ pickcode }) | 获取下载链接(Web 接口) |
downloadUrlApp({ pickcode }) | 获取下载链接(App 接口) |
downloadFolders({ pickcode }) | 获取下载文件夹列表 |
downloadFiles({ pickcode }) | 获取下载文件列表 |
| 方法 | 说明 |
|---|---|
loginQrcodeToken(app) | 获取二维码 token |
loginQrcodeScanStatus({ uid, time, sign }) | 查询扫码状态 |
loginQrcodeScanResult(uid, app) | 获取登录结果 |
loginWithQrcode(app, onQrcode, onStatus) | 完整扫码登录流程 |
| 方法 | 说明 |
|---|---|
shareInfo({ share_code }) | 获取分享信息 |
shareReceive({ share_code, receive_code, ... }) | 保存分享文件 |
offlineTaskAdd({ url }) | 添加离线任务 |
# 克隆项目
git clone https://github.com/yourusername/115pan-node.git
cd 115pan-node
# 安装依赖
bun install
# 运行演示(扫码登录)
bun run demo
# 使用保存的 cookies
bun run demo:save
# 运行测试
bun test
# 构建产物
bun build ./index.ts --outdir ./dist
// 主要类型
export type { P115ClientOptions, RequestOptions };
export type { P115CookiesData, DirNode, P115URL };
// 错误类
export {
P115OSError,
P115AuthenticationError,
P115BusyOSError,
P115DataError,
P115OperationalError,
P115AccessError,
P115FileTooBig,
P115ExceededError,
P115InvalidArgumentError,
P115NoSpaceError,
P115NotSupportedError,
P115LoginError,
};
欢迎提交 Issue 和 Pull Request!
Download counts and popularity will appear here as the collector receives them.
This describes our collected data; it is not a security assessment.
Observed since 20 Oct, 18:05 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:dde1028eab10b7f7f90ef2a8ed84ac35191b658c85a7a12aa5a5e5e67545cada