
API command notes
177
result of double Tab
[admin@MikroTik] > ip address add
broadcast comment copy-from disabled netmask network address interface
Note: Not all attributes will have full or precise description in CLI, but all attributes will have precise and full
description of values accepted by attribute
Building API sentence:
/ip/address/add
=address=192.168.88.1/24
=interface=ether1
Result of execution of this command will be IP address added on interface ether1 same as in CLI.
Note: If command in CLI does not have named attribute using ? key you can get required attribute name.
Atribute that is not named will appear in between <>
API attributes
API has some special attributes, that are not available through CLI, or are not available through
CLI directly. These atributes starts with dot. For example .id, that gives identification number of the item, whilst
these can be seen in CLI (returned by find) ID is not directly shown with the item.
API command attributes
All attributes of command starts with equals sigh, whilst special case for API attribute to command itself. Like .tag
attribute that is not part of any command, but can be used to identify returned data of command executed.
Atributes without value
Commands in RouterOS have attributes that does not have any value set, If these attributes are used it just indicates
that they should be used, and value, if any is given will be ignored.
For example, indicate that we will follow IP address changes:
/ip/address/print
=follow=
See the equals marks surrounding follow - they should be there as attribute should be between them.
API sentence structure
API sentence should be sent in very specific form. About precise descriptions please see API. If you are not going to
write your own API implementations or, you do not understand exactly how it should be created, here is the
explanation:
•• API sentence can consist of several lines (or words);
•• when sent to router each word have to have a prefix, that have to be made in a specific way encoding length of the
word;
•• last word in API sentence have to be zero terminated (have to contain byte set to all zeros). Also, if sentence only
contains one word, it has to be zero terminated, or else router will wait for further words in that sentence, and all
other words will be counted as words from same sentence, not new sentence.
Commenti su questo manuale