API wrapper/client for Asus WRT routers/access points
All async methods return promise based types and can be awaited.
import { AsusWRT } from "node-asuswrt";
const config = {
Username: 'admin',
Password: 'password',
BaseUrl: 'http://192.168.1.1',
ErrorLogCallback: (logDescription, logData) => { // optional property
if (logData) {
console.log(logDescription, logData);
} else {
console.log(logDescription);
}
},
InfoLogCallback: (logDescription, logData) => { // optional property
if (logData) {
console.log(logDescription, logData);
} else {
console.log(logDescription);
}
}
}
const asus = new AsusWRT.AsusWRT(config);
asus.getWANStatus().then(result => {
console.log(result);
});
asus.getTotalTrafficData().then(result => {
console.log('traffic', result);
})
asus.getRouters().then(result => {
result.forEach(router => {
asus.getCPUMemoryLoad(router.mac).then(result => {
console.log('load', result);
});
asus.getUptime(router.mac).then(result => {
console.log('uptime', result);
});
asus.setLedsEnabled(router.mac, true).then(success => {
console.log(success);
});
asus.getWirelessClients(router.mac, "2G").then(wiredClients => {
console.log(router.alias, wiredClients);
});
})
});
import { AsusWRT } from "node-asuswrt";
const config = {
Username: 'admin',
Password: 'password',
BaseUrl: 'http://192.168.1.1',
ErrorLogCallback: (logDescription, logData) => { // optional
if (logData) {
console.log(logDescription, logData);
} else {
console.log(logDescription);
}
},
InfoLogCallback: (logDescription, logData) => { // optional
if (logData) {
console.log(logDescription, logData);
} else {
console.log(logDescription);
}
}
}
const asus = new AsusWRT.AsusWRT(config);
asus.getRouters()
asus.getWirelessClients(router.mac, "2G") // 2.4ghz devices
asus.getWirelessClients(router.mac, "5G") // 5ghz devices
asus.getWiredClients(router.mac)
asus.setLedsEnabled(router.mac, true) // turns leds on
asus.setLedsEnabled(router.mac, false) // turns leds off
asus.rebootNetwork()
asus.rebootDevice(router.mac);
asus.getCPUMemoryLoad(router.mac) // requires mac of router / access point
asus.getUptime(router.mac) // requires mac of router / access point
asus.getTotalTrafficData()
// poll this function to get realtime data usage for example 2 seconds interval and calculate difference
asus.getWANStatus()
asus.getWakeOnLanList()
asus.wakeOnLan(wakeOnLanDeviceMac)
// `npm install fs.promises` for writeFile
asus.exportCertificate().then(result => {
writeFile('./cert_key.tar', result);
});
{
ip: string,
mac: string,
name: string,
nickName: string,
dpiDevice: string,
vendor: string,
ipMethod: string,
rssi: number
}
{
CPUUsagePercentage: number,
MemoryUsagePercentage: number
}
{
Router: 0,
AccessPoint: 1
}
{
alias: string,
modelName: string,
uiModelName: string,
productId: string,
firmwareVersion: string,
newFirmwareVersion: string,
ip: string,
mac: string,
online: boolean,
operationMode: AsusWRTOperationMode
}
{
trafficReceived: number;
trafficSent: number;
}
{
status?: number;
statusstr?: string;
type?: string;
ipaddr?: string;
netmask?: string;
gateway?: string;
dns?: string;
lease?: number;
expires?: number;
xtype?: string;
xipaddr?: string;
xnetmask?: string;
xgateway?: string;
xdns?: string;
xlease?: number;
xexpires?: number;
}
{
name: string,
mac: string
}