Community discussions

MikroTik App
 
User avatar
janisk
MikroTik Support
MikroTik Support
Topic Author
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

API Links

Thu Jan 15, 2009 12:54 pm

API implementations in different programming languages from users of this forum:

in Perl - forum thread by cheesegrits
in Delphi - forum thread and wiki by rodolfo
in Delphi #2 - forum thread by Chupaka
in PHP - external by Denis Basta and contributors
Java sample methods - forum post
in Python - wiki link by Mikrotik staff
in C# - wiki link by wiki user Gregy
Ruby on rails wiki and discussion on forum(v1.9) - by astounding
in Adobe Flash - wiki by haakon
in C - wiki by webasdf
in C (GPL2 license) -wiki by octo
.NET (C#) discussion on forum - external by danikf
in NodeJS - by trakkasure
in C++17 by Ayman Al-Qadhi

API related information links:
http://wiki.mikrotik.com/wiki/API
http://wiki.mikrotik.com/wiki/API_command_notes
 
User avatar
normis
MikroTik Support
MikroTik Support
Posts: 26288
Joined: Fri May 28, 2004 11:04 am
Location: Riga, Latvia

Re: API examples

Thu Jan 15, 2009 1:01 pm

it would be great if all of them would be in the wiki. the owners would also get RouterOS licenses!
 
rodolfo
Long time Member
Long time Member
Posts: 553
Joined: Sat Jul 05, 2008 11:50 am

Re: API examples

Sun Jan 18, 2009 1:09 pm

 
User avatar
normis
MikroTik Support
MikroTik Support
Posts: 26288
Joined: Fri May 28, 2004 11:04 am
Location: Riga, Latvia

Re: API examples

Mon Jan 19, 2009 8:57 am

cool! email support to get your RouterOS license
 
rodolfo
Long time Member
Long time Member
Posts: 553
Joined: Sat Jul 05, 2008 11:50 am

Re: API examples

Wed Jan 21, 2009 2:07 pm

Thanks a lot!
 
haakon
just joined
Posts: 19
Joined: Sat May 02, 2009 6:02 pm

Re: API examples

Sat May 02, 2009 11:08 pm

Hi,

I've just made, and published Adobe Flash ActionScript 3 class for RouterOS API

http://wiki.mikrotik.com/wiki/API_ActionScript_3_class
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8709
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: API examples

Mon May 04, 2009 8:55 pm

Janis, please add link to my topic =)

http://forum.mikrotik.com/viewtopic.php?f=9&t=31555
 
User avatar
normis
MikroTik Support
MikroTik Support
Posts: 26288
Joined: Fri May 28, 2004 11:04 am
Location: Riga, Latvia

Re: API examples

Tue May 05, 2009 8:55 am

 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8709
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: API examples

Tue May 05, 2009 12:58 pm

thanks, Normis. and add the Wiki, please =)

http://wiki.mikrotik.com/wiki/API_Delphi_Client
 
User avatar
DogHead
Member Candidate
Member Candidate
Posts: 196
Joined: Thu Jan 03, 2008 9:36 pm
Location: Anywhere you want me to be

Re: API examples

Wed May 27, 2009 1:06 am

The examples, etc using the API are great. We are already trying to write our own simplified interface for end users in Delphi based on the examples provided, but it is a major pain for us to learn Delphi (java, ruby or any other programming language for that matter). Even python is tough if you want to make a GUI and are not a programmer.

Before we spend a lot of time re doing what someone else has already accomplished (TowNet, Mikrocontrol, etc), I was wondering if there is someone who already has developed an open, simple windows client, like winbox, but designed for end users so they can simply specify a few parameters without having to understand the entire RouterOS. Source code? We are looking for a complete example that could be easily tweaked.

Webbox is close to what we want, but since you cannot change it's functionality, it is not going to do what we need.

With the introduction of LUA in v4, will we be able to port something like Gargoyle or LUCI onto RouterOS? This would be an interface that is customizable by us mere mortals (ISP guys with limited programming skills). LUA is close enough to simple scripting that we can figure it out and customize it ourselves. Of course you would need to be able to upload the LUA pages to a web server on the device in order for this to work.
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8709
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: API examples

Wed May 27, 2009 1:19 am

We are already trying to write our own simplified interface for end users
what functionality do you need?
 
User avatar
DogHead
Member Candidate
Member Candidate
Posts: 196
Joined: Thu Jan 03, 2008 9:36 pm
Location: Anywhere you want me to be

Re: API examples

Wed May 27, 2009 1:54 am

We would want to be able to:

1. Add/enable bridge or mesh interface
a. Bond interfaces into bridge or mesh
b. For bridge turn on or off RTSP
c. For mesh make portal node
2. Configure wireless
a. Set mode, band, frequency, SSID
b. Enable Nstreme
c. Enable WPA and set PSK
3. IP/Routing/NAT
a. Apply IP address and mask to interface
b. Enable NAT and set public interface
c. Set up port forwarding
d. Enable DMZ (one host for port forwarding) and set address
e. Set default gateway
f. Add/delete static routes
4. DHCP
a. Enable server on interface with range, default gw, and dns server
b. Enable client on interface
5. Administration
a. Set password
b. Set system ID
c. Set time zone and time
d. Enable and set NTP

All values would populate from the running configuration of the router. Apply would change only values that were altered. The rest of the detailed set up would be done via winbox or telnet by an administrator. If there were even more configuration available, but we had the option of editing the source to delete out the functions we don't need for a particular type of user, it would be really cool. Maybe the ability to reset and run a script would be good. Still thinking about it.

This is the kind of application I think a lot of people want, but none of us has either the programming skill or the money to pay for development. Once an example is made, I bet you would have all sorts of variants. Your API test interface was good, but didn't really go far enough in showing how edits would work, etc.

Any help on this would be really appreciated.

Would look something like the attached:
You do not have the required permissions to view the files attached to this post.
 
User avatar
cholegm
Frequent Visitor
Frequent Visitor
Posts: 57
Joined: Thu Jul 19, 2007 7:43 pm
Location: Gornji Milanovac, Serbia
Contact:

Re: API examples

Thu May 28, 2009 11:43 am

Can anybody make the API for VB (for VB projects and ASP pages)?!



Thanks,
Mladen
 
ayufan
Member
Member
Posts: 334
Joined: Sun Jun 03, 2007 9:35 pm
Contact:

Re: API examples

Tue Jun 23, 2009 4:05 pm

Use C# code ;)
 
User avatar
tgrand
Long time Member
Long time Member
Posts: 667
Joined: Mon Aug 21, 2006 2:57 am
Location: Winnipeg, Manitoba, Canada

Re: API examples

Mon Jul 27, 2009 10:59 pm

There is a vb.net sample on the forums.
Do a search
 
hgmamaci
just joined
Posts: 6
Joined: Wed Jul 15, 2009 9:14 pm

Re: API examples

Fri Aug 14, 2009 11:57 am

We would want to be able to:
Could you find anything on this? Can you please share if you had.

Thanks
 
User avatar
DogHead
Member Candidate
Member Candidate
Posts: 196
Joined: Thu Jan 03, 2008 9:36 pm
Location: Anywhere you want me to be

Re: API examples

Fri Aug 21, 2009 9:00 am

No word from anyone on this.

We would love to see someone come up with a good working solution.
 
User avatar
webasdf
Frequent Visitor
Frequent Visitor
Posts: 87
Joined: Mon Jan 26, 2009 6:37 pm

Re: API examples

Tue Oct 13, 2009 6:23 am

I'm working on an API client in C at the moment (for implementation in an openWRT metarouter). Has this been done yet? I don't want to re-invent the wheel, especially since my C is really rusty.

So many seg faults so little time :)
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7038
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: API examples

Tue Oct 13, 2009 8:04 am

http://wiki.mikrotik.com/wiki/MUM_2009_CZ
Look for API SDK by Townet, Italy
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8709
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: API examples

Tue Oct 13, 2009 2:19 pm

DogHead, you have nice screenshot - what's problem? you now just need a bit of coding =) can you share that form? p.s. is it Delphi?
 
User avatar
webasdf
Frequent Visitor
Frequent Visitor
Posts: 87
Joined: Mon Jan 26, 2009 6:37 pm

Re: API examples

Tue Oct 13, 2009 3:41 pm

I did previously find API SDK by Townet, Italy, but they only published object files and headers. I need source code in order to cross compile for openWrt in MetaRouter. BTW, I will post it when I get it finished.
 
User avatar
webasdf
Frequent Visitor
Frequent Visitor
Posts: 87
Joined: Mon Jan 26, 2009 6:37 pm

Re: API examples

Thu Oct 15, 2009 1:35 am

C implementation of the API attached. If anybody wants to check my work, comments are welcome.

Enjoy!
You do not have the required permissions to view the files attached to this post.
 
