比官方SDK更好用的腾讯云SDK。
已经疯狂得不能用代码行数(总计
66
行,包含空行和debug)来衡量该项目了,代码仅有1,489
字节(净化后)。
Minimum, Flexible, Scalable.
支持Lazy Require。
Table of Contents generated with DocToc
国际惯例:
npm install wqcloud --save
# Node.js 7.6.0之前的版本请安装 v2.x.x版本
npm install wqcloud@2.1.4 --save
公共参数:
var options = {
SecretId: '',
SecretKey: '',
// 不填,每次请求都会自动重新生成
// Signature: '',
Nonce: parseInt(Math.random() * 999999, 10),
Timestamp: parseInt(new Date() / 1000, 10)
};
ES5:
var WQCLOUD = require('wqcloud');
var trade = WQCLOUD.TRADE(options);
trade.DescribeUserInfo().then(function(instances){
// xxxx
});
ES7:
const {TRADE} = require('wqcloud');
const trade = TRADE(options);
// Within Async Func
(async() => {
const userInfo = await trade.DescribeUserInfo();
// xxxx
})();
默认使用的版本是 v3, 如果需要使用 V2 参考:
ES5:
var WQCLOUD = require('wqcloud');
var trade = WQCLOUD.V2.TRADE(options);
trade.DescribeUserInfo().then(function(instances){
// xxxx
});
ES7:
const {V2:{ TRADE }} = require('wqcloud');
const trade = TRADE(options);
// Within Async Func
(async() => {
const userInfo = await trade.DescribeUserInfo();
// xxxx
})();
API文档参考:https://www.qcloud.com/document/api/213/568
查询可用区示例:
const WQCLOUD = require('wqcloud');
const example = WQCLOUD.CVM({
SecretId: 'xxxx',
SecretKey: 'xxxx'
});
example.DescribeAvailabilityZones({
Region: 'gz'
}).then((data) => {
console.log(data);
});
API文档参考:https://www.qcloud.com/document/api/362/2445
查询价格示例:
const example = WQCLOUD.CBS({
SecretId: 'xxxx',
SecretKey: 'xxxx'
});
example.InquiryStoragePrice({
inquiryType: 'create',
storageType: 'cloudBasic',
storageSize: 100,
goodsNum: 1,
period: 1,
payMode: 'prePay'
}).then((data) => {
console.log(data);
});
API文档参考:https://www.qcloud.com/document/api/386/6628
查询可用区示例:
const example = WQCLOUD.BM({
SecretId: 'xxx',
SecretKey: 'xxx'
});
example.DescribeRegions().then((data) => {
console.log(data);
});
API文档参考:https://www.qcloud.com/document/api/377/3170
查询弹性伸缩组示例:
const example = WQCLOUD.SCALING({
SecretId: 'xxxx',
SecretKey: 'xxxx'
});
example.DescribeScalingGroup().then((data) => {
console.log(data);
});
API文档参考: https://www.qcloud.com/document/api/214/888
查询价格示例:
const example = WQCLOUD.LB({
SecretId: 'xxxx',
SecretKey: 'xxxx'
});
example.InquiryLBPrice({
loadBalancerType: 2
}).then((data) => {
console.log(data);
});
API文档参考: https://www.qcloud.com/document/api/215/908
查询私有网络列表示例:
const example = WQCLOUD.VPC({
SecretId: 'xxxx',
SecretKey: 'xxxx'
});
example.DescribeVpcEx().then((data) => {
console.log(data);
});
API文档参考: https://www.qcloud.com/document/api/228/1722
查询所有域名信息示例:
const example = WQCLOUD.CDN({
SecretId: 'xxxx',
SecretKey: 'xxxx'
});
example.DescribeCdnHosts().then((data) => {
console.log(data);
});
API文档参考: https://www.qcloud.com/document/api/236/1209
即DNSPOD
服务。
不得不说,DNSPOD是我见过最烂的服务商,客服电话永远打不通。交钱的是大爷,想要霸占别人域名只需要购买VIP服务即可,域名主人就别再想用DNSPOD的免费服务了。呵呵哒~
个人意见,强烈推荐参考。
API文档参考: https://www.qcloud.com/document/api/302/4031
API文档参考: https://www.qcloud.com/document/api/237/2246
API文档参考:https://www.qcloud.com/document/api/238/6430
API文档参考: https://www.qcloud.com/document/api/239/1748
API文档参考: https://www.qcloud.com/document/api/241/1762
API文档参考: https://www.qcloud.com/document/api/297/2314
API文档参考: https://www.qcloud.com/document/api/295/1773
API文档参考: https://www.qcloud.com/document/api/397/1785
API文档参考: https://www.qcloud.com/document/api/270/1989
API文档参考: https://www.qcloud.com/document/api/271/2049
API文档参考: https://www.qcloud.com/document/api/378/4367
获取账户余额示例:
const {TRADE} = require('wqcloud');
// const TRADE = require('wqcloud').TRADE;
const trade = TRADE({
SecretId: 'xxxxx',
SecretKey: 'xxxx'
});
// Within Async Func
(async() => {
const balance = await trade.describeAccountBalance();
console.log(balance);
})();
API文档参考: https://www.qcloud.com/document/api/558/7758
API文档参考: https://www.qcloud.com/document/product/266/7788
基本涵盖所有, 只要检查 API接口访问地址是否类似这样的格式 https://${service}.api.qcloud.com/v2/index.php
即可.
参考项目: https://github.com/AirDwing/wqcloud-video
2018-11-28
支持 v3 接口。
2017-05-11
更新了签名算法,进一步优化代码,将代码行数缩减到82行(含空行)。
2017-01-06
从 waliyun
阿里云SDK修改适配到 QCloud
2016-09-06
- 使用元编程方式进行重构,减少重复代码和
Action
限制; - 更新文档链接。
2016-05-16 解决了签名偶发错误的问题。
MIT
通过支付宝捐赠: