This topic describes how to install the RAM SDK for Node.js. It also provides an example about how to use the SDK.

Install the RAM SDK for Node.js

Run the following npm command: npm install aliyun-sdk.

Use the RAM SDK for Node.js

The following sample code uses the RAM SDK for Node.js to create a RAM user.

ALY = require("aliyun-sdk")

// Construct an Alibaba Cloud client. The client will be used to send a request.
// When you construct the client, set the AccessKey ID and AccessKey secret.
// RAM is a global service. However, the RAM API endpoint is located in the China (Hangzhou) region. The sample code uses the primary endpoint of the RAM API.
var ram = new ALY.RAM({
        accessKeyId: "<access-key-id>",
        secretAccessKey: "<access-key-secret>",
        endpoint: 'https://ram.aliyuncs.com',
        apiVersion: '2015-05-01'
});

// Construct a CreateUser request.
ram.createUser({
        Action: 'CreateUser',
        UserName: "alice"
}, function (err, res) {
        console.log(err, res);
});