User avatar
janisk
MikroTik Support
MikroTik Support
Topic Author
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: API examples

Thu Oct 15, 2009 11:53 am

webasdf, thank you for your addition.

code is clearly written and easy to read.

If you could make wiki article with your source and some explanation you could even get some benefits. you can read that in this post by normis
 
User avatar
webasdf
Frequent Visitor
Frequent Visitor
Posts: 87
Joined: Mon Jan 26, 2009 6:37 pm

Re: API examples

Thu Oct 29, 2009 6:22 pm

webasdf, thank you for your addition.

code is clearly written and easy to read.

If you could make wiki article with your source and some explanation you could even get some benefits. you can read that in this post by normis
Silly question. I went to start an article on the wiki about my C implementation of the API. I can't find the sign-up page to create an account on the wiki site. I have several important changes to make to my implementation and want to get them documented. Is there a signup page or do I need to e-mail someone about creating an account on the wiki?
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8709
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: API examples

Fri Oct 30, 2009 1:51 am

yeah, the registration of new accounts is blocked:
Permissions Errors

You do not have permission to create this user account, for the following reason:

The action you have requested is limited to users in the group: Administrators.
who broke the Wiki? ))
 
User avatar
normis
MikroTik Support
MikroTik Support
Posts: 26288
Joined: Fri May 28, 2004 11:04 am
Location: Riga, Latvia

Re: API examples

Fri Oct 30, 2009 9:50 am

why do you need another account?

wiki registration was temporatily blocked because of spam attacks, we will try to solve it, and turn it on later today
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8709
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: API examples

Fri Oct 30, 2009 2:38 pm

webasdf needs his first account - and cannot register %)
 
User avatar
normis
MikroTik Support
MikroTik Support
Posts: 26288
Joined: Fri May 28, 2004 11:04 am
Location: Riga, Latvia

Re: API examples

Fri Oct 30, 2009 2:45 pm

OK I will turn on registration now
 
User avatar
webasdf
Frequent Visitor
Frequent Visitor
Posts: 87
Joined: Mon Jan 26, 2009 6:37 pm

Re: API examples

Fri Oct 30, 2009 3:07 pm

OK I will turn on registration now
Thanks for opening registration on the wiki. I was able to make an account.
 
User avatar
normis
MikroTik Support
MikroTik Support
Posts: 26288
Joined: Fri May 28, 2004 11:04 am
Location: Riga, Latvia

Re: API examples

Fri Oct 30, 2009 3:15 pm

does anyone know any better spam protection plugins for mediawiki ;) ? REcaptcha is not stopping them anymore.
 
User avatar
webasdf
Frequent Visitor
Frequent Visitor
Posts: 87
Joined: Mon Jan 26, 2009 6:37 pm

Re: API examples

Sat Oct 31, 2009 4:25 pm

does anyone know any better spam protection plugins for mediawiki ;) ? REcaptcha is not stopping them anymore.
I manage a PHPBB forum sometimes. On our registration form, we have CAPTCHA as well as a basic question, "What color is the sky?" I read somewhere that simple questions like that can fool most spambots. If you can add a simple mandatory field (so that you can't register w/o selecting the right answer) on your reg form like that, it may work for you. It seems to have worked for us.
 
User avatar
webasdf
Frequent Visitor
Frequent Visitor
Posts: 87
Joined: Mon Jan 26, 2009 6:37 pm

Re: API examples

Mon Nov 02, 2009 5:58 am

webasdf, thank you for your addition.

code is clearly written and easy to read.

If you could make wiki article with your source and some explanation you could even get some benefits. you can read that in this post by normis
Made some modifications to my C implementation. It has been successfully tested with 1, 2 and 3-byte encoded length fields (the logic should also work w/ 4-byte lengths). Also supports little endian AND big endian CPU architectures. Here's a link. API in C Wiki Article
 
User avatar
janisk
MikroTik Support
MikroTik Support
Topic Author
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: API examples

Mon Nov 02, 2009 9:18 am

nice article webasdf, please write to support@mikrotik.com so we can give you well earned RouterOS license.
 
User avatar
janisk
MikroTik Support
MikroTik Support
Topic Author
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: API examples

Mon Nov 30, 2009 12:47 pm

we have 2 new additions from ayfan in PHP and Octo in C
 
xezen
Long time Member
Long time Member
Posts: 628
Joined: Fri May 30, 2008 10:23 am
Location: South Africa

Re: API examples

Tue Dec 01, 2009 7:27 am

im new to api and codeing and looking for advice

i think php would work for me

what i am trying to get is read the gps connected to the serial port of a mikrotik

so i will have a gsp connected to serial and my api will read it!

put i cant seem to get the gps data up can some one point me to the line were i call the gpsdata up please
 
User avatar
janisk
MikroTik Support
MikroTik Support
Topic Author
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: API examples

Tue Dec 01, 2009 9:03 am

are you able to read that information in console? with what command?
 
xezen
Long time Member
Long time Member
Posts: 628
Joined: Fri May 30, 2008 10:23 am
Location: South Africa

Re: API examples

Tue Dec 01, 2009 3:04 pm

i have a a gsp connected to console and on the routerboard i set remoter accesson a port
to connect to the serial

example

gps-----serail on routerboard-------wireless

on the routerboard i set a remote to seial connection

so i get this
x.x.x.x:5000

in internet explore


if i type in x.x.x.x:5000 it shows me a webpage with all datat comming off the gps

then with my oracle database i read and store the data


then i use geoserver and oracle and google earth to give me my live gps feeds as long as my wireless stays up

took some time to get this setup running
 
csickles
Forum Guru
Forum Guru
Posts: 1255
Joined: Fri May 28, 2004 8:46 pm
Location: Phoenix, AZ
Contact:

Re: API Links

Fri Sep 10, 2010 7:39 pm

Cool.............

I just snagged a copy of the C# code and compiled it into a DLL...

For those like me who dont do C#, but do VB,,

Here is a DLL (It is un-altered from the WIKI (Except a referance to system.socket))

Reference it in Your VB project like so...

    Private Sub btnGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGo.Click
        Dim sStatus As String = ""
        Dim MTK As New MikroTikAPI.MK("10.0.0.3")

        Me.rtInfo.Text = ""
        If MTK.Login("Your-UserID-Here", "Your-Password-Here") Then

            MTK.Send("/ip/address/print")
            'MTK.Send("/ping")
            'MTK.Send("=address=10.0.0.1")
            'MTK.Send("=count=1")
            'MTK.Send("/interface/wireless/registration-table/print")
            MTK.Send(".tag=sss", True)

            For Each sStatus In MTK.Read
                Me.rtInfo.Text = Me.rtInfo.Text + vbCr + sStatus
            Next
        Else
            Me.rtInfo.Text = "Login Error. Correct User / Password"
        End If
        MTK = Nothing
        sStatus = Nothing
    End Sub

This will get you started..

Remember that the return is sent back as a list object, so you need to cycle thru it as in the above example..

The Tags statement will need to be dealt with.. I havent had time to study it's function Etc...

Off I go to play with the New MikroTik API object.. Lets see how long it takes me to brick a router.... :lol:
You do not have the required permissions to view the files attached to this post.
 
User avatar
janisk
MikroTik Support
MikroTik Support
Topic Author
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: API Links

Mon Sep 13, 2010 2:04 pm

good.

and what about .tag?

it is there to identify reply from command and will contain same tag set as you set it sending command to RouterOS.
 
csickles
Forum Guru
Forum Guru
Posts: 1255
Joined: Fri May 28, 2004 8:46 pm
Location: Phoenix, AZ
Contact:

Re: API Links

Tue Sep 14, 2010 1:13 am

Ok, I think I got it.

So if I send a tag of "MyTag" then the reply contains the same text in the reply "tag"?

I will give it a try...

Thx..
 
csickles
Forum Guru
Forum Guru
Posts: 1255
Joined: Fri May 28, 2004 8:46 pm
Location: Phoenix, AZ
Contact:

Re: API Links

Tue Sep 14, 2010 1:20 am

K...

Makes sence now..

the ".tag=MyTag" shows the "command sender IE: who issues the command so that the reply can be verified.


Cool... More to come...
 
csickles
Forum Guru
Forum Guru
Posts: 1255
Joined: Fri May 28, 2004 8:46 pm
Location: Phoenix, AZ
Contact:

Re: API Links

Tue Sep 14, 2010 1:25 am

So I have the cool use of the day...

You have a email scanner of web filter, and it detects that traffic from one IP or a range if IPs is just garbage.. IE viruses or boat loads of SPAM..

Then you could (Via API) add the IP/s to an IP list and then use firewalling to drop all IPs on that list..

With scripting Etc (Or the device adding the offending IP/s to the list) the system admin(s) could be notified by email Etc..

COOL !!!
 
User avatar
janisk
MikroTik Support
MikroTik Support
Topic Author
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: API Links

Thu Sep 16, 2010 10:46 am

in case of viruses that is good solution in case of mail - no normal user needs to make SMTP connection more than once in a second or in a few seconds, so, if you can add just rate limiting smtp connections, or add to blacklist allowing 1 connection every 30 seconds or ban altogether.

That can be done this way because users when send e-mail with many recipients, they send one message.
 
csickles
Forum Guru
Forum Guru
Posts: 1255
Joined: Fri May 28, 2004 8:46 pm
Location: Phoenix, AZ
Contact:

Re: API Links

Thu Sep 16, 2010 8:51 pm

For smaller users this is true...

For us Old timmers that have Mail server records in the 10s of thousands. (Spammers NEVER delete an address they figure out)
(We were 6500 users on the average at any one time (IT staff = 340) over the years) turn over for over 25 Years...

Our avarage SPAM load is 250 to 350 SPAMS per user per day.
Multiply that by 15K users, and more and more payloads are to one or two persons at a time (to avoid list SPAM rules (Bots send so who cares about sender CPU loads))..

My Avg. SPAM load is 99.98% bad at the mail gateway. (99.8 % to people that DONT EXIST ! LDAP takes a BEETING !!)

It requires 3 seporate scanning systems (Layered) (One with 8 AV engines) just to "TAME" it down...

So blocking spammers at the router (IP based) is a GOOD thing...

Mabee my filtering systems can stop SMOKING !!!

And as far as connection rates..

Microsoft "rates" user / system connection rates... Mine even with the filters rates as "Obcene"..

I have had comment from Microsoft SEs "And it is still running ?".. I say no more..
 
Ripper
Member Candidate
Member Candidate
Posts: 164
Joined: Thu Aug 05, 2010 1:24 am

Re: API Links

Sat Sep 18, 2010 2:30 am

how execute command in PHP API
 queue simple disable P40-34-9-2 
i've tryed that way

$API->write('/queue/simple',false);
$API->write('=disable=P40-34-9-2');

but it sad unknow command

any solution ?
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8709
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: API Links

Sun Sep 19, 2010 3:44 am

try

$API->write('/queue/simple/disable',false);
$API->write('=.id=P40-34-9-2');
 
Ripper
Member Candidate
Member Candidate
Posts: 164
Joined: Thu Aug 05, 2010 1:24 am

Re: API Links

Sun Sep 19, 2010 1:18 pm

Thanks a lot that was useful.
 
Phalanx00
just joined
Posts: 17
Joined: Wed Jan 19, 2011 9:45 am

Re: API Links

Sun Feb 13, 2011 9:54 am

I have a stupid question on http://wiki.mikrotik.com/wiki/API_In_CPP:
I need to send 4 commands, but only first one will execute.
login...
// first command
            writeSentence.AddWord("/export");
            writeSentence.AddWord("=file=script");
            
            mt.WriteSentence(writeSentence);
            mt.ReadBlock(block);

// second command
            writeSentence.AddWord("/file/set");
            writeSentence.AddWord("=numbers=script.rsc");
            writeSentence.AddWord("=contents=\"" + Commands + "\"");
  
            mt.WriteSentence(writeSentence);
            mt.ReadBlock(block);
 
So I tried wait for !done
bool done = 0;
while (!done) {
                mt.ReadSentence(readSentence);

                if (readSentence.GetSentence() == "!done" ) {
                    done = 1;
                }
}
But I have right debug output and still only first command will be executed. All of commands worked alone nice. This is the last thing what I need to finish my hell project :D Thank you for anything usefull
 
User avatar
janisk
MikroTik Support
MikroTik Support
Topic Author
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: API Links

Tue Feb 15, 2011 3:23 pm

It looks correct at first glance at what you posted, with what commands i have tested.

You could try to sniff traffic and see what sniff contains, if there are replies from router and what they contain.

if completely unsure, you can try with python example and see if these commands actually work.
 
Phalanx00
just joined
Posts: 17
Joined: Wed Jan 19, 2011 9:45 am

Re: API Links

Wed Feb 16, 2011 6:31 pm

There's something weird in CPP API.

my app is these four commands:
1) create file
2) edit file
3) import file
4) remove file

