const conn = await Deno.connect( hostname: '192.168.88.1', port: 8728 ); const client = createClient( readable: conn.readable, writable: conn.writable );
private function getInterfaceStats() $query = new Query('/interface/print'); $interfaces = $this->api->query($query)->read();
: Users have noted that some advanced filtering (using the .query syntax) can be "tricky" compared to standard REST implementations. 2. Legacy "Binary" API
curl -k -u admin: https://192.168.88.1/rest/ip/address
This library provides typed helpers for many RouterOS menus including:
Before running any API examples, you must enable the API service on your router.
Python is one of the most popular languages for interacting with the API due to its simplicity and strong libraries. A. Prerequisites
One of the most common uses for the API is fetching system health data to feed into a dashboard or an alerting system. Using a library like RouterOS-api , you can quickly pull CPU and memory stats. routeros_api connection = routeros_api.RouterOsApiPool( 192.168.88.1 , username= , password= = connection.get_api() # Get system resources = api.get_resource( /system/resource = resource.get()
use RouterOS\Client; use RouterOS\Query; $client = new Client([ 'host' => '192.168.88.1', 'user' => 'admin', 'pass' => 'password' ]); // Get all active wireless registrations $query = new Query('/interface/wireless/registration-table/print'); $responses = $client->query($query)->read(); print_r($responses); Use code with caution. 5. Useful API Paths for Automation