James Bachini

Node.js client for Moz API (MozScape)

node moz api

Update 2020:

This is outdated now and not maintained. I’d recommend using one of these packages:

Original Post:

I was doing some work with SEO domains and realised there wasn’t a node.js client for the MozScape API… so after Googling and not finding what I was looking for I built one.

What this basically does is provide SEO metrics on the URL you provide.

Here’s the download link: http://jamesbachini.com/misc/moznode/moznode.zip

Full code below:

var request = require("request");
var crypto = require('crypto');

// Get credentials from https://moz.com/products/mozscape/access
mozAccessID = "mozscape-xxxxxxxxxx";
mozSecretKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";

mozExpires = parseInt((Date.now() / 1000).toFixed()) + 300;
console.log (mozExpires);
mozStringToSign = mozAccessID+"\n"+mozExpires;
//mozSig = crypto.createHmac('sha1', mozSecretKey).update(mozStringToSign).digest('hex');

mozSig = crypto.createHmac('sha1', mozSecretKey).update(mozStringToSign).digest('base64');
mozSafeSig = encodeURIComponent(mozSig);

mozURL = 'jamesbachini.com';
mozCols = '103079247904'; // Learn more here: https://moz.com/help/guides/moz-api/mozscape/api-reference/url-metrics

mozRequest = "http://lsapi.seomoz.com/linkscape/url-metrics/"+encodeURIComponent(mozURL)+"?Cols="+mozCols+"&AccessID="+mozAccessID+"&Expires="+mozExpires+"&Signature="+mozSafeSig;

request(mozRequest, function (error, response, body) {
// if (!error && response.statusCode == 200) {
console.log(body);
// }
});

Get The Blockchain Sector Newsletter, binge the YouTube channel and connect with me on Twitter

The Blockchain Sector newsletter goes out a few times a month when there is breaking news or interesting developments to discuss. All the content I produce is free, if you’d like to help please share this content on social media.

Thank you.

James Bachini

Disclaimer: Not a financial advisor, not financial advice. The content I create is to document my journey and for educational and entertainment purposes only. It is not under any circumstances investment advice. I am not an investment or trading professional and am learning myself while still making plenty of mistakes along the way. Any code published is experimental and not production ready to be used for financial transactions. Do your own research and do not play with funds you do not want to lose.


Posted

in

,

by