In Qt/C++ I have this behavior:
1) if file was not created, only file is created (step 1)
2) if file was created, it runs correctly

If anybody could try it, I wrote small client program with clean C++ API solution. Same behavior unless if file was created, import is trap...
I post cpp api if you can try that.

edit client.cpp with your information in call API Login then
make
./client

Hope it helps others too :?

EDIT: WORKS if use standart exporting, no ip address exporting
writeSentence.AddWord("/export");
writeSentence.AddWord("=file=script");
You do not have the required permissions to view the files attached to this post.
 
User avatar
janisk
MikroTik Support
MikroTik Support
Topic Author
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: API Links

Tue Feb 22, 2011 10:34 am

on what board you try to run this and on what RouterOS version?

Tried this on RB1000 with 5.0rc10

first, separate commands, removed quotation from =contents="some text" as that is not required to be there in rsc file.
[edit] wanted to add a bit about the protocol and how this works.
so you send in length and string, that in this case is formed this way:
=contents=blah..blah

API will read length, if it is not too long, it will read the string and see that argument is =contents= the rest of the string is value for the argument. Because of all this, you can set contents to whatever you like, even if you set it to "= contents=" it will be no concern for API.

Same thing happens when API returns some stuff, like script, you get =source=<whole script>

[/edit]

second ran it some other C++ code that did these commands
$ time ./TestAPI 
ret: !done
ret: !done

ret: !done

ret: !done


real    0m0.270s
user    0m0.000s
sys     0m0.000s



p.s. since i am paranoid of sorts, did not run your code.
 
User avatar
danikf
Frequent Visitor
Frequent Visitor
Posts: 72
Joined: Mon Mar 14, 2011 8:57 am

Re: API Links

Mon Mar 14, 2011 9:05 am

Hi,
please add this link to wiki:
.NET (C#) high-level api solution: http://code.google.com/p/mikrotik4net/

thx, danik
 
sw0rdf1sh
Frequent Visitor
Frequent Visitor
Posts: 50
Joined: Sun Nov 28, 2010 6:16 pm

Re: API Links

Tue Mar 22, 2011 1:42 pm

Please add this as well:

http://wiki.mikrotik.com/wiki/Api_php_template
Thanx
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8709
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: API Links

Wed Mar 23, 2011 12:20 am

are these examples of PHP API Class usage?..
 
sw0rdf1sh
Frequent Visitor
Frequent Visitor
Posts: 50
Joined: Sun Nov 28, 2010 6:16 pm

Re: API Links

Wed Mar 23, 2011 12:54 am

are these examples of PHP API Class usage?..
Chupaka I searched before building and posting in the wiki and I didn't find any example using this php api.So I did. If you believe they don't belong in the wiki then please delete so.

As for the use I believe it's a simple way of displaying info into a more readable form for a website rather than the respond from the api in an array format.
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8709
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: API Links

Wed Mar 23, 2011 2:01 am

sure, they should be in Wiki, just correct the text: it's not "based on the PHP API Class", it "uses PHP API Class" - you deceive people a bit...

all the rest is fine =)
 
User avatar
janisk
MikroTik Support
MikroTik Support
Topic Author
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: API Links

Wed Mar 23, 2011 10:31 am

linked php api to these templates, thx.
 
sw0rdf1sh
Frequent Visitor
Frequent Visitor
Posts: 50
Joined: Sun Nov 28, 2010 6:16 pm

Re: API Links

Wed Mar 23, 2011 1:28 pm

sure, they should be in Wiki, just correct the text: it's not "based on the PHP API Class", it "uses PHP API Class" - you deceive people a bit...

all the rest is fine =)
Sorry for that.My mistake.It's corrected now.
 
chapeupreto
just joined
Posts: 6
Joined: Wed Jul 21, 2010 5:49 pm

Re: API Links

Wed Mar 23, 2011 4:06 pm

Hi folks.
First, thanks for those links.
By talking in PHP API, I've downloaded the php class mikrotik api posted here
http://forum.mikrotik.com/viewtopic.php?f=9&t=50176
by sw0rdf1sh and I'm using it in some of my projects.
After executing a script that uses that routeros_api.class.php class, I got this message:
Notice: Undefined variable: _ in ... on line 313
Then, I would like to ask you guys a question:
First, consider the following piece of code which exists in that php class (lines 300 up to 320)
// If we have got more characters to read, read them in.
         if ($LENGTH > 0) {
            $_ = "";
            $retlen=0;
            while ($retlen < $LENGTH) {
               $toread = $LENGTH - $retlen ;
               $_ .= fread($this->socket, $toread);
               $retlen = strlen($_);
            }
            $RESPONSE[] = $_ ;
            $this->debug('>>> [' . $retlen . '/' . $LENGTH . ' bytes read.');
         }

         // If we get a !done, make a note of it.
         if ($_ == "!done")
            $receiveddone=true;

         $STATUS = socket_get_status($this->socket);

         
         if ($LENGTH > 0)
            $this->debug('>>> [' . $LENGTH . ', ' . $STATUS['unread_bytes'] . '] ' . $_);
