Page 1 of 1

API on RouterOS v7

Posted: Fri Oct 02, 2020 8:28 pm
by jmginer
Hello,

the API is working on RouterOS 7 like in v6 ?

Or we need to change something on our custom developments?

Thanks!

Re: API on RouterOS v7  [SOLVED]

Posted: Sun Oct 04, 2020 5:32 am
by Amm0
Good question, I just tried it, seems to work the same.

If it doesn't work...you may want to look at the API client you're using to see if supports the newer API authentication scheme (in 6.43, the login sequence changed, so older library version may not be able to connect with v7 or recent v6 ROSs: https://wiki.mikrotik.com/wiki/Manual:API#Initial_login). Also MT API with TLS ("api-ssl"), a few things have to align (e.g. most OS/libraries check if a TLS certificate is "valid", TLS versions/cyphers used, etc – so stuff like that can give the false sense the API doesn't work)

I tried the MT API against ROSv7.1beta2 on an Audience, and used a ROSv7 specific command (/routing/table), seem to work both un-encrypted and using TLS/SSL using node.js with @aluisiora handy NPM https://github.com/aluisiora/routeros-client
const RouterOSClient = require('routeros-client').RouterOSClient;

let testROSv7 = function (ip = process.env.MT_IP || '192.168.88.1') {
    const api = new RouterOSClient({
        host: ip,
        user: process.env.MT_USER || "admin",
        password:  process.env.MT_PASSWD || "",
        tls: { rejectUnauthorized: false }, // api-ssl uses self-signed cert, for testing ROSv7, any form of SSL will do
        port: 8729
    });

    api.connect().then((client) => {
    	// in ROSv7, route table and rules have moved from "/ip/route/rule" to "/routing/table" & "/routing/rule"
    	// assuming the API worked the same, it should be able read it using the new "ROS URL" for it
        client.menu("/routing/table").getOnly().then((result) => {
            console.log(result); 
            api.close();
        }).catch((err) => {
            console.log(err); // Some error...
        });
    }).catch((err) => {
        console.log(err)
        // Connection error
    });
}

testROSv7()

Re: API on RouterOS v7

Posted: Mon Oct 05, 2020 5:14 pm
by jmginer
Good question, I just tried it, seems to work the same.

Thanks for your test!

Re: API on RouterOS v7

Posted: Mon Oct 12, 2020 8:21 am
by kiler129
PHP libraries also work properly, I even developed a small project for wireguard automation around the API and it works flawlessly.