context = ssl.create_default_context() api_ssl = librouteros.connect( host='192.168.88.1', username='admin', password='your_password', port=8729, ssl_wrapper=context.wrap_socket )
const RouterOSAPI = require('node-routeros'); const conn = new RouterOSAPI( host: '192.168.88.1', user: 'api_user', password: 'SecurePassword123', port: 8728 ); async function addStaticLease() try await conn.connect(); // Build the command and its arguments const result = await conn.write('/ip/dhcp-server/lease/add', 'address': '192.168.88.250', 'mac-address': 'AA:BB:CC:DD:EE:FF', 'comment': 'Automated API Lease Assignment', 'disabled': 'no' ); console.log('Lease added successfully. ID assigned:', result); catch (err) console.error('Error executing API command:', err); finally await conn.close(); addStaticLease(); Use code with caution. PHP: Managing Firewall Rules mikrotik api examples
reply, _ := client.Run("/interface/print", "=.proplist=name,running") for _, re := range reply.Re fmt.Printf("Interface: %s, Running: %s\n", re.Attributes["name"], re.Attributes["running"]) context = ssl
# Send command sock.send(cmd.encode() + b'\n\n') # Read response until !done result = [] while True: chunk = sock.recv(4096).decode() result.append(chunk) if '!done' in chunk: break sock.close() return ''.join(result) import RouterOSClient from '@sourceregistry/mikrotik-client'
This code creates a new user with the name newuser , password newpassword , and group admin .
import RouterOSClient from '@sourceregistry/mikrotik-client';
api.close()
We use Google cookies to:
If you do not wish for this data to be collected or shared with Google, you can opt-out by clicking the button below.