So, there is this PHP variable $_ on it.
Besides the code above, I've glanced the entire class and saw no other mentions for that $_
I suppose my script don't execute those instructions inside that first conditional, i.e., if ($LENGTH > 0) ...
Therefore, when the script reachs that second conditional, i.e., if ($_ == "!done"), the PHP produces the notice message
undefined variable: _ 
, just because the $_ variable had never been initialized.
Although it's just a simple notice message, is that code right? I mean, don't you guys think the $_ variable should be initialized somewhere before the execution of those IF's?
I tried to contact the author of that API class, but got no success.
That's it.
Thanks for any reply and suggestions.

rod~
 
trakkasure
just joined
Posts: 8
Joined: Sun Feb 27, 2011 9:28 pm

Re: API Links

Wed May 18, 2011 8:49 pm

Just wanted to add my new API to the list of available:

Written in NodeJS: https://github.com/Trakkasure/mikronode

Installable with NPM
npm install mikronode
Features:
  • * 100% Javascript. (with NodeJS)
    * Channel based communication
    * Multiple channels can be used at once.
    * Synchronous execution of commands issued on the same channel.
    * Asynchrounous execution of commands issued on different channels.
    * Focus on high performance
... Now if only it would end up in the list on the Wiki ...
 
User avatar
janisk
MikroTik Support
MikroTik Support
Topic Author
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: API Links

Thu May 19, 2011 9:51 am

it would be nice if you could make wiki page for your implementation. With more explanations or example.
 
trakkasure
just joined
Posts: 8
Joined: Sun Feb 27, 2011 9:28 pm

Re: API Links

Thu May 19, 2011 7:41 pm

it would be nice if you could make wiki page for your implementation. With more explanations or example.
I didn't know I had access to create a wiki page. I'll figure it out.

The GitHub page, https://github.com/trakkasure/mikronode, has full source and examples.

And it can be installed using npm (For those who use it):
npm install mikronode
It works very well. And I have plans to further develop and support it.
 
trakkasure
just joined
Posts: 8
Joined: Sun Feb 27, 2011 9:28 pm

Re: API Links

Thu May 19, 2011 8:25 pm

I didn't know I had access to create a wiki page. I'll figure it out.
Ok. So.. I created a wiki page (http://wiki.mikrotik.com/wiki/User_talk:Trakkasure).. It's under my "talks page".
So.. how do I create one outside of my talks one? (or does someone else do that?)

Still trying to figure it out.
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8709
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: API Links

Fri May 20, 2011 2:26 am

So.. how do I create one outside of my talks one? (or does someone else do that?)

Still trying to figure it out.
yeah, with Google search it's a bit tricky...

http://wiki.mikrotik.com/index.php?titl ... ction=edit - replace "MyNewPageTitle" with necessary string... or just put http://wiki.mikrotik.com/wiki/MyNewPageTitle to the Address bar and then press "Create" link
 
trakkasure
just joined
Posts: 8
Joined: Sun Feb 27, 2011 9:28 pm

Re: API Links

Fri May 20, 2011 3:54 am

put http://wiki.mikrotik.com/wiki/MyNewPageTitle to the Address bar and then press "Create" link
Ok.. Done.

http://wiki.mikrotik.com/wiki/MikroNode

I don't have permission to edit the Manual::API page. So....
 
User avatar
janisk
MikroTik Support
MikroTik Support
Topic Author
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: API Links

Fri Jun 03, 2011 8:53 am

added link from API page to your creation and back
 
trakkasure
just joined
Posts: 8
Joined: Sun Feb 27, 2011 9:28 pm

Re: API Links

Fri Jun 03, 2011 11:17 pm

Thanks you.
 
User avatar
saaremaa
Member Candidate
Member Candidate
Posts: 162
Joined: Tue Feb 02, 2010 7:48 pm
Location: Baltijos šalių miestas

Re: API Links

Mon Aug 01, 2011 5:06 pm

Need Help. Python API from Wiki does not work in Python 3.2.xxx.? Please share a working API.
 
User avatar
janisk
MikroTik Support
MikroTik Support
Topic Author
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: API Links

Wed Aug 03, 2011 3:10 pm

yes, python API client example from API manual page was written some time ago and is working only with Python 2.7.x or older.

However I have created example (based on Python2 example) for Python3
 
User avatar
saaremaa
Member Candidate
Member Candidate
Posts: 162
Joined: Tue Feb 02, 2010 7:48 pm
Location: Baltijos šalių miestas

Re: API Links

Wed Aug 03, 2011 6:20 pm

yes, python API client example from API manual page was written some time ago and is working only with Python 2.7.x or older.

However I have created example (based on Python2 example) for Python3
You can upload API for Python 3.x.x ?
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8709
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: API Links

Wed Aug 03, 2011 11:18 pm

 
User avatar
saaremaa
Member Candidate
Member Candidate
Posts: 162
Joined: Tue Feb 02, 2010 7:48 pm
Location: Baltijos šalių miestas

Re: API Links

Wed Aug 03, 2011 11:32 pm

Imho, api ( http://wiki.mikrotik.com/wiki/Manual:API_Python3) contains syntax errors. Or am I mistaken?
 
User avatar
janisk
MikroTik Support
MikroTik Support
Topic Author
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: API Links

Thu Aug 04, 2011 8:25 am

well i was successful running it :), running commands etc.

and python does not complain :)
 
User avatar
saaremaa
Member Candidate
Member Candidate
Posts: 162
Joined: Tue Feb 02, 2010 7:48 pm
Location: Baltijos šalių miestas

Re: API Links

Thu Aug 04, 2011 8:32 am

well i was successful running it :), running commands etc.

and python does not complain :)
OS: Ubuntu Server + Python 3.2

File "./api.py", line 33
attrs[w] =
^
SyntaxError: invalid syntax
 
User avatar
janisk
MikroTik Support
MikroTik Support
Topic Author
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: API Links

Thu Aug 04, 2011 8:37 am

wiki spacing could be the problem. File added to wiki. Just have to rename it to py from txt it is saved on the wiki.

this is how it runs:
$ python3 api.py tst admin ''
<<< /login
<<<
>>> !done
>>> =ret=39fe3aa4385c1820b5df799739b50761
>>>
<<< /login
<<< =name=admin
<<< =response=000ef1c4c0919129902827644fe9c65efb
<<<
>>> !done
>>>
edit:
did changes to article and made sure that wiki spacing does not interfere with python

downloaded from python.org && compiled
$ python3 --version
Python 3.2.1
 
User avatar
saaremaa
Member Candidate
Member Candidate
Posts: 162
Joined: Tue Feb 02, 2010 7:48 pm
Location: Baltijos šalių miestas

Re: API Links

Thu Aug 04, 2011 8:47 am

Thank you for your help. The problem is not only in the gaps Wiki. In Ubuntu it was set to simultaneously release Python v2 and v3. Removed Python v2 and everything started.
 
User avatar
janisk
MikroTik Support
MikroTik Support
Topic Author
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: API Links

Thu Aug 04, 2011 10:12 am

reading post elsewhere in the forum realised that python3 example is not capable to connect to ipv6 hosts, so i did small update to correct that.
 
User avatar
saaremaa
Member Candidate
Member Candidate
Posts: 162
Joined: Tue Feb 02, 2010 7:48 pm
Location: Baltijos šalių miestas

Re: API Links

Thu Aug 04, 2011 10:54 pm

Python3 API crashed if comment contain symbol`s different from the English symbol`s.
<<< /login
<<<
>>> !done
>>> =ret=a341a4f9r5b81fadfr40w29y04c2d8c4
>>>
<<< /login
<<< =name=asdfgh
<<< =response=00a919e4rd2795wqdfc036brc8ay19a9911
<<<
>>> !done
>>>
/ip/firewall/address-list/getall

<<< /ip/firewall/address-list/getall
<<<
>>> !re
>>> =.id=*11
>>> =list=local-net
>>> =address=192.168.39.0/24
>>> =dynamic=false
>>> =disabled=false
>>> =comment=test0
>>>
>>> !re
>>> =.id=*4F
>>> =list=l-2048-2048
>>> =address=192.168.39.0/24
>>> =dynamic=false
>>> =disabled=false
>>> =comment=Unauth custommers speed
>>>
>>> !re
>>> =.id=*114
>>> =list=l-1536-1536
>>> =address=192.168.38.0/24
>>> =dynamic=false
>>> =disabled=true
Traceback (most recent call last):
File "api.py", line 164, in <module>
main()
File "api.py", line 148, in main
x = apiros.readSentence()
File "api.py", line 50, in readSentence
w = self.readWord()
File "api.py", line 60, in readWord
ret = self.readStr(self.readLen())
File "api.py", line 131, in readStr
s = self.sk.recv(length - len(ret)).decode('UTF-8')
UnicodeDecodeError: 'utf8' codec can't decode byte 0xc4 in position 9: invalid continuation byte
 
