{"id":13464965,"url":"https://github.com/aluisiora/routeros-client","last_synced_at":"2025-03-25T13:32:50.452Z","repository":{"id":47441198,"uuid":"108572984","full_name":"aluisiora/routeros-client","owner":"aluisiora","description":"Abstraction layer over the node-routeros API","archived":true,"fork":false,"pushed_at":"2021-01-18T00:45:51.000Z","size":442,"stargazers_count":71,"open_issues_count":3,"forks_count":36,"subscribers_count":5,"default_branch":"development","last_synced_at":"2025-03-17T23:18:14.323Z","etag":null,"topics":["api","javascript","mikrotik","mikrotik-api","mikrotik-routerboard-api","mikrotik-wrapper","node","node-routeros","nodejs","promise","routerboard","routerboard-api","routerboard-wrapper","routeros","routeros-api","routeros-node","routeros-wrapper","typescript","wrapper"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aluisiora.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-27T17:08:09.000Z","updated_at":"2025-02-04T20:20:31.000Z","dependencies_parsed_at":"2022-09-26T16:21:15.981Z","dependency_job_id":null,"html_url":"https://github.com/aluisiora/routeros-client","commit_stats":null,"previous_names":[],"tags_count":43,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aluisiora%2Frouteros-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aluisiora%2Frouteros-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aluisiora%2Frouteros-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aluisiora%2Frouteros-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aluisiora","download_url":"https://codeload.github.com/aluisiora/routeros-client/tar.gz/refs/heads/development","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245471229,"owners_count":20620903,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","javascript","mikrotik","mikrotik-api","mikrotik-routerboard-api","mikrotik-wrapper","node","node-routeros","nodejs","promise","routerboard","routerboard-api","routerboard-wrapper","routeros","routeros-api","routeros-node","routeros-wrapper","typescript","wrapper"],"created_at":"2024-07-31T14:00:53.626Z","updated_at":"2025-03-25T13:32:49.979Z","avatar_url":"https://github.com/aluisiora.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# Discontinued\n\n***I worked on this project in my spare time, but unfortunately I no longer work with mikrotik devices and don't have the free time anymore, so consider it as discontinued. Feel free to fork this project and create your own spin.***\n\n# RouterOS Client\nThis is a client wrapper for [node-routeros](https://github.com/aluisiora/node-routeros) api for doing common tasks and making the api easier to use for small and large NodeJS projects.\n\n## Getting Started\nThese instructions will help you install and use some of the client features, you can get a complete documentation in the [wiki](https://github.com/aluisiora/routeros-client/wiki).\n\n### Prerequisites\nYou must be familiar with [Promises](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise), how to chain it, how to catch errors and etc.\n\n### Installing\nYou can install by using npm:\n```\nnpm install routeros-client --save\n```\nNote: you are not required to install `node-routeros` since it's already a dependency of this lib.\n\n## Features\n[Everything you get from the `node-routeros`](https://github.com/aluisiora/node-routeros) is still here, plus:\n * You can save the menu and reuse it for multiple operations.\n * There is a \"Model\" feature where you can fire commands on each entry of a menu individually (check the examples).\n * Easy to read and write reusable code.\n\n## Examples\nHere are some short examples of usage, head to the [wiki](https://github.com/aluisiora/routeros-client/wiki) for a complete documentation.\n### Connecting\n```javascript\nconst RouterOSClient = require('routeros-client').RouterOSClient;\n\nconst api = new RouterOSClient({\n    host: \"192.168.88.1\",\n    user: \"admin\",\n    password: \"123456\"\n});\n\napi.connect().then((client) =\u003e {\n    // After connecting, the promise will return a client class so you can start using it\n\n    // You can either use spaces like the winbox terminal or\n    // use the way the api does like \"/system/identity\", either way is fine\n    client.menu(\"/system identity\").getOnly().then((result) =\u003e {\n        console.log(result.identity); // Mikrotik\n        api.close();\n    }).catch((err) =\u003e {\n        console.log(err); // Some error trying to get the identity\n    });\n\n}).catch((err) =\u003e {\n    // Connection error\n});\n```\n### Printing only VLAN interfaces\n```javascript\napi.connect().then((client) =\u003e {\n\n    client.menu(\"/interface\").where(\"type\", \"vlan\").get().then((results) =\u003e {\n        // results is an array of all the vlan interfaces\n    }).catch((err) =\u003e {\n        // error getting interfaces\n    });\n\n}).catch((err) =\u003e {\n    // Connection error\n});\n```\n### Adding and editing a firewall rule\n```javascript\napi.connect().then((client) =\u003e {\n\n    const filterMenu = client.menu(\"/ip firewall filter\");\n\n    filterMenu.add({\n        chain: \"forward\",\n        action: \"accept\",\n        protocol: \"tcp\",\n        dstPort: 80\n    }).then((response) =\u003e {\n        // response should be an object like { ret: \"*3C\" }\n        return filterMenu.where(\"id\", response.ret).update({\n            srcAddress: \"192.168.88.5\"\n        });\n\n    }).then((response) =\u003e {\n        // response should be an empty array [] since, \n        // if there is no error, updates return nothing, meaning success\n        api.close();\n    }).catch((err) =\u003e {\n        // error adding or eiditing\n    });\n\n}).catch((err) =\u003e {\n    // Connection error\n});\n```\n### Using the Model\n```javascript\napi.connect().then((client) =\u003e {\n\n    client.menu(\"/ip proxy access\").getModel().then((results) =\u003e {\n\n        // Suppose we want to disable acl #2 on the access list\n        results[2].disable(); // this returns a Promise too\n\n        // If we want to remove acl #5\n        results[5].remove().then(() =\u003e {\n            // removed successfully\n        }, (err) =\u003e {\n            // error trying to remove\n        });\n\n        // Or if we want to update acl #0\n        results[0].update({\n            comment: \"Updated through Model\"\n        }).then((result) =\u003e {\n            // result is the updated version\n        }).catch((err) =\u003e {\n            // error updating\n        });\n\n    }).catch((err) =\u003e {\n        // error getting proxy access list\n    });\n\n}).catch((err) =\u003e {\n    // Connection error\n});\n```\n### Creating a model from an item\n```javascript\napi.connect().then((client) =\u003e {\n\n    client.menu(\"/interface\").where({ interface: \"ether1\"}).getOnly().then((result) =\u003e {\n\n        const ether1 = client.model(result);\n\n        ether1.update({\n            comment: \"WAN\"\n        }).then((updatedEther1) =\u003e {\n            // Should return an updated version of the ether1,\n            // but since it is the same object...\n            console.log(ether1 === updatedEther1); // true\n\n            console.log(ether1.comment); // WAN\n        }).catch((err) =\u003e {\n            // error updating\n        });\n\n    }).catch((err) =\u003e {\n        // error getting proxy access list\n    });\n\n}).catch((err) =\u003e {\n    // Connection error\n});\n```\n### Streaming content\n```javascript\napi.connect().then((client) =\u003e {\n\n    // The stream function returns a Stream object\n    // so you are able to pause, resume or stop\n    const torch = client.menu(\"/tool torch\")\n        .where({interface: \"ether1\"})\n        .stream((err, data, stream) =\u003e {\n            if (err) return err; // got an error while trying to stream\n\n            console.log(data); // the data from the stream itself\n\n            // Will start the countdown after the \n            // first stream of data is received\n            stopTorching(); \n        });\n\n    // Variable to store the timeout\n    let finalCountdown;\n    const stopTorching = function(){\n        // If the timeout wasn't set yet\n        if (!finalCountdown) {\n            // Start counting 5 seconds to stop the stream\n            finalCountdown = setTimeout(() =\u003e {\n                torch.stop();\n            }, 5000);\n        }\n    };\n\n}).catch((err) =\u003e {\n    // Connection error\n});\n```\n# Cloning this repo\nNote that, if are cloning this repo, you must be familiar with [Typescript](https://www.typescriptlang.org/) so you can make your changes.\n## Running the tests\nThere aren't that many tests, but in order to run them, I used [RouterOS CHR](https://mikrotik.com/download) (look for the Cloud Hosted Router if you aren't familiar with it yet) on a virtual machine with 4 interfaces, where the first interface is a bridge of my network card:\n\n![VirtualBox RouterOS CHR Conf](https://raw.githubusercontent.com/aluisiora/routeros-client/master/images/routeros-chr-interfaces.gif)\n\nAlso, the vm gets the 10.62.0.25 ip address, you might want to change that in the test files according to network.\nThe user and password was set to admin and admin respectively.\n\nRun the tests using:\n```\nnpm test\n```\nThe testing was created using [mocha](https://mochajs.org/) and [chai](http://chaijs.com/).\n# TODO\n * Write more tests\n# License\nMIT License\n\nCopyright (c) 2017 Aluisio Rodrigues Amaral\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faluisiora%2Frouteros-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faluisiora%2Frouteros-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faluisiora%2Frouteros-client/lists"}