TS RouterOS

0 views

Problem

Talking to a MikroTik router through its RouterOS API means handling connection, login and error cases correctly every time.

Core Idea

A minimal TypeScript client for the RouterOS API, with TCP and SSL support and a result object returned for every async call.

Guarantees

Supports both the old and new login methods. Expected failures like bad credentials or timeouts are returned, not thrown.

Tradeoffs

The client covers the core: connect, login, run commands and handle events. Other commands go through runCommand, so there are no typed wrappers for every RouterOS command.

typescriptmikrotiknetworkingopen-source

Overview#

TS RouterOS is a minimal TypeScript client for the MikroTik RouterOS API. It connects over TCP on port 8728 or over SSL on port 8729, then sends commands and parses the responses into plain objects.

How It Works#

You create a client for one router, connect, log in, and run commands. The client picks the legacy or challenge login flow automatically.

Every async call returns a result with a status, so the caller decides how to branch. Expected failures come back as results rather than thrown errors.

Design Choices#

  • Factory-style API built from plain functions, with no classes
  • Result pattern for every async operation
  • Generic runCommand for any RouterOS command, with room for custom helpers