User avatar
janisk
MikroTik Support
MikroTik Support
Topic Author
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: API Links

Mon Aug 08, 2011 12:28 pm

similar to cli it will show weird symbol. as generally it is not known what value is paced there and what it should mean.
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2400
Joined: Thu Aug 31, 2006 4:43 pm
Location: europe://Bulgaria/Plovdiv

Re: API Links

Mon Aug 29, 2011 11:52 pm

Hi.

Please add this to the Wiki:
https://sourceforge.net/projects/netrouteros/

It's for PHP, but unlike the previous ones, it's heavily OOP and requires PHP 5.3 (for the sake of namespaces), and this in an effort to make it look like a more "natural" extension to PHP, rather than a "bolt on" (and also to simplify some stuff that if you want to use with the other APIs, you really need to know what you're doing).

I'd appreciate any feedback, both here, and on the project page.
 
ormg770
just joined
Posts: 1
Joined: Tue Oct 18, 2011 7:16 pm

Re: API Links

Tue Oct 18, 2011 7:18 pm

Wish someone could help me with an asp API.

Thanks in advance
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2400
Joined: Thu Aug 31, 2006 4:43 pm
Location: europe://Bulgaria/Plovdiv

Re: API Links

Tue Oct 18, 2011 8:37 pm

Wish someone could help me with an asp API.

Thanks in advance
On the bottom of the API's wiki page, you can see 3 .NET clients - in C#, VB.NET, and an external C# project.

Assuming that by "ASP", you're talking about "ASP.NET", you can use any one of these clients (IMHO, mikrotik4net looks like the most sophisticated client, and as such, the one I'd pick). If by "ASP", you really mean "ASP", as in "ASP classic", I must ask... why? Why not upgrade to ASP.NET?

If you mean you're actually using one of these clients and are having problems... post a new topic about it or something.
 
User avatar
vthinkteam
just joined
Posts: 7
Joined: Sun Nov 20, 2011 7:23 am
Location: Mataram, Indonesia
Contact:

Re: API Links

Sun Nov 20, 2011 7:45 am

We have developing Mikrotik RouterOS API Library from Denis Basta (denis.basta@gmail.com) routeros_api class and we change it to our core class with name Mapi_Core. We have been tested with RouterOS version 3 and above. This spark library allow your Mikrotik RouterOS via CodeIgniter Framework for PHP, and we have make it easier than before for access and manipulating Mikrotik RouterOS API with specific method.

If you are CodeIgniter Framework Programmer, you can get Library for CodeIgniter Spark in this link :

Spark Library : http://getsparks.org/packages/mikrotik_api/show
Spark Repository : https://github.com/vthink/mikrotik_api
Documentation : http://doc.vthink.web.id
Updates Info : http://vthink.web.id/index.php/content/categories/21

if you have codeigniter but doesn't have a spark management package you can install it via terminal with this command :
php -r "$(curl -fsSL http://getsparks.org/go-sparks)"
more information about what is CodeIgniter Spark PHP Framework, please open this link:
http://getsparks.org/install
 
ve3nbe
just joined
Posts: 3
Joined: Tue Nov 29, 2011 8:59 pm

Re: API Links

Thu Dec 01, 2011 12:02 pm

Thank you very much
 
User avatar
vthinkteam
just joined
Posts: 7
Joined: Sun Nov 20, 2011 7:23 am
Location: Mataram, Indonesia
Contact:

Re: API Links

Fri Dec 02, 2011 11:57 am

By the way how about Mikrotik API Java that janisk created... how it licensed???
I was read in wiki, license said that

Code is provided as is and can be freely used freely. I, as a writer of code, am not responsible for anything that may arise from use of this code.


But I can't see that licensed on GPL or MIT or BSD or something else???
I was developing library that I plan for license on GPL 3. My Core library using MikroTik API Java that was created by Janisk, and I'm doing some modification for adapting with My Library. How do I license janisk work to be part of my library, and how to say that I was doing modification on that class.

If janisk here please respond me...
 
User avatar
vthinkteam
just joined
Posts: 7
Joined: Sun Nov 20, 2011 7:23 am
Location: Mataram, Indonesia
Contact:

Re: API Links

Fri Dec 02, 2011 11:58 am

And one things I'm new on Licensing... soo, help me to understand it..
 
User avatar
janisk
MikroTik Support
MikroTik Support
Topic Author
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: API Links

Fri Dec 02, 2011 2:21 pm

i see all of these licenses restrictive for this peace of code. So, the code is provided AS-IS, you can freely use it as a whole or parts of it, edit it to suit your needs and your project. If you see errors in the code and want them fixed you can contact me and notify about those. If you are going to publish source of your code under some license, just make sure that nobody is going to write me saying that i have some licensed code on the page that i either have to license under same license and write down who the real author is.
 
User avatar
vthinkteam
just joined
Posts: 7
Joined: Sun Nov 20, 2011 7:23 am
Location: Mataram, Indonesia
Contact:

Re: API Links

Fri Dec 02, 2011 5:31 pm

Thankz for reply my post...

Can I get your email? cause when I want to contact you, I cannot see email or any other contact for communicating with you.
send me message to vthinkteam@gmail.com

I analyze what you said in this.
If you are going to publish source of your code under some license, just make sure that nobody is going to write me saying that i have some licensed code on the page that i either have to license under same license and write down who the real author is.
first thing, I want to publish my source code with the your source code inside some package of my source code. I will make library called JRouterOS and I want use GPL 3 license on it.

This the situation :
Your code using AS-IS or in other words "unlicensed" (this my opinion).
My Code using license GPL 3.
I want to distribute jar , javadoc, and src in one bundle, that your code in that bundle too.
Your code will be inside JRouterOS.jar in some package on classpath of this jar.


With this situation my question is :
1. Does the license GPL with unlicensed will compatible in one bundle...
2. or, Do my code cannot licensed to GPL 3, so I have to use AS-IS too...
 
User avatar
janisk
MikroTik Support
MikroTik Support
Topic Author
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: API Links

Thu Dec 08, 2011 1:37 pm

AFAIK you can use my code, just in header add notice that where this code was taken from. That should suffice.
 
legrang
just joined
Posts: 23
Joined: Wed Nov 03, 2010 4:05 pm
Location: South Africa
Contact:

Re: API Links

Mon Dec 30, 2013 2:12 pm

I have written a Java client library for the Mikrotik API.

The library, source code and examples can be found here: https://github.com/GideonLeGrange/mikrotik-java

Current version is 1.0, with 1.1 - which will support TLS encryption - due shortly.

I appreciate all questions and comments.

-
Gideon
 
User avatar
janisk
MikroTik Support
MikroTik Support
Topic Author
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: API Links

Mon Mar 24, 2014 1:46 pm

somehow i missed your post. Added your java link to the wiki.
 
comtihon
just joined
Posts: 1
Joined: Fri Jun 13, 2014 3:45 am

Re: API Links

Fri Jun 13, 2014 3:47 am

I made api for Erlang, please add it to your wiki -> https://github.com/comtihon/erotik
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8709
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: API Links

Fri Jun 13, 2014 12:51 pm

I made api for Erlang, please add it to your wiki -> https://github.com/comtihon/erotik
ahhh, I'm in love with than name!..
 
serthan
Frequent Visitor
Frequent Visitor
Posts: 61
Joined: Sat Jun 16, 2007 10:49 am

Re: API Links

Wed Jul 09, 2014 5:30 pm

/ip/hotspot/user/remove
=numbers=123

username:123
password:123

api kod doesnt work, mikrotik removing another user which have id=123
can we use =name= or anything instead of =numbers=
thx
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7038
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: API Links

Wed Jul 09, 2014 6:19 pm

You can get ID by name
/ip/hotspot/user/print
?name=123
=.proplist=.id


and tehn run remove command
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8709
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: API Links

Wed Jul 09, 2014 7:11 pm

/ip/hotspot/user/remove
=numbers=123

username:123
password:123

api kod doesnt work, mikrotik removing another user which have id=123
can we use =name= or anything instead of =numbers=
thx
well, not 'numbers' but '.id', I think. also, .id is in '*number' format, so if '123' is username, then you can use it as .id (need to be checked, but in other places you can use unique name for .id) without worrying that user with .id equal to *123 will be deleted
 
