Node.js阿里云接口(Aliyun API)SDK

WAliyun

npm npm

比官方SDK更好用的阿里云SDK。

Minimum, Flexible, Scalable.

支持Lazy Require。

安装和使用

国际惯例:

1
npm install waliyun --save

公共参数:

1
2
3
4
5
6
7
8
9
10
11
12
13
var options = {
AccessKeyId: 'xxxx-xxxx-xxxx-xxxx',
AccessKeySecret: 'xxxx-xxxx-xxxx-xxxx',
// 选填,不同接口类型注意版本日期
Version: '2014-05-26',
// 选填
SignatureMethod: 'HMAC-SHA1',
Format: 'json',
SignatureVersion: '1.0',
// 每次请求都会自动重新生成
SignatureNonce: Math.random(),
Timestamp: new Date().toISOString()
};

ES5:

1
2
3
4
5
6
7
8
9
10
11
12
var WALIYUN = require('waliyun');
// 加载全部方法
var ecs = WALIYUN.ECS(options);
// 或加载某些方法
var ecs = WALIYUN.ECS(options, ['DescribeInstances', 'DescribeInstanceStatus']);
// 或加载某个方法
var ecs = WALIYUN.ECS(options, 'DescribeInstances');
ecs.describeInstances({
RegionId: 'cn-hangzhou'
}).then(function(instances){
// xxxx
});

ES6:

1
2
3
4
5
6
7
8
9
import {ECS} from 'waliyun';
const ecs = ECS(options);
// Within Async Func
(async() => {
const instances = await ecs.describeInstances({
RegionId: 'cn-hangzhou'
});
// xxxx
});

已支持的接口

Github主页上检查最新版本: https://github.com/willin/waliyun

CDN

API文档参考:

https://help.aliyun.com/document_detail/cdn/api-reference/overview.html

云服务器 ECS

API文档参考:

https://help.aliyun.com/document_detail/ecs/open-api/apisummary.html

云监控 Metrics

API文档参考:

https://help.aliyun.com/document_detail/cms/API_References/New_Metric_OpenAPI_Reference/API_Guide.html

访问控制 RAM

API文档参考:

https://help.aliyun.com/document_detail/ram/ram-api-reference/intro/intro.html

云数据库 RDS

API文档参考:

https://help.aliyun.com/document_detail/rds/OpenAPI-manual/RDS-OpenAPI-Invoke/API-catalog.html

访问控制 STS

API文档参考:

https://help.aliyun.com/document_detail/ram/sts-api-reference/intro.html

便于鸣谢,捐赠请留下网名~