npm install mozscape-request
var moz = require('node-moz')({
accessId: '<YOUR ACCESSID>',
secret: '<YOUR SECRET>',
expires: 300 // Optional, default set to 300
});
Available options:
- accessId {string} : Mozscape access id
- secret {string} : Mozscape secret
- url {string} [optional] : Api url, Default: http://apiv2.ahrefs.com/,
- expires {boolean} [optional] : Expires delay, Default: 300
var query = moz.newQuery('url-metrics')
.target('http://moz.com')
.cols(['canonical_url', 'external_links', 'root_domains_linking', 'moz_rank_url'])
.sort('page_authority')
.limit(10)
moz.send(query, function(err, result){
var canonical_url = result.uu;
var external_links = result.ued;
var root_domains_linking = result.uipl;
var moz_rank_url = result.umrp;
});
Result contains the response of the mozscape API. Check the documentation of each endpoint to get the key corresponding to the parameter you have passed.
To use the batch mode, simply pass an array to the targets
method. Batch mode request use POST method.
Note: Batch mode is currently working only on the url-metrics endpoint
var query = moz.newQuery('url-metrics')
.target(['http://moz.com', 'http://optimiz.me'])
.cols(['canonical_url', 'external_links', 'root_domains_linking', 'moz_rank_url'])
.sort('page_authority')
.limit(10)
moz.send(query, function(err, result){
});
Metadata request are done in a similar fashion:
moz.metadata('last_update', function(err, last_update){
});
// Which is the short for:
var query = moz.newQuery('metadata')
.target('last_update');
moz.send(query, function(err, result){
});
Use the bitsToFlags method to translate a bitflags sum to an array of flags:
var query = moz.newQuery('links')
.target('http://moz.com'])
.linkCols(['Flags'])
.sort('page_authority')
.limit(10)
moz.send(query, function(err, result){
// result.if return the bitflags sum for the flag linkCols parameters
var flags = moz.bitsToFlags(result.if);
// flags: ['no_follow', 'img', '301_redirect']
});
You must specify your token to run the test suite:
ACCESSID="<ACCESSID>" SECRET="<SECRET>" npm test
You can also run the tests agains your own target if needed (default is moz.com
):
TARGET=<YOUR TARGET> ACCESSID="<ACCESSID>" SECRET="<SECRET>" npm test
npm run-script doc
- Support request frequency rate
Developed for Optimiz.me, an online software designed to help working the SEO optimisation of your web site, by yourself, without the need of technical knowledge.
Développé pour Optimiz.me un logiciel en ligne conçu pour aider à travailler l'optimisation du référencement de votre site web, par vous-même, sans besoin de connaissances techniques.