Datasheet

API Delphi Client
249
begin
ShowMessage('Done');
ResListen.Free;
tmrListen.Enabled := False;
Break;
end;
Memo1.Lines.Add(ResListen['time'] + ': ' + ResListen['message']);
until False;
end;
Downloads and suggestions
For downloads and suggestions see forum thread RouterOS API Delphi Client
[1]
References
[1] http:/ / forum. mikrotik. com/ viewtopic. php?f=9& t=31555& start=0
API Delphi
This document describes a Delphi class to access RouterOs using API interface.
Enable API's in RouterOs devices
By default API interface is disabled in the device, then enable it using the simple command in a terminal connection:
/ip service enable api
Using API: send commands and receive output through the socket
The mikrotik protocol to talk with api interface is well documented in the main page API. You can connect to the
API interface of an RouterOs device using a TCP socket connected to 8728 port.
In this page you can found a Delphi class which encapsulate the details of the connection and give you the ability to
use some simple methods to create applications usin API.
All methods return 0 if the execution is correct (<0 otherwise)
The Delphi class tr_mkrouter
This class is defined in a Delphi unit. I used Delphi 7 but is simple to adapt to other versions. This class publish this
methods:
constructor create(i_logger: TLogger);
Create the object. Passing the object TLogger, enable you to log the activity to a memo control and/or to a file.
function open(ip_router, user, password: string): integer;
Open the socket with the router and executes the login handshake.
function msend(vs: string; fl_execute: boolean): integer;
Send the string vs tho the router (send an api word). If fl_execute=true it concatenate a #0 (send an api sentence)
wich cause the command to be executed.