Skip to main content

Python implementation of MikroTik RouterOS API

Project description

Tests Latest PyPI version Supported Python Versions License

About

Python implementation of routeros api. This library uses semantic versioning. On major version things may break, so pin version in dependencies.

Usage

In [1]: from librouteros import connect

In [2]: api = connect(host='192.168.56.200', username='admin', password='abc')

In [4]: api(cmd='/interface/print', stats=True)
Out[4]:
  ({'.id': '*1',
  'bytes': '418152/157562',
  'comment': '',
  'disabled': False,
  'drops': '0/0',
  'dynamic': False,
  'errors': '0/0',
  'mtu': 1500,
  'name': 'ether1',
  'packets': '3081/1479',
  'running': True,
  'type': 'ether'},)

In [5]: api(cmd='/interface/print')
Out[5]:
  ({'.id': '*1',
  'comment': '',
  'disabled': False,
  'dynamic': False,
  'mtu': 1500,
  'name': 'ether1',
  'running': True,
  'type': 'ether'},)

In [7]: api.close()

In [8]:

If you want to pass parameters that strart with a dot character you can do it in this way:

params = {'disabled': True, '.id' :'7'}
api(cmd='/ip/firewall/nat/set', **params)

Python booleans are converted according to this table:

python

direction

api

False

<-

false,no

True

<-

true,yes

False

->

no

True

->

yes

Contributing

To submit a feature requests or a bug report, please use issues from within github. If you would like to submit a patch please contact author or use pull request.

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

librouteros-1.0.2.tar.gz (6.2 kB view hashes)

Uploaded Source

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