User avatar
janisk
MikroTik Support
MikroTik Support
Topic Author
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: API Links

Tue Aug 05, 2014 3:09 pm

I made api for Erlang, please add it to your wiki -> https://github.com/comtihon/erotik
thanks for example, added to wiki.
 
ibrahim10101
just joined
Posts: 2
Joined: Wed Oct 29, 2014 5:05 pm

Re: API Links

Wed Oct 29, 2014 5:13 pm

how to read data with c# ????
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8709
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: API Links

Thu Oct 30, 2014 12:25 pm

how to read data with c# ????
http://wiki.mikrotik.com/wiki/API_in_C_Sharp
 
luan
just joined
Posts: 4
Joined: Sun May 31, 2015 9:06 pm

Re: API Links

Mon Jun 01, 2015 1:26 am

Hi folks.
I need to print on a table id and the name of the hostpot users.
and remove the User by his id.
Can anyone help me.
 
luan
just joined
Posts: 4
Joined: Sun May 31, 2015 9:06 pm

Re: API Links

Mon Jun 01, 2015 1:29 am

Hi folks.
I need to print on a table id and the name of the hostpot users.
and remove the User by his id.
Can anyone help me.
I use C Sharp
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8709
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: API Links

Mon Jun 01, 2015 2:02 pm

Hi folks.
I need to print on a table id and the name of the hostpot users.
and remove the User by his id.
Can anyone help me.
/ip/hotspot/user/print
=.proplist=.id,name
then
/ip/hotspot/user/remove
=.id=ID_HERE
I use C Sharp
http://wiki.mikrotik.com/wiki/API_in_C_Sharp
 
kgninfos
Member
Member
Posts: 387
Joined: Thu Jun 21, 2012 7:34 pm
Location: Earth
Contact:

Re: API Links

Sat Jun 13, 2015 6:11 pm

can anyone post a sample project with source on how to use the api in Android app
a simple /ip/address/print with parsing and show the result in textfeild/ table would be enough

Thanks
 
User avatar
danikf
Frequent Visitor
Frequent Visitor
Posts: 72
Joined: Mon Mar 14, 2011 8:57 am

Re: API Links

Fri Aug 28, 2015 1:01 am

Hi all,

