Getting started with the uptimerobot api with nodejs

Today, I'm going to show you how to get started with our nodejs connector for the uptimerobot api, you will see how simple it is to use the uptimerobot api with nodejs!

First, you will need to include our uptimerobot api nodejs package that you can find on npm: https://www.npmjs.com/package/@lazydb_community/uptimerobot

const UptimeRobot = require('@lazydb_community/uptimerobot');

Now that uptimerobot is added to our project, we just have to initialize it with your API key (which you can found on uptimerobot.com, either an account api key or monitor api key)

const UptimeRobotClient = new UptimeRobot('your-api-key');

Congrats, you can now use the uptimerobot api with nodejs!

Now you can use any method of the uptimerobot api. To do so you just need to call the method with all the required arguments and optionally the other arguments in an object as the last argument, here is an example to use the newMonitor method.

UptimeRobotClient.newMonitor("friendly name","https://mywebsite.com","1", {}).then(data => { const monitor_id = data.monitor.id; console.log("New monitor created with id ", monitor_id); }).catch(error => { console.log(error); })

Here is the complete example for you, try to copy-paste it to see how it works!

const UptimeRobot = require('@lazydb_community/uptimerobot'); const UptimeRobotClient = new UptimeRobot('your-api-key'); UptimeRobotClient.newMonitor("friendly name","https://mywebsite.com","1", {}).then(data => { const monitor_id = data.monitor.id; console.log("New monitor created with id ", monitor_id); }).catch(error => { console.log(error); })