🚀
TypeScript 优先
完整的类型定义,提供卓越的开发体验和类型安全保障,支持智能提示和错误检查
npm install goofish-client
yarn add goofish-client
pnpm add goofish-client
import { Goofish, LogLevel } from "goofish-client";
// 创建客户端实例
const client = new Goofish({
cookie: "cookie2=xxxx",
level: LogLevel.INFO,
});
// 获取首页Feed数据
const feedData = await client.api.mtop.home.getFeed({
pageSize: 20,
pageNumber: 1,
});
console.log(`获取到 ${feedData.data.cardList.length} 个商品`);
// 搜索商品
const results = await client.api.mtop.search.search({
keyword: "iPhone 14",
pageNumber: 1,
rowsPerPage: 20,
});
console.log(`找到 ${results.data.resultList.length} 个商品`);
// 获取商品详情
const itemDetail = await client.api.mtop.item.getDetail({
itemId: "95xxxxxxxxx334",
});
console.log(`商品标题: ${itemDetail.data.itemDO.title}`);
npm install goofish-client
选择以下任一方式获取认证:
import { Goofish, LogLevel } from "goofish-client";
// 方式1: 使用已有Cookie
const client = new Goofish({
cookie: "your_existing_cookie",
});
// 方式2: 二维码登录
const client = new Goofish({});
const loginResult = await client.api.passport.qr.generate();
// 扫描二维码后获取Cookie...
// 获取首页推荐
const feedData = await client.api.mtop.home.getFeed({
pageSize: 30,
pageNumber: 1,
});
// 搜索商品
const products = await client.api.mtop.search.search({
keyword: "MacBook Pro",
filter: {
priceRange: { from: 5000, to: 15000 },
},
});
// 获取商品详情
const itemDetail = await client.api.mtop.item.getDetail({
itemId: "95xxxxxxxxx334",
});
// 获取用户信息
const userInfo = await client.api.mtop.user.getUserNav();
重要声明
本 Client 为第三方开发工具,仅供学习研究使用。使用前请确保遵守相关平台的服务条款。
TypeScript 类型定义主要覆盖成功响应场景,错误处理请参考官方文档。