话说,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封装的更多相关文章

  1. Atitit. C# java 的api 文件夹封装结构映射总结

    Atitit. C#  java 的api 文件夹封装结构映射总结 C# java ref System.Reflection System.Type. java.lang.ref concurren ...

  2. 基于V2EX API的nodejs组件.

    今天又学习到了新的知(zi)识(shi),来给自己做个笔录,也算在这酷热的天气里给自己写了一篇降温的‘膏药’,话就讲这么多了 ,start off...... 首先 ,依赖选择: /**设置为严格模式 ...

  3. 循序渐进VUE+Element 前端应用开发(13)--- 前端API接口的封装处理

    在前面随笔<循序渐进VUE+Element 前端应用开发(12)--- 整合ABP框架的前端登录处理>介绍了一个系统最初接触到的前端登录处理的实现,但往往对整个系统来说,一般会有很多业务对 ...

  4. 必应API接口nodejs版

    近期,在研究百度.必应.API等的url提交API时,发现有用Go语言做工具的大佬的分享 利用 API 自动向搜索引擎提交网址(Go语言版) - pyList. 其中提到bing API提交方法,并给 ...

  5. 依图语音API的C#封装以及调用进行语音转写的处理

    对于语音识别,一般有实时语音识别和语音文件的识别处理等方式,如在会议.培训等场景中,可以对录制的文件进行文字的转录,对于转录文字的成功率来说,如果能够转换90%以上的正确语音内容,肯定能减轻很多相关语 ...

  6. Get Region Information from IP Address with Taobao API

    通过淘宝的API "http://ip.taobao.com/service/getIpInfo.php?ip=*.*.*.*" 来获得你要查询的IP地址的国家,地区,城市,ISP ...

  7. 火币网api的nodejs实现

    var request = require('request'); var crypto = require('crypto'); var config = { api_url: 'https://a ...

  8. Android 音视频开发(五):使用 MediaExtractor 和 MediaMuxer API 解析和封装 mp4 文件

    一个音视频文件是由音频和视频组成的,我们可以通过MediaExtractor.MediaMuxer把音频或视频给单独抽取出来,抽取出来的音频和视频能单独播放: 一.MediaExtractor API ...

  9. $微信小程序开发实践点滴——Bmob基本REST API的python封装

    Refer:Bmob后端云REST API接口文档:http://docs.bmob.cn/data/Restful/a_faststart/doc/index.html 本文使用python对Bmo ...

随机推荐

  1. MySQL用户无法登陆问题

    安装完MySQL后,我们通常添加拥有相应权限的普通用户用来访问数据库.在使用普通用户(假设为tom)本地登录数据库的时候,经常会出现无法登录的情况,但是从其他的mysql客户端却可以登录.在本地使用t ...

  2. Autofac全面解析系列(版本:3.5) – [使用篇(推荐篇):1.类型注册]

    前言 Autofac Autofac是一套高效的依赖注入框架. Autofac官方网站:http://autofac.org/ Autofac在Github上的开源项目:https://github. ...

  3. Python所有的错误都是从BaseException类派生的,常见的错误类型和继承关系

    https://docs.python.org/2/library/exceptions.html#exception-hierarchy BaseException +-- SystemExit + ...

  4. 带有天气预报的高大上web报表制作分享

    我用FineReport开发了挺多报表,但集成天气预报这样提高交互和人性化的还是第一次,所以跟大家分享下. 这个报表是综合的门店销售管理分析面板,可以查询业绩分析.店员销售分析,店铺排行分析(可以看出 ...

  5. KVM 介绍(7):使用 libvirt 做 QEMU/KVM 快照和 Nova 实例的快照 (Nova Instances Snapshot Libvirt)

    学习 KVM 的系列文章: (1)介绍和安装 (2)CPU 和 内存虚拟化 (3)I/O QEMU 全虚拟化和准虚拟化(Para-virtulizaiton) (4)I/O PCI/PCIe设备直接分 ...

  6. 【原】常见CSS3属性对ios&android&winphone的支持

    2个月前,我在博文<webapp开发中兼容Android4.0以下版本的css hack>中写过“那对于做移动网页开发的同事来说,一般只要做好webkit内核浏览器的展现效果就行了” ,在 ...

  7. Ubuntu下初学ROS时所遇小问题

    [1]运行命令$ rospack depends1 beginner_tutorials 时,提示 : [rospack] Error: no such package beginner_tutori ...

  8. maven-安装配置

    Maven是基于项目对象模型(POM),可以通过一小段描述信息来管理项目的构建,报告和文档的软件项目管理工具. maven是什么maven这个词可以翻译为“知识的积累”,也可以翻译为“专家”或“内行” ...

  9. [No000012]编程中浮点数之什么是科学计数法

    科学记数法 把一个绝对值小于1(或者大于等于10)的实数记为a×10n的形式(其中1≤/a/<10),这种记数法叫做科学记数法. (或者大于等于10)的实数记为a×10^n的形式(其中1≤|a| ...

  10. 实用js函数收集

    1. 全选复选框: //复选框全选函数 function SelectAll() { var checkAll = document.getElementsByName("checkAll& ...