Page 1 of 1

How to use some API from LAN?

Posted: Sun Apr 22, 2012 10:38 pm
by JoZu
Is there any way to use some API to send and receive commands from LAN? To run directly from the pages of the router mikrotik own.
Send commands via HTML?
JSP Pages?

Thanks so much.

Re: How to use some API from LAN?

Posted: Mon Apr 23, 2012 8:30 pm
by boen_robot
There is an API protocol with clients in lots of server side scripting and desktop languages.

Is that the kind of thing you're after? The "from LAN" in your post sounds a little vague, especially considering the sentence after it... if this is supposed to mean "from outside the router", then yes, that's what the API is for - allowing you to send commands and/or receive information between a client (a web server or a desktop app) and RouterOS.

Re: How to use some API from LAN?

Posted: Mon Apr 23, 2012 9:24 pm
by JoZu
In this case I mean a javascript api built into the router itself through a file. (perhaps mikrotik.js? jsp page? ssh command via html page?)
That javascript could be used for through a web page (inside the router) to control the hotspot.
It could make hotspot management pages without relying on any external server, accessed through the wifi itself.
Do not know if I explained very well, thank you and sorry my english.

Re: How to use some API from LAN?

Posted: Tue Apr 24, 2012 12:01 pm
by boen_robot
JavaScript runs on a browser (the HTTP client), not the router (the HTTP server), so there's no way MikroTik could do that, and if they did do something similar (e.g. send aribitrary commands to a special URL on the router's HTTP server), it would be very insecure, as you're essentially allowing the client to do whatever they want.

If the HTTP server supported a server scripting engine (JSP, PHP, a proprtietary language), you would've been able to do that, but there's no such support, and AFAIK, no plans to add such (beyond the pseudo server language for outputting hotspot variables that is).

You could always make the router redirect or dst-nat to a separate web server that controls it via the API protocol. The end user wouldn't know (or care about) the difference.