Is there is list of supported RouterOS API commands or a way to know a command is not supported?
For instance, I’d like to know if I can create or update static DNS entries using the API.
Thanks in advance…
Is there is list of supported RouterOS API commands or a way to know a command is not supported?
For instance, I’d like to know if I can create or update static DNS entries using the API.
Thanks in advance…
All commands are supported, except find.
_Please read:
http://wiki.mikrotik.com/wiki/API
http://wiki.mikrotik.com/wiki/API_command_notes
added some more stuff to
http://wiki.mikrotik.com/wiki/API_command_notes
hope this makes it more clear that was before
Yes, that is a good clarification. I think I just stumbled on a key point of API information (which is really a basic computing fact). Maybe this info can help the next guy…
It was confusing to this API newcomer that some set commands allow look-up by name while others only allow look-up by ID. For instance, the examples show using =.id=name for setting interface parameters. For interfaces that make sense since duplicate interface names are not allowed and look-up by name would not be ambiguous. Static DNS entries on the other hand allow multiple entries with the same name which makes look-up and setting by name impossible (or at least could lead to inconsistent behavior). Better to parse and handle these in a defined manner.
Example setting (updating existing) static DNS entry via API
We read the static DNS entry via the API:
/ip/dns/static/print
?name=a.b.com
=.proplist=.id,name,address
Which results in…
!re
=.id=*3
=name=a.b.com
=address=4.4.4.4
Now we change the IP address for this entry
This will work (targets one specific record):
/ip/dns/static/set
=.id=*3
=address=5.5.5.5
This will not work since more than one ‘a.b.com’ may exist
/ip/dns/static/set
=.id=a.b.com
=address=5.5.5.5
this is why value of name attribute cannot be set as value for .id due to ambiguity.
/ip/dns/static/set
=.id=a.b.com
=address=3.3.3.3
!trap
=category=0
=message=no such item
/ip/dns/static/print
?name=a.b.com
=.id=*4
=name=a.b.com
=address=2.2.2.2
thanks for the good find. will update example page.
Sorry, but how do I know the complete list of commands?
I would like to do backups using API, and for that i’d need to enumerate the whole configuration tree.
/interface/ethernet
/interface/queue
/queue/interface
...
Is it possible to know this list in advance using API?