please redirect link for tik4net (.NET (C#) - external by danikf) to new location (both in this thread and in wiki links).

New location of tik4net project: https://github.com/danikf/tik4net
And newly created thread here: http://forum.mikrotik.com/viewtopic.php?f=9&t=99954

Thanks,
D
 
nuclide
just joined
Posts: 1
Joined: Thu Nov 05, 2015 8:56 pm

Re: API examples

Thu Nov 05, 2015 9:02 pm

Can anybody make the API for VB (for VB projects and ASP pages)?!



Thanks,
Mladen
It will be wonderful
 
User avatar
danikf
Frequent Visitor
Frequent Visitor
Posts: 72
Joined: Mon Mar 14, 2011 8:57 am

Re: API Links

Sun Nov 08, 2015 6:41 pm

Hi,

why not use C# (.NET) dlls in VB (also .NET) code?

D
 
andredossantos
just joined
Posts: 8
Joined: Thu Jul 21, 2016 9:21 pm

Re: API Links

Thu Jul 21, 2016 11:34 pm

Implementation in Go (Golang):
https://github.com/go-routeros/routeros

To install, run: go get gopkg.in/routeros.v1
 
andredossantos
just joined
Posts: 8
Joined: Thu Jul 21, 2016 9:21 pm

Re: API Links

Fri Jul 22, 2016 1:55 pm

Added Go implementation page to the wiki.
Could someone link to it from the API page?

http://wiki.mikrotik.com/wiki/API_in_Go
 
User avatar
janisk
MikroTik Support
MikroTik Support
Topic Author
Posts: 6263
Joined: Tue Feb 14, 2006 9:46 am
Location: Riga, Latvia

Re: API Links

Fri Jan 20, 2017 4:06 pm

Added Go implementation page to the wiki.
Could someone link to it from the API page?

http://wiki.mikrotik.com/wiki/API_in_Go
Added,

we really appreciate your input. Hopefully, a lot of our users will find this useful.
 
igorvukotic
just joined
Posts: 10
Joined: Mon Aug 03, 2015 2:00 pm

Re: API Links

Sun Nov 26, 2017 6:50 pm

Hi guys, need help with API/Python27
i follow: https://wiki.mikrotik.com/wiki/Manual:A ... d_examples

can someone show how to pass this terminal command true API:
/ip firewall filter
add action=drop chain=input dst-port=53 in-interface=ether1_WAN protocol=udp
i tried ( with many variations ):
apiros.runCommand("/ip/firewall/filter/add","=chain=input\n=action=drop\n=dst-port=53\n=in-interface=ether1_WAN\n=protocol=udp","")
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8709
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: API Links

Mon Nov 27, 2017 8:36 am

.runCommand? I can't find this on the page you linked to...
 
igorvukotic
just joined
Posts: 10
Joined: Mon Aug 03, 2015 2:00 pm

Re: API Links

Mon Nov 27, 2017 11:04 am

class APIError(Exception):
	def __init__(self, message, category = -1):
		self.message = message
		self.category = category
	def __str__(self):
		return repr(self.message)
		
class ApiRos:
	"""
	Routeros api
	"""
	def __init__(self, ip):
		sk = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
		sk.connect((ip, 8728))
		self.sk = sk
		self.currenttag = 0
	def login(self, username, pwd):
		for _, attrs in self.talk(["/login"]):
			chal = binascii.unhexlify(attrs['=ret'])
		md = md5.new()
		md.update('\x00')
		md.update(pwd)
		md.update(chal)
		self.talk(["/login", "=name=" + username,
			"=response=00" + binascii.hexlify(md.digest())])
	def talk(self, words):
		if self.writeSentence(words) == 0:
			return
		r = []
		while 1:
			i = self.readSentence();
			if len(i) == 0:
				continue
			reply = i[0]
			attrs = {}
			for w in i[1:]:
				j = w.find('=', 1)
				if (j == -1):
					attrs[w] = ''
				else:
					attrs[w[:j]] = w[j + 1:]
			r.append((reply, attrs))
			if reply == '!done':
				return r
	def writeSentence(self, words):
		ret = 0
		for w in words:
			self.writeWord(w)
			ret += 1
		self.writeWord('')
		return ret
	def readSentence(self):
		r = []
		while 1:
			w = self.readWord()
			if w == '':
				return r
			r.append(w)
	def writeWord(self, w):
		# print "<<< " + w
		self.writeLen(len(w))
		self.writeStr(w)
	def readWord(self):
		ret = self.readStr(self.readLen())
		# print ">>> " + ret
		return ret
	def writeLen(self, l):
		if l < 0x80:
			self.writeStr(chr(l))
		elif l < 0x4000:
			l |= 0x8000
			self.writeStr(chr((l >> 8) & 0xFF))
			self.writeStr(chr(l & 0xFF))
		elif l < 0x200000:
			l |= 0xC00000
			self.writeStr(chr((l >> 16) & 0xFF))
			self.writeStr(chr((l >> 8) & 0xFF))
			self.writeStr(chr(l & 0xFF))
		elif l < 0x10000000:
			l |= 0xE0000000
			self.writeStr(chr((l >> 24) & 0xFF))
			self.writeStr(chr((l >> 16) & 0xFF))
			self.writeStr(chr((l >> 8) & 0xFF))
			self.writeStr(chr(l & 0xFF))
		else:
			self.writeStr(chr(0xF0))
			self.writeStr(chr((l >> 24) & 0xFF))
			self.writeStr(chr((l >> 16) & 0xFF))
			self.writeStr(chr((l >> 8) & 0xFF))
			self.writeStr(chr(l & 0xFF))
	def readLen(self):
		c = ord(self.readStr(1))
		if (c & 0x80) == 0x00:
			pass
		elif (c & 0xC0) == 0x80:
			c &= ~0xC0
			c <<= 8
			c += ord(self.readStr(1))
		elif (c & 0xE0) == 0xC0:
			c &= ~0xE0
			c <<= 8
			c += ord(self.readStr(1))
			c <<= 8
			c += ord(self.readStr(1))
		elif (c & 0xF0) == 0xE0:
			c &= ~0xF0
			c <<= 8
			c += ord(self.readStr(1))
			c <<= 8
			c += ord(self.readStr(1))
			c <<= 8
			c += ord(self.readStr(1))
		elif (c & 0xF8) == 0xF0:
			c = ord(self.readStr(1))
			c <<= 8
			c += ord(self.readStr(1))
			c <<= 8
			c += ord(self.readStr(1))
			c <<= 8
			c += ord(self.readStr(1))
		return c
	def writeStr(self, str):
		n = 0;
		while n < len(str):
			r = self.sk.send(str[n:])
			if r == 0: raise RuntimeError, "connection closed by remote end"
			n += r
	def readStr(self, length):
		ret = ''
		while len(ret) < length:
			s = self.sk.recv(length - len(ret))
			if s == '': raise RuntimeError, "connection closed by remote end"
			ret += s
		return ret
	def getSocket(self):
		return self.sk
	def runCommand(self, command, cmd2, cmd3, **arguments):
		'''
		Run a command attempting to keep as close to the command line version,
		while maintaining an easy to use library.
		'''
		apiMessage = [command, cmd2, cmd3]
		if arguments != None:
			apiMessage += ["={0}={1}".format(k.replace('__', '-'), v) for k, v in arguments.items()]
		rez = self.talk(apiMessage)
		# print rez
		# Remove the !done at the end of the list.
		if rez[len(rez) - 1][0] == '!done':
			doneVal = rez.pop()
 		# Check for error conditions (Need to make this more efficient).
		trapVal = filter(lambda x: x[0] == '!trap', rez)
		if trapVal != []:
			trapVal = trapVal.pop()
			if 'category' in trapVal:
				category = trapVal[1]['=category']
			else:
				category = -1
			# print "TrapVal = {0}".format(trapVal[1])
			raise APIError(trapVal[1]['=message'], category)
		# Extract the data itself
		data = map(lambda x: x[1], rez)
		if data == []:
			if doneVal[1] != {}:
				data = doneVal[1]['=ret']
		return data
	
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8709
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: API Links

Mon Nov 27, 2017 12:31 pm

Try "dst__port=53\n=in__interface=ether1_WAN" (replace 'minus' sign with double underscore)
 
igorvukotic
just joined
Posts: 10
Joined: Mon Aug 03, 2015 2:00 pm

Re: API Links

Mon Nov 27, 2017 4:48 pm

no help..
Screen Shot 2017-11-27 at 15.46.31.jpg
You do not have the required permissions to view the files attached to this post.
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8709
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: API Links

Tue Nov 28, 2017 12:35 pm

I'm not familiar with Py, check this: viewtopic.php?p=392367
 
lniconet
just joined
Posts: 1
Joined: Wed Jul 17, 2013 7:45 pm

Re: API Links

Fri Jun 22, 2018 8:10 pm

Hello,

For those interested, my python module to use the API:

https://github.com/lnicolas83/routeros-api
 
SergeS
Frequent Visitor
Frequent Visitor
Posts: 67
Joined: Fri Mar 25, 2016 6:23 am

Re: API Links

Fri Jul 13, 2018 12:50 am

Does anybody need Labview code for Mikrotik API support?
If yes - I could share it. I wrote it and was using already for few years with good results.
If nobody - I will not bother...
 
Pulido
just joined
Posts: 1
Joined: Tue Aug 14, 2018 11:05 pm

Re: API Links

Tue Aug 14, 2018 11:07 pm

I'm definitely interested in seeing this. Thanks.
 
User avatar
BlackVS
Member Candidate
Member Candidate
Posts: 172
Joined: Mon Feb 04, 2013 7:00 pm
Contact:

Re: API Links

Fri Mar 29, 2019 12:49 pm

One more Python API (still beta but functional) :
https://github.com/BlackVS/smartROS (some description in Russian)
Is developed for my own needs.
Main features:
  • TLS+ADH / TLS+certificates connection supported
  • routers' credentials stored in config file
  • human readable conditions (see below)
  • logging
  • test script "console" included
Conditions in commands:
in console:
/ip/firewall/address-list/print where="list==Blacklist and address==8.8.8.8"
or in Python ( style 1):
import smartROS
router = smartROS.getRouter("Main")
print( router.ip.firewall.address__list.print (where="list==Blacklist and address==8.8.8.8") )
or in Python ( style 2):
import smartROS
router = smartROS.getRouter("Main")
print( router.do("/ip/firewall/address-list/print", where="list==Blacklist and address==8.8.8.8") )
 
Madnessy
just joined
Posts: 3
Joined: Wed May 15, 2019 9:44 pm

Re: API Links

Wed May 15, 2019 9:50 pm

Not really api related , nor scripting related.

But is there an ansible playbook somewhere we can use to configure our devices ?
(Already started building my own cause i could'nt find one on the ansible galaxy nor on the forum)
 
nar6du14
just joined
Posts: 2
Joined: Mon Oct 01, 2018 4:43 pm

Re: API Links

Thu May 23, 2019 11:20 pm

This a link to a python 3 asynchronous version of mikrotik api feel free to share it https://bitbucket.org/wambedu14/splynxp ... krotik_api
 
Madnessy
just joined
Posts: 3
Joined: Wed May 15, 2019 9:44 pm

Re: API Links

Wed May 29, 2019 11:01 am

made a first commit of the ansible role / playbook
https://github.com/Madnessy/ansible-mikrotik

feel free to use / test / share / suggest improvements etc
 
arielf
newbie
Posts: 34
Joined: Fri May 09, 2008 4:58 pm

Re: API Links

Fri Sep 06, 2019 1:09 pm

Hello, does anyone know or have any php, that helps me to add, delete, block, leasess of the dhcp-server mikrotik?
 
Longsdale
just joined
Posts: 6
Joined: Thu Jan 02, 2020 8:19 am

Re: API Links

Fri Jan 03, 2020 7:31 pm

I have written a C++ API connector/wrapper: https://github.com/zx2512/MikrotikPlus
It would be nice if this gets added to these lists as there is no other good C++ connector available.
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8709
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: API Links

Sat Jan 04, 2020 1:54 pm

I have written a C++ API connector/wrapper: https://github.com/zx2512/MikrotikPlus
It supports only RouterOS versions 6.43 and later, right?
 
Longsdale
just joined
Posts: 6
Joined: Thu Jan 02, 2020 8:19 am

Re: API Links

Sat Jan 04, 2020 4:01 pm

It supports only RouterOS versions 6.43 and later, right?
That is correct. I didn't want to bother with the outdated authentication method which is removed in the latest versions.
 
legrang
just joined
Posts: 23
Joined: Wed Nov 03, 2010 4:05 pm
Location: South Africa
Contact:

Re: API Links

Sat Jan 04, 2020 6:43 pm

Supporting both is not difficult
 
Longsdale
just joined
Posts: 6
Joined: Thu Jan 02, 2020 8:19 am

Re: API Links

Sat Jan 04, 2020 6:46 pm

Supporting both is not difficult
I didn't really want to spend additional time on it. Updating consumes less time.
 
User avatar
vasilevkirill
Trainer
Trainer
Posts: 56
Joined: Tue May 22, 2012 7:38 am
Location: Russian, Saint-Petersburg
Contact:

Re: API Links

Sat Apr 11, 2020 4:46 pm

hi,
this simple GUI for testing RouterOS API, based in web browser.
need running binary and open http://localhost:8081
source https://github.com/vasilevkirill/RouterOSAPIGUI
binary for all platforms https://github.com/vasilevkirill/Router ... I/releases
 
User avatar
arsalansiddiqui
just joined
Posts: 23
Joined: Mon Aug 14, 2017 1:03 pm
Location: Karachi, Pakistan
Contact:

Re: API Links

Mon Jul 27, 2020 4:49 pm

I want to get logs in pagination and dhcp lease in pagination what should i do to make output to a certain limit, example 1 to 10 or 67 to 87.
I'm using PHP api of Denis Basta
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8709
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: API Links

Fri Jul 31, 2020 11:16 am

You just get full list via API and then sort/paginate as you want.
 
User avatar
arsalansiddiqui
just joined
Posts: 23
Joined: Mon Aug 14, 2017 1:03 pm
Location: Karachi, Pakistan
Contact:

Re: API Links

Sat Aug 01, 2020 9:04 pm

If i fetch full page than what's use of pagination then, pagination helps to load only certain records thats what i want. i dont want to load all records its no use, i want to minimize the delay time faced during full fetched data
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7038
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: API Links

Mon Aug 03, 2020 10:01 am

API does not support such feature. You can only use queries to filter returned items by specific criteria, but no paging.
 
James56
just joined
Posts: 7
Joined: Fri Aug 21, 2020 9:07 pm

Re: API Links

Sat Aug 29, 2020 11:56 am

Note: The PHP links in the top post don't work.
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8709
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: API Links

Mon Aug 31, 2020 4:02 pm

13:51, 3 January 2019 Normis (talk | contribs) deleted page RouterOS PHP class
13:51, 3 January 2019 Normis (talk | contribs) deleted page API PHP class
But some other API articles are still in Wiki... Normis?..

I'll update the first post with a link to https://github.com/BenMenking/routeros-api and will wait for the answer in viewtopic.php?p=814209#p814209 - the repo there is not available for me now.
 
alqadhi
just joined
Posts: 4
Joined: Wed Jun 10, 2020 8:44 pm

Re: API Links

Fri Oct 02, 2020 6:59 pm

How do I submit a library to be included in the Wiki?

Here is a library that I wrote a few months ago. It is written in C++17, and uses Boost.Asio (will be included in the C++23 standard).
https://github.com/aymanalqadhi/tikpp
 
alqadhi
just joined
Posts: 4
Joined: Wed Jun 10, 2020 8:44 pm

Re: API Links

Sat Oct 17, 2020 8:23 pm

API implementations in different programming languages from users of this forum:

in Perl - forum thread by cheesegrits
in Delphi - forum thread and wiki by rodolfo
in Delphi #2 - forum thread by Chupaka
in PHP - external by Denis Basta and contributors
Java sample methods - forum post
in Python - wiki link by Mikrotik staff
in C# - wiki link by wiki user Gregy
Ruby on rails wiki and discussion on forum(v1.9) - by astounding
in Adobe Flash - wiki by haakon
in C - wiki by webasdf
in C (GPL2 license) -wiki by octo
.NET (C#) discussion on forum - external by danikf
in NodeJS - by trakkasure

API related information links:
http://wiki.mikrotik.com/wiki/API
http://wiki.mikrotik.com/wiki/API_command_notes
Please update the post with the last library in the Wiki API page.
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8709
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: API Links

Sun Oct 18, 2020 10:58 pm

Added a link to the first post
 
Manfi99
just joined
Posts: 1
Joined: Fri Mar 19, 2021 11:57 am

Re: API Links

Fri Mar 19, 2021 12:07 pm

Does anybody need Labview code for Mikrotik API support?
If yes - I could share it. I wrote it and was using already for few years with good results.
If nobody - I will not bother...
Hello,

I am interested in your LabVIEW code. Could you share it to me, please?
Thank you very much.
 
jeppu31
just joined
Posts: 4
Joined: Mon Apr 12, 2021 7:47 pm

Re: API Links

Sun Apr 25, 2021 10:29 am

Looking for Mikrotik api for Arduino using esp32, esp8266 please share it to me or email me jeffcastaneda31@ gmail. com

Thanks.. Godbless
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8709
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: API Links

Sat May 01, 2021 1:34 am

There are clients for C and C++ - just use them?..
 
Electrogics
just joined
Posts: 4
Joined: Sat Mar 13, 2021 8:00 pm

Re: API Links

Thu Aug 12, 2021 5:08 pm

Hi, where is the wiki for API C? it seems to be moved, I can't access, thank you!
 
User avatar
Larsa
Forum Guru
Forum Guru
Posts: 1025
Joined: Sat Aug 29, 2015 7:40 pm
Location: The North Pole, Santa's Workshop

API support for command concatenation?

Wed May 04, 2022 6:22 pm

Anyone who knows a API framework that supports command concatenation or command substitution aka “[]” or "()" ? We've tried some frameworks for python, perl, php and javascript but found nada so far.

Could it be the implementations that is limited or even worse a restriction in the core API itself?
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8709
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: API Links

Tue May 10, 2022 4:02 pm

What exactly do you want to do by "command concatenation or substitution"?..
 
msatter
Forum Guru
Forum Guru
Posts: 2897
Joined: Tue Feb 18, 2014 12:56 am
Location: Netherlands / Nīderlande

Re: API Links

Sun May 22, 2022 2:18 pm

 
wesllycode
just joined
Posts: 1
Joined: Wed Aug 17, 2022 11:20 pm

Re: API Links

Wed Aug 17, 2022 11:26 pm

 
User avatar
anav
Forum Guru
Forum Guru
Posts: 18958
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Re: API Links

Fri Aug 19, 2022 5:18 pm

Question from a non techie..... What is an API...
APIs let your product or service communicate with other products and services without having to know how they’re implemented.

Okay, so not much further ahead other than its some sort of, in my experience, ICD (interface control document which details the inputs and outputs of data and their formats at an interface so that two systems communicating can be programmed to accept and provide data in the agreed to formats).

This appears similar to API, so what are all the APIs being used for by folks here? Is it simply to program the MT routers from some other software?
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: API Links

Fri Aug 19, 2022 5:23 pm

Is just another protocol like HTTP...
No matter if IIS, Apache, nginx, etc., no matter if is etscape, opera, firefox, internet explorer...
 
saintmg
just joined
Posts: 2
Joined: Sat Aug 20, 2022 3:15 pm

Re: API Links

Sat Aug 20, 2022 3:19 pm

Hi, any API for PHP, JS or Python for hAP lite TC RB941-2nD-TC?

I wanted to create a hotspot management system so I can rent my Internet connection via WiFi. Thanks!
 
User avatar
BartoszP
Forum Guru
Forum Guru
Posts: 2855
Joined: Mon Jun 16, 2014 1:13 pm
Location: Poland

Re: API Links

Sun Aug 21, 2022 11:54 am

Have you read https://wiki.mikrotik.com/wiki/Manual:API ? Is it so hard to find that page? If yes, what could be done do make searching forum better instead of search.php?keywords=api+links ? What's wrong with the topic itself viewtopic.php?t=29073 ?
 
atuxnull
Frequent Visitor
Frequent Visitor
Posts: 82
Joined: Tue Feb 07, 2017 10:02 pm

Re: API Links

Tue Aug 23, 2022 8:57 am

i have a few queues and i would like to create a shortcurt to my desktop PC (Win 10) so i could enable/disable a particular queue, without user interaction.
I have basic programming training, nothing special. So even a bat file would do the trick. Is there a way to do this please?
 
User avatar
Chupaka
Forum Guru
Forum Guru
Posts: 8709
Joined: Mon Jun 19, 2006 11:15 pm
Location: Minsk, Belarus
Contact:

Re: API Links

Sat Sep 17, 2022 2:47 pm

i have a few queues and i would like to create a shortcurt to my desktop PC (Win 10) so i could enable/disable a particular queue, without user interaction.
I have basic programming training, nothing special. So even a bat file would do the trick. Is there a way to do this please?
SSH. Simply setup SSH access with key (instead of password, so you don't need to type it) - and you can run any command from .bat by simply executing something like
ssh admin@router_IP "/queue simple disable queue1"
 
FIBRANETPLUS
just joined
Posts: 6
Joined: Fri May 13, 2022 2:42 am

Re: API Links

Sat Jan 14, 2023 9:29 pm

Hello, I need enable disable L2TP-Server
Any idea?
$API->write("/ppp/l2tp/disable",true); not work!
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: API Links

Sat Jan 14, 2023 10:50 pm

i do not know if /ppp/l2tp/ exist, but the command on terminal are:
/interface l2tp-server server set enabled=no
/interface l2tp-server server set enabled=yes
 
FIBRANETPLUS
just joined
Posts: 6
Joined: Fri May 13, 2022 2:42 am

Re: API Links

Sun Jan 15, 2023 6:12 pm

i do not know if /ppp/l2tp/ exist, but the command on terminal are:
/interface l2tp-server server set enabled=no
/interface l2tp-server server set enabled=yes
thanks
$API->write("/interface/l2tp-server/server/getall",true);
response
<<< [36] /interface/l2tp-server/server/getall >>> [3/3] bytes read. >>> [3, 304]!re >>> [13/13] bytes read. >>> [13, 290]=enabled=true >>> [13/13] bytes read. >>> [13, 276]=max-mtu=1450 >>> [13/13] bytes read. >>> [13, 262]=max-mru=1450 >>> [14/14] bytes read. >>> [14, 247]=mrru=disabled >>> [36/36] bytes read. >>> [36, 210]=authentication=chap,mschap1,mschap2 >>> [21/21] bytes read. >>> [21, 188]=keepalive-timeout=30 >>> [23/23] bytes read. >>> [23, 164]=max-sessions=unlimited >>> [35/35] bytes read. >>> [35, 128]=default-profile=default-encryption >>> [14/14] bytes read. >>> [14, 113]=use-ipsec=yes >>> [26/26] bytes read. >>> [26, 86]=ipsec-secret=xxxxxxxxxx >>> [26/26] bytes read. >>> [26, 59]=caller-id-type=ip-address >>> [27/27] bytes read. >>> [27, 31]=one-session-per-host=false >>> [22/22] bytes read. >>> [22, 8]=allow-fast-path=false >>> [5/5] bytes read. >>> [5, 1]!done OkDisconnected...
I try

Disable
$API->write("/interface/l2tp-server/server/set",false);
$API->write("=enabled=false",true); 
Enable
$API->write("/interface/l2tp-server/server/set",false);
$API->write("=enabled=true",true); 
Work Fine, thanks
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: API Links

Sun Jan 15, 2023 8:52 pm

Work Fine, thanks
👌

Who is online

Users browsing this forum: Cmon169 and 14 guests