This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

MikroTik API Lua library
#1
Use attached code to create a user library named mikrotik.
Make sure that your router is running at least v6.43.
It is recommended to create a separate user for api access, possibly with limited read-only access if you don't need to change anything on the router remotely.

Example:
Code:
mt, err = require('user.mikrotik').new('192.168.1.1')

if mt then
  res, err = mt:login('api', '123456') -- user api, pass 123456

  if res then
    -- get wireless registration table
    res, err = mt:readlist('/interface/wireless/registration-table/print')
    log(res)
  else
    log('login failed', tostring(err))
  end

  mt:close()
else
  log('connect failed', tostring(err))
end

Attached Files
.lua   mikrotik.lua (Size: 3.85 KB / Downloads: 46)
Reply


Messages In This Thread
MikroTik API Lua library - by admin - 20.10.2020, 06:57
RE: MikroTik API Lua library - by FatMax - 20.10.2020, 11:48
RE: MikroTik API Lua library - by admin - 20.10.2020, 12:13
RE: MikroTik API Lua library - by DGrandes - 03.12.2020, 17:45
RE: MikroTik API Lua library - by admin - 04.12.2020, 07:35
RE: MikroTik API Lua library - by DGrandes - 07.12.2020, 13:11
RE: MikroTik API Lua library - by admin - 07.12.2020, 13:49
RE: MikroTik API Lua library - by DGrandes - 07.12.2020, 15:03
RE: MikroTik API Lua library - by admin - 09.12.2020, 07:19
RE: MikroTik API Lua library - by DGrandes - 09.12.2020, 08:09
RE: MikroTik API Lua library - by FatMax - 07.01.2021, 23:20
RE: MikroTik API Lua library - by Igori - 10.01.2021, 15:45
RE: MikroTik API Lua library - by admin - 11.01.2021, 08:07
RE: MikroTik API Lua library - by Igori - 11.01.2021, 19:50
RE: MikroTik API Lua library - by edgars - 26.08.2021, 08:28

Forum Jump: