New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mozscape-request

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mozscape-request

Nodejs client for Mozscape API

  • 0.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-88.89%
Maintainers
1
Weekly downloads
 
Created
Source

Moz

  • Get a moz authentication token and secret
  • Moz api documentation

installation

  npm install mozscape-request

Documentation

Basic Usage

Require the module and pass your options

  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

Build and run a query

  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.

Batch mode

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

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){

  });

Flags

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']
  });

Run tests

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

Generate API documentation

  npm run-script doc

Todo:

  • Support request frequency rate

Special Thanks

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.

Keywords

FAQs

Package last updated on 05 Sep 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc