Mikrotik Api Examples

Top

Mikrotik Api Examples

Mikrotik Api Examples

Mikrotik Api Examples

Mikrotik Api Examples

Mikrotik Api Examples

/ip service enable api-ssl

/ip/address/print /ip/address/add =address=10.0.0.1/24 =interface=ether1 /ip/address/set =.id=*1 =address=10.0.0.2/24 /ip/address/remove =.id=*1

Using the mikrotik-api Python library, you can retrieve device information as follows:

const Mikronode = require('mikronode'); const device = new Mikronode('192.168.88.1'); device.connect() .then(([login]) => return login('admin', 'YourSecurePassword'); ) .then((conn) => // Open a channel for streaming data const chan = conn.openChannel('traffic_monitor'); // Execute the monitor traffic command chan.write('/interface/monitor-traffic', 'interface': 'ether1', 'once': '' // Remove this parameter to stream continuously ); chan.on('done', (packet) => const data = packet.data[0]; console.clear(); console.log(`=== Real-time Traffic Monitor: ether1 ===`); console.log(`Rx Bits Per Second: $(parseInt(data['rx-bits-per-second']) / 1000000).toFixed(2) Mbps`); console.log(`Tx Bits Per Second: $(parseInt(data['tx-bits-per-second']) / 1000000).toFixed(2) Mbps`); ); chan.on('trap', (error) => console.error('API Error: ', error); ); ) .catch((err) => console.error('Connection Error: ', err); ); Use code with caution. 6. API Error Handling and Best Practices

When the router receives and processes a sentence, it returns one or more replies: