个人觉得目前 最好用的Taobao API的NodeJS封装
话说,Top API SDK默认只给了四种语言的SDK,没有我大NodeJS,这可怎么行,于是封装了一个。
参考地址
GitHub: https://github.com/xiaoppp/TopAPI-Node
NPM: https://www.npmjs.com/package/topapi-node
TopAPI SDK for Node.js
Using Es6 promise, all api return promise.
Platform Compatibility
Using Promise, Generator features of ES6
When using node 0.11.x or greater, you must use the --harmony-generators flag or just --harmony to get access to generators.
When using node 0.10.x and lower or browsers without generator support, you must use gnode and/or regenerator.
io.js is supported out of the box, you can use co without flags or polyfills.
Install
$ npm install topapi-node
Usage
var Top = require("topapi-node");
var top = new Top({
appKey:"",
appSecret: "",
sessionKey: ""
});
var params = {
page_size: 200,
fields: "num_iid,title,price,pic_url,num,seller_cids,modified,list_time,has_showcase"
}
top.taobao_items_onsale_get(params).then(
(data) => {
console.log(data);
},
(err) => console.log(err)
)
Extend Top Apis
Since topAPI has huge APIs, and this only implements some of them, so you have two ways to extend that, both of them were fine.
Maybe the best way is contribute your code into lib/apis file. :) First way, you can extend the TOPAPI prototype Top.prototype.taobao_items_onsale_get = function(params) {
let self = this;
let method = "taobao.items.onsale.get";
return new Promise((resolve, reject) => {
self.postAPI(method, params).then(
(body) => {resolve(body.items_onsale_get_response);},
(err) => reject(err)
);
});
} Second way, postAPI to server let method = "taobao.items.onsale.get"; var params = {
page_size: 200,
fields: "num_iid,title,price,pic_url,num,seller_cids,modified,list_time,has_showcase"
} top.postAPI(method, params).then(
(body) => {
console.log(body);
},
(err) => console.log(err)
)
Process Control
Suggest to use CO for process control
co(function*() {
let param = {
parent_id: 0,
picture_category_name: "test"
};
let category = yield top.taobao_picture_category_get(param);
if (category) {
category = yield top.taobao_picture_category_add(param);
}
return Promise.resolve(category);
}
License
(c) Fork Ltd. Licensed under the MIT license.
Using ES6 features Promise Array Function Generator
个人觉得目前 最好用的Taobao API的NodeJS封装的更多相关文章
- Atitit. C# java 的api 文件夹封装结构映射总结
Atitit. C# java 的api 文件夹封装结构映射总结 C# java ref System.Reflection System.Type. java.lang.ref concurren ...
- 基于V2EX API的nodejs组件.
今天又学习到了新的知(zi)识(shi),来给自己做个笔录,也算在这酷热的天气里给自己写了一篇降温的‘膏药’,话就讲这么多了 ,start off...... 首先 ,依赖选择: /**设置为严格模式 ...
- 循序渐进VUE+Element 前端应用开发(13)--- 前端API接口的封装处理
在前面随笔<循序渐进VUE+Element 前端应用开发(12)--- 整合ABP框架的前端登录处理>介绍了一个系统最初接触到的前端登录处理的实现,但往往对整个系统来说,一般会有很多业务对 ...
- 必应API接口nodejs版
近期,在研究百度.必应.API等的url提交API时,发现有用Go语言做工具的大佬的分享 利用 API 自动向搜索引擎提交网址(Go语言版) - pyList. 其中提到bing API提交方法,并给 ...
- 依图语音API的C#封装以及调用进行语音转写的处理
对于语音识别,一般有实时语音识别和语音文件的识别处理等方式,如在会议.培训等场景中,可以对录制的文件进行文字的转录,对于转录文字的成功率来说,如果能够转换90%以上的正确语音内容,肯定能减轻很多相关语 ...
- Get Region Information from IP Address with Taobao API
通过淘宝的API "http://ip.taobao.com/service/getIpInfo.php?ip=*.*.*.*" 来获得你要查询的IP地址的国家,地区,城市,ISP ...
- 火币网api的nodejs实现
var request = require('request'); var crypto = require('crypto'); var config = { api_url: 'https://a ...
- Android 音视频开发(五):使用 MediaExtractor 和 MediaMuxer API 解析和封装 mp4 文件
一个音视频文件是由音频和视频组成的,我们可以通过MediaExtractor.MediaMuxer把音频或视频给单独抽取出来,抽取出来的音频和视频能单独播放: 一.MediaExtractor API ...
- $微信小程序开发实践点滴——Bmob基本REST API的python封装
Refer:Bmob后端云REST API接口文档:http://docs.bmob.cn/data/Restful/a_faststart/doc/index.html 本文使用python对Bmo ...
随机推荐
- MySQL 调优基础(二) Linux内存管理
进程的运行,必须使用内存.下图是Linux中进程中的内存的分布图: 其中最重要的 heap segment 和 stack segment.其它内存段基本是大小固定的.注意stack是向低地址增长的, ...
- Linux下NDK编译FFMPEG包含neon参数
FFMPEG编译成Android库已经有很多案例了,编译优化neon的也很多,以下是我通过实践成功的案例,这里主要讲编译的配置文件,其他设置可结合Linux下使用NDK编译FFMPEG(libstag ...
- 模块module
python中的Module相当于C++中头文件和命名空间的组合体,便于代码的组织,任何一个python代码的文件都是一个Module,都可以被其他模块import import,from...imp ...
- 一、Android学习第一天——环境搭建(转)
(转自:http://wenku.baidu.com/view/af39b3164431b90d6c85c72f.html) 一. Android学习第一天——环境搭建 Android 开发环境的搭建 ...
- 留念 C语言第一课简单的计算器制作
留念 C语言第一课简单的计算器制作 学C语言这么久了. /* 留念 C语言第一课简单的计算器制作 */ #include<stdio.h> #include<stdlib.h ...
- [引] Security tips for web developers
Source :Security tips for web developers
- 如何在TFS中恢复系统默认查询”已指派给我”的设置(TFS 2013)
故事是这样开始的,一天开发人员求助说,在浏览器中修改了系统默认的工作项查询"已指派给我"的后,发现这个查询每次都提示超时,并且没有办法恢复到初始的设置状态,因为出现超时提示以后,查 ...
- 磁盘、分区及Linux文件系统 [Disk, Partition, Linux File System]
1.磁盘基础知识 1.1 物理结构 硬盘的物理结构一般由磁头与碟片.电动机.主控芯片与排线等部件组成:当主电动机带动碟片旋转时,副电动机带动一组(磁头)到相对应的碟片上并确定读取正面还是反面的碟面,磁 ...
- 突然发现这周有点忙。。着玩-PHP进阶
hi 周二才,不过我突然意识到这周有点忙着玩的感觉,还是很期待的——今天下午去市里,晚上回来看电影,明晚聚餐吃火锅,后天下午拍短片,晚上可能要打球,周五,嗯,就到周五了.虽然这样下去连怎么写(bian ...
- OpenStack Networking overview
原文地址:http://docs.openstack.org/newton/install-guide-ubuntu/neutron-concepts.html Networking service ...