Community discussions

 
cblyseth
just joined
Topic Author
Posts: 2
Joined: Mon Mar 21, 2011 8:08 pm

Concise list of API supported commands?

Mon Aug 08, 2011 11:48 pm

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...
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 5919
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: Concise list of API supported commands?

Tue Aug 09, 2011 8:43 am

All commands are supported, except find.
_Please read:
http://wiki.mikrotik.com/wiki/API
http://wiki.mikrotik.com/wiki/API_command_notes
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6283
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: Concise list of API supported commands?

Tue Aug 09, 2011 9:19 am

added some more stuff to
http://wiki.mikrotik.com/wiki/API_command_notes

hope this makes it more clear that was before
 
cblyseth
just joined
Topic Author
Posts: 2
Joined: Mon Mar 21, 2011 8:08 pm

Re: Concise list of API supported commands?

Tue Aug 09, 2011 6:50 pm

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
 
User avatar
janisk
MikroTik Support
MikroTik Support
Posts: 6283
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: Concise list of API supported commands?

Wed Aug 10, 2011 11:51 am

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.
 
User avatar
LatinSuD
Member Candidate
Member Candidate
Posts: 174
Joined: Wed Jun 29, 2005 1:05 pm
Location: Spain
Contact:

Re: Concise list of API supported commands?

Fri Aug 09, 2019 1:15 pm

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?

Who is online

Users browsing this forum: No registered users and 6 guests