API docs

If you haven’t noticed yet - the long promised API is included with v3.
Here are some preliminary docs for it:

http://wiki.mikrotik.com/wiki/API

Normunds,

this is great. I hope docs will be extended with regard to API specific commands etc.

How about the possibility to encrypt communication with the API interface? I think this is a must for serious applications.
I know this is the first beta, so if this is already on the to-do-list, forget this :wink:

Best regards,
Christian Meis

being updated in real time, now include a simple client in python

Ok, I’ll put a stone on my F5 key :stuck_out_tongue:
Best regards,
Christian Meis

Excellent. Need someone to roll it all up in a Perl module :smiley:

This is excellent.

A comparable :list command would be nice so we know what commands the API on the current version provides. If this already exists then ignore.

Sam

You could use the encrypted tunnels ip and send it securely.

It would be nice to bind ip services to specific ips only as well, like the new API service, winbox, telnet, ssh, etc. I know you can firewall them but if they aren’t listening in the first place its better. A router with a ton of ip addresses is listening on a lot of ports. If you could see a netstat -an i bet it would surprise most people.

Yeah¡¡¡ THAT’S SWEET¡¡¡¡¡ :sunglasses: :sunglasses: :sunglasses:

Docs updated: http://wiki.mikrotik.com/wiki/API

How can I request a wireless scan via the API ?

My goal is to scan for a few seconds to get a list of available SSIDs. In CLI mode I cannot scan for X number of seconds either - I’m hoping there is a way to scan with the API, even if I have to tell it to cancel on my own.

  1. Scan for a few seconds.

  2. Get a list of SSIDs and if their status.

  3. Change wireless properties to allow connection to specific SSID, possibly changing security profile.

  4. If no known wireless profiles connect to strongest unsecured.

If I can simply scan using the API I can do the rest.

PS - There used to be a :list command, is this option available to know what API commands there are ?

Sam

ah ha …

/interface/wireless/scan
=number=w-internal

although I’m not sure how to cancel it. . . I tried /cancel but doesn’t stop it … I also tried adding a tag but I cannot seem to get the syntax right. Normis please help me : )

Sam

it seems the wiki api.py newer example file has problems?

Traceback (most recent call last):
File “api.py”, line 161, in
main()
File “api.py”, line 142, in main
r = select.select([s, sys.stdin], , , None)
select.error: (10038, ‘An operation was attempted on something that is not a socket’)

I am running this on windows python 2.5.1 - can you confirm this works on your systems ?

Sam

To cancel scan (as per wiki example)

1> /interface/wireless/scan
1> =.id=wlan1
1> .tag=Mouse
1>

scan scan

2> /cancel
2> =tag=Mouse
2>

Is it possible to request or listen for graph data via API?

using API you can only get information which can be acquired using console.


so, using API you cannot get graphing results, but you can set/change settings

Thanks for the answer, I was asking to make sure that I have not overlooked anything. However I have read sentence on the wiki “The API is a way to create your own versions of Winbox”, not that I want to, but doesnt it suggests that it should be possible to do anything that is in WinBox with the API? But I guess the person who wrote that didnt meant that literally.
It would be nice if there was a way how to get to statistics data that is used to create graphs, if I am not mistaken, there is currently no way how to get to them.

you cannot see graphing results using winbox. winbox is graphical representation of console, everything that can be done in console can be done in winbox and vice versa.

so, yes, one who wrote that you can build your own winbox really meant that.

graph results can only be seen though web browser.

I am not sure we are talking about the same thing, because if I open Tools/Graphing/Whatever in winbox, I can clearly see daily, weekly, monthly and yearly graph, just like in web interface.

Great works guys it help …

I have not seen mentioned anywere how to get or set specific fields. So far I have guessed:
/ip/firewall/get
=.id={id from getall}

which displays most common fields from a record. However what if I want to get some field like comment, routing-mark, etc… . I have tried a few things, like adding another param ‘value’, ‘valuename’, ‘name’… with name of the field, but nothing seems to be it.
I have the feeling that I might be overlooking something obvious.

EDIT:
I was apparently blind, because when I have looked for a hundredth time, I could see all fields there (when I executed /get). So everybody can safely ignore this ‘question’/ :wink:

To clarify this, in /getall there not all fields - only most common are there, but for all records. In /get there are apparently all (which I have previously overlooked), but you have to specify a record. All this is pretty consistent with the console.