npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

mozscape-request

v0.0.4

Published

Nodejs client for Mozscape API

Downloads

47

Readme

Moz

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.