npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mikro-client

v0.5.3

Published

Simple library using socket API to connect and control Mikrotik devices in JavaScript or TypeScript. Allows for easy automation of Mikrotik device management and configuration tasks.

Downloads

63

Readme

mikro-client

This library, written in TypeScript and also compatible with JavaScript, provides a simple connection via TCP sockets to send and receive command-line commands from MikroTik. With this library, you can easily and quickly control and get information from a MikroTik device.

version documentation in:

  • English
  • Spanish

Installation

npm install mikro-client

or

yarn add mikro-client

Usage

To use the class, you must first import it into your project:

import { MikroClient } from 'mikro-client'

Then, you can create a new instance of the class by providing the necessary configuration options:

const options = {
  host: 'XXX.XXX.XXX.XXX',
  port: XXXX,
  username: 'xxxxx',
  password: 'xxxxx',
  timeout: 5000,
}
const mikro = new MikroClient(options)

Once you have an instance of the class, you can use the "talk" method to send MikroTik commands to the device and receive the response:

const response = await mikro
  .talk(['/interface/print'])
  .then((response) => {
    console.log(response)
  })
  .catch((error) => {
    console.error(error)
  })

You can also specify the type of response you want to receive using the optional "type" argument:

const response = await mikro
  .talk(['/interface/print'], 'object')
  .then((response) => {
    console.log(response)
  })
  .catch((error) => {
    console.error(error)
  })

Examples

Here are some examples of MikroTik commands that you can send using the "talk" method:

  • Get network interface information:
const response = await mikro
  .talk(['/interface/print'])
  .then((response) => {
    console.log(response)
  })
  .catch((error) => {
    console.error(error)
  })
  • Add a firewall rule:
mikro
  .talk([
    '/ip/firewall/filter/add',
    '=chain=forward',
    '=protocol=tcp',
    '=dst-port=80',
    '=action=accept',
  ])
  .then((response) => {
    console.log(response)
  })
  .catch((error) => {
    console.error(error)
  })
  • Get connected user information:
mikro
  .talk(['/ip/hotspot/active/print'])
  .then((response) => {
    console.log(response)
  })
  .catch((error) => {
    console.error(error)
  })
  • Create a hotspot user:
mikro
  .talk([
    '/ip/hotspot/user/add',
    '=name=example',
    '=password=example',
    '=profile=default',
  ])
  .then((response) => {
    console.log(response)
  })
  .catch((error) => {
    console.error(error)
  })

Information

For more information on the MikroTik commands that you can send using the MikroApi class, we recommend consulting the MikroTik documentation, which is available at the following link:

  • API - RouterOS - MikroTik Documentation

On this page, you will find a complete list of available MikroTik commands and their respective parameters. You will also find examples of how to use these commands in the MikroTik command line and API.

I hope this helps you get more information on MikroTik commands and how to use them with the MikroApi class. If you have any additional questions, don't hesitate to ask.


License

  • MIT

Created by jjjjose - 2022