ojisatriani/mikrotikapi

Router Mikrotik API

1.0.4 2019-08-27 07:38 UTC

This package is auto-updated.

Last update: 2024-04-27 18:50:51 UTC


README

Client API for RouterOS/Mikrotik

Instalation

Via composer:

composer require ojisatriani/mikrotikapi

Manual composer.json in require section:

"require": {
    "ojisatriani/mikrotikapi": "dev-master", // <- this line
}

Basic Usage:

use OjiSatriani\MikrotikApi\Mikroji;
$router = Mikroji::connect('192.168.3.1','user-api','user-api');
echo $router->ram() .'<br />'; // 1652.2
echo $router->hdd() .'<br />'; // 915.8
echo $router->cpu() .'<br />'; // 0
echo $router->rx('ether1') .'<br />'; // 1.85Kb/Mb/Gb/Tb
echo $router->tx('ether1') .'<br />'; // 47.7Kb/Mb/Gb/Tb
echo $router->rxInMb('ether1') .'<br />'; // 1.85 (view chart or graph) 
echo $router->txInMb('ether1') .'<br />'; // 47.70 (view chart or graph)
echo json_encode($router->getInterface()) .'<br />'; //  {"ether1":"ether1","ether2:ether2","ether3:ether3"}
echo $router->command('log/print'); //  return array()

Mikrotik Wiki page at http://wiki.mikrotik.com/wiki/API_PHP_class

https://github.com/BenMenking/routeros-api

Configure API credentials

RouterOS Winbox

  1. Enabling API.

Go to IP -> Services and enable api service.

  1. Creating API user.

Go to System -> Users, tab Groups. Create new group with permissions: api, read, write.

Then after group created go to tab Users and create new. Associate this user with group previously created.

Done.