Community discussions

MikroTik App
 
jmginer
Member Candidate
Member Candidate
Topic Author
Posts: 153
Joined: Tue Dec 11, 2012 4:56 am
Contact:

API on RouterOS v7

Fri Oct 02, 2020 8:28 pm

Hello,

the API is working on RouterOS 7 like in v6 ?

Or we need to change something on our custom developments?

Thanks!
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 3169
Joined: Sun May 01, 2016 7:12 pm
Location: California

Re: API on RouterOS v7  [SOLVED]

Sun Oct 04, 2020 5:32 am

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()
 
jmginer
Member Candidate
Member Candidate
Topic Author
Posts: 153
Joined: Tue Dec 11, 2012 4:56 am
Contact:

Re: API on RouterOS v7

Mon Oct 05, 2020 5:14 pm

Good question, I just tried it, seems to work the same.

Thanks for your test!
 
User avatar
kiler129
Member
Member
Posts: 352
Joined: Tue Mar 31, 2015 4:32 pm
Location: IL, USA
Contact:

Re: API on RouterOS v7

Mon Oct 12, 2020 8:21 am

PHP libraries also work properly, I even developed a small project for wireguard automation around the API and it works flawlessly.

Who is online

Users browsing this forum: No registered users and 16 guests