For better security, it is highly recommended to create a dedicated API user with restricted permissions rather than using the default admin account. 2. Python API Example (RouterOS v6 & v7)
# Conceptual example of sending a command to get all IP addresses /ip/address/print .proplist=address,interface Use code with caution. Copied to clipboard REST API (RouterOS v7+) The REST API uses standard HTTP methods ( ) and JSON. List Addresses (GET) curl -k -u admin:password https://192.168.88 Add an IP (POST)
def create_voucher_user(voucher_code, minutes_valid=60, profile="default"): hotspot = api.get_resource('/ip/hotspot/user') expiry = (datetime.now() + timedelta(minutes=minutes_valid)).strftime('%Y-%m-%d %H:%M:%S')
# 1. Add DHCP static lease api('/ip/dhcp-server/lease/add', 'mac-address': client_mac, 'address': client_ip, 'server': 'dhcp1', 'comment': client_name ) print(f"DHCP lease added for client_name")
<?php
For better security, it is highly recommended to create a dedicated API user with restricted permissions rather than using the default admin account. 2. Python API Example (RouterOS v6 & v7)
# Conceptual example of sending a command to get all IP addresses /ip/address/print .proplist=address,interface Use code with caution. Copied to clipboard REST API (RouterOS v7+) The REST API uses standard HTTP methods ( ) and JSON. List Addresses (GET) curl -k -u admin:password https://192.168.88 Add an IP (POST) mikrotik api examples
def create_voucher_user(voucher_code, minutes_valid=60, profile="default"): hotspot = api.get_resource('/ip/hotspot/user') expiry = (datetime.now() + timedelta(minutes=minutes_valid)).strftime('%Y-%m-%d %H:%M:%S') For better security, it is highly recommended to
# 1. Add DHCP static lease api('/ip/dhcp-server/lease/add', 'mac-address': client_mac, 'address': client_ip, 'server': 'dhcp1', 'comment': client_name ) print(f"DHCP lease added for client_name") For better security
<?php