Skip to main content

RouterOS v7 REST API python module

Project description

RosRestPy

PyPi Package Version Supported Python versions LICENSE

Mikrotik's RouterOS v7 REST API python module

RouterOS v7 REST API Support

Check Here for API Support.

Not all types and methods of the RouterOS v7 REST API are supported, yet. Finding any bugs? Please Create Issue

Installing

You can install or upgrade rosrestpy with:

pip install rosrestpy --upgrade

Example

from ros import Ros

# Initiate Ros object
ros = Ros("https://192.168.88.1/", "admin", "")


# Check cpu load
if ros.system.resource.cpu_load > 90:
    print(f"{ros.system.identity}'s CPU > 90%")

# Print all interface name
for interface in ros.interface():
    print(interface.name)

# Finding specific queue
queues = ros.queue.simple(name="Hotspot")
if len(queues) == 1:
    queue = queues[0]
    print(f"Usage {queue.bytes}")

# Adding new /simple/queue
from ros.queue import SimpleQueue
new_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/queue
test_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/queue
test_queue = ros.queue.simple(name="Test")[0]
ros.queue.simple.delete(test_queue)

# Using /tool/bandwith-test
bw_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}")

Resources

The RouterOS REST API is the technical reference for rosrestpy.

Contributing

Contributions of all sizes are welcome. Please review our contribution guidelines to get started. You can also help by reporting bugs or feature requests.

Open Source Notice

Big thanks to attrs and cattrs as the bases of rosrestpy, without them this module creation would be very tedious!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rosrestpy-0.12.2.tar.gz (43.6 kB view details)

Uploaded Source

Built Distribution

rosrestpy-0.12.2-py3-none-any.whl (74.9 kB view details)

Uploaded Python 3

File details

Details for the file rosrestpy-0.12.2.tar.gz.

File metadata

  • Download URL: rosrestpy-0.12.2.tar.gz
  • Upload date:
  • Size: 43.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.8.18 Linux/6.5.0-1023-azure

File hashes

Hashes for rosrestpy-0.12.2.tar.gz
Algorithm Hash digest
SHA256 907f4874873d03e23303aa143f19feeb8b96ff8a3e8ca358794d53691cef4714
MD5 c34b62e76bba67fa8d35ff2716eed760
BLAKE2b-256 f7568ff4070105c76da6b95590a0db9cebfcf37e3a450cf2aebc50956be25c6a

See more details on using hashes here.

File details

Details for the file rosrestpy-0.12.2-py3-none-any.whl.

File metadata

  • Download URL: rosrestpy-0.12.2-py3-none-any.whl
  • Upload date:
  • Size: 74.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.8.18 Linux/6.5.0-1023-azure

File hashes

Hashes for rosrestpy-0.12.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7f5cb57e6df9692c18058064c9c4fda19ca54fe450e800180735e50fa3159ad2
MD5 43eaa5a0efb2b0b693b9adda106f9711
BLAKE2b-256 9448e66f6b016deafde5222aba0cc371b136ef33a9045129e32b68acff2ce361

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page