0.0.3 • Published 7 years ago

restful-mikrotik v0.0.3

Weekly downloads
4
License
MIT
Repository
github
Last release
7 years ago

restful-mikrotik

A Restful API server for MikroTik RouterOS.

usage:

% npm install restful-mikrotik
var RestfulMikrotik = require('restful-mikrotik');
var api_server = new RestfulMikrotik({
  host: '10.0.0.1',
  user: 'admin',
  password: 'password',
  listen_port: 8080,
  listen_host: '127.0.0.1'
});

// api_server.stop(); // stop API server.

Constructor of RestfulMikrotik accept an object:

propertiestypedefaultdescription
hoststrRouter address
userstrRouter username
passwordstrRouter password
portint8728Router API port
tlsbool/objectfalseWhen true or object, tls will be enabled. See mikronode document for more infomation
listen_portint8080REST API server listen port
listen_hoststr127.0.0.1REST API server listen address

To query, send a GET request to API server:

% curl http://127.0.0.1:8080/ip/firewall/nat/print
[{".id":"*1","chain":"srcnat","action":"masquerade","out-interface":"ether1" .... 

To use command with parameters, POST a JSON object:

% curl http://127.0.0.1:8080/ip/address/comment -H 'Content-Type: application/json' -X POST -d '{"=numbers": 5, "=comment": "VPN"}'
[] 
# equivalent to "/ip address comment numbers=5 comment=VPN"

To query with condition, POST a JSON object:

% curl http://127.0.0.1:8080/ip/address/print -H 'Content-Type: application/json' -X POST -d '{"?interface": "ether1"}'
[{".id":"*2","address":"172.19.38.45/24","network":"172.19.38.0","interface":"ether1","actual-interface":"ether1","invalid":"false","dynamic":"true","disabled":"false"}]
# equivalent to "/ip address print where interface=ether1"

For more information about query/parameter, see mikrotik wiki.

TODO

  • (Real) TLS fix? - For whatever reason, connection using tls close itself after channel closed, maybe problem with mikronode?
0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago