Node.js is a great tool for interacting with REST API’s that deal with JSON in responses, but you may need something more programmatic. And if you’ve been interacting with NS1’s API via Node.js and require a high level client library, this update is for you.
Today we’re happy to announce that NS1 has a JavaScript client library – compatible with Node.js versions 5 and above.
We use this library ourselves for our frontend web portal and will be updating and making improvements to the API over time.
If you wish to use it on the client side, please contact us as we have CORS restrictions active.
Install via NPM like so:
npm install ns1
Example usage:
var NS1 = require('ns1') NS1.set_api_key([your api key]) NS1.Zone.find().then(function(zones) { console.log(zones) //=> Array of NS1.Zone objects }) NS1.Zone.find('yourzone.com').then(function(zone) { console.log(zone) //=> NS1.Zone object of just the zone zone.update({ zone: 'anotherdomain.com' }).then(function(zone) { console.log(zone) //=> NS1.Zone object w/ updated info }) }) NS1.Zone.create({ zone: 'yourzone.com' }).then(function(zone) { console.log(zone) //=> Your newly created zone }) new NS1.Zone({ zone: 'yourzone.com' }).save().then(function(zone) { console.log(zone) //=> same as above })
Useful links:
NPM: https://www.npmjs.com/package/ns1/
Documentation: http://ns1.github.io/ns1-js/
Github: https://github.com/ns1/ns1-js