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 🙏

© 2025 – Pkg Stats / Ryan Hefner

top-pages

v0.7.4

Published

Retreive a list of the most popular pages from a given domain along with their estimated monthly traffic

Downloads

19

Readme

top-pages

Fetch the most popular pages on a given domain, with options to use various data sources

This package is intended to be used as either

  • a module within other libraries (prototype ready)
  • a CLI tool (not coded yet)

To use Google Analytics to pull data from your own sites, you must get a keys.json file.

See notes about Google Analytics Integration below

Configure your API keys and credentials in a .env file

Usage

See test.js for more examples

let get_top_pages = require('top-pages')

// load your key file
let ga_keys = require('./keys.json')

// use this inside of an async block of code

// when you supply keys, you can use google analytics data
// without ga keys, the tool relies on competitive analytics tools
// in the future this package will support a variety of libraries
let top_pages = await get_top_pages('https://www.example.com', { ga_keys: ga_keys })

let top_url = Object.keys(top_pages)[0]

let top_url_views = top_pages[top_url]

Use Cases

I use this package in my amazon Affiliate Link Fixer to help users prioritize their most popular pages.

You could also use this for quick competitive analysis to find the most popular contant among a list of websites.

Google Analytics Integration

Use Google Analytics by placing a keys.json file and loading it.

Follow this video, up until you get the JSON file

Involves creating a 'service account' with Google

https://www.youtube.com/watch?v=r6cWB0xnOwE

Then sharing access to this account from your analytics admin section

Remember to enable "Google Analytics Reporting API"

https://console.developers.google.com/apis/api/analyticsreporting.googleapis.com/overview?project=1049178100145

Quirks

Pagination

Google Analytics API returns up to 10,000 results per request.

You will have to make additional requests to get more data.

However, this also means you might not need all the data and it can be achieved in two ways:

  • filtering or
  • limiting the amount of pages.

Limitations

SpyFu only returns the top 5 results when you're not logged in.