Mikrotik's RouterOS v7 REST API python module
Not all types and methods of the RouterOS v7 REST API are supported, yet. Finding any bugs? Please Create Issue
You can install or upgrade rosrestpy with:
pip install rosrestpy --upgradefromrosimportRos# Initiate Ros objectros=Ros("https://192.168.88.1/", "admin", "")
# Check cpu loadifros.system.resource.cpu_load>90:
print(f"{ros.system.identity}'s CPU > 90%")
# Print all interface nameforinterfaceinros.interface():
print(interface.name)
# Finding specific queuequeues=ros.queue.simple(name="Hotspot")
iflen(queues) ==1:
queue=queues[0]
print(f"Usage {queue.bytes}")
# Adding new /simple/queuefromros.queueimportSimpleQueuenew_queue=SimpleQueue(name="Test", target="192.168.88.0/24", max_limit="10M/10M", disabled=True)
new_queue=ros.queue.simple.add(new_queue)
print(new_queue)
# Updating /simple/queuetest_queue=ros.queue.simple(name="Test")[0]
new_test_queue=ros.queue.simple.set(test_queue, {"comment": "Test comment"})
print(new_test_queue)
# Deleting /simple/queuetest_queue=ros.queue.simple(name="Test")[0]
ros.queue.simple.delete(test_queue)
# Using /tool/bandwith-testbw_tests=ros.tool.bandwith_test("172.16.0.1", "3s", "admin", direction="both")
result_bw_test=bw_tests[-1]
print(f"Download {result_bw_test.rx_total_average}")
print(f"Upload {result_bw_test.tx_total_average}")The RouterOS REST API is the technical reference for rosrestpy.
Contributions of all sizes are welcome. Please review our contribution guidelines to get started. You can also help by reporting bugs or feature requests.
Big thanks to attrs and cattrs as the bases of rosrestpy, without them this module creation would be very tedious!