Making REST API calls to Junos with Node.js
In this recipe, we'll make an example app, rest.js
, using Node.js to connect to the Junos OS REST API in order to make procedure calls. We'll use Node.js's built-in HTTPS support, augmented with some extra external modules simply for convenience. For utility value, we'll provide some command-line options to customize how the application runs.
Command line option | Description |
| Specify the output format |
| Specify the actual RPC call |
| Self-signed certificate from router |
| HTTPS port number, default |
| Username to authenticate with |
Getting ready
In order to complete this recipe, you need access to a JUNOS router device running at least JUNOS 14.2, and you should have completed the previous recipe on REST API Setup. The JavaScript code that we'll use is compatible with Node.JS v0.12, v4.x and v6.x. You should also be familiar with npm
, the Node.js package manager.
How to do it...
The steps for the recipe are...