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

gsc-trending-plus

v1.1.0

Published

Fetch your most visited and trending pages from Google Search Console.

Readme

📈 GSC Trending Plus

Fetch and display your most visited and trending pages directly from Google Search Console using a simple Node.js module.
Perfect for dashboards, analytics widgets, and SEO tools built with React, Next.js, or Node.js.


npm version License: MIT Node.js Google API


🚀 Features

✅ Fetch top-performing pages by Clicks, Impressions, CTR, and Position
✅ Works with Google Search Console API (via Service Account)
✅ Minimal setup — just one function call
✅ Supports both server-side (Node.js) and frontend (Next.js / React) usage
✅ Ideal for custom dashboards, SEO analytics, and reporting tools


🧠 Installation

npm install gsc-trending-plus

or

yarn add gsc-trending-plus

⚙️ Setup Guide

🧩 STEP 1 — Enable Search Console API in Google Cloud

  1. Go to Google Cloud Console.
  2. Create a new project (e.g., “yourdomain GSC API”).
  3. Navigate to APIs & Services → Library → search for “Search Console API” → click Enable.
  4. Go to APIs & Services → Credentials → Create Credentials → Service Account.
  5. Name it (e.g., gsc-service) → click Create and Continue → assign no special roles → click Done.
  6. Click your new Service Account → Keys → Add Key → Create New Key → JSON.
    • It will download a file like:
      gsc-service-xxxxxxxxxxxx.json
  7. Save this file securely (e.g., inside your project folder).
  8. Copy the Service Account Email (found in the Service Account details).

🧩 STEP 2 — Grant Access to Search Console

  1. Go to Google Search Console.
  2. Click Settings → Users and Permissions → Add User.
  3. Add your Service Account email (e.g., [email protected]).
  4. Grant Full or Restricted access (both work for read-only API calls).

🧩 STEP 3 — Add Your Key File

  • Save your JSON key file (e.g., ./service-account.json).
  • Never commit this file to Git — it’s ignored by default in .gitignore.
  • Keep it safe and private.

🧪 Usage Example

import getGSCTrendingData from 'gsc-trending-plus';

(async () => {
  const data = await getGSCTrendingData({
    keyFile: './service-account.json',
    siteUrl: 'https://yourdomain.com',
    startDate: '2025-10-01',
    endDate: '2025-10-31',
    limit: 5
  });

  console.log(data);
})();

Output Example:

[
  {
    "url": "https://yourdomain.com/blog/post1",
    "clicks": 1200,
    "impressions": 8500,
    "ctr": 14.12,
    "position": 4.8
  },
  {
    "url": "https://yourdomain.com/blog/post2",
    "clicks": 980,
    "impressions": 7100,
    "ctr": 13.8,
    "position": 5.2
  }
]

📊 Response Format

| Field | Description | |----------------|--------------------------------------| | url | Page URL from Google Search Console | | clicks | Number of user clicks | | impressions | Number of times the page appeared | | ctr | Click-through rate (%) | | position | Average ranking position |


✅ Verify It Works

  • Wait ~10–15 seconds after the first API call (cache warm-up).
  • Check your console — data should appear sorted by performance.
  • If you see "GSC config missing", verify your key file path and permissions.

❓ FAQ

Does this module store or send any personal data?

❌ No.
All data is fetched securely from your own Google Search Console property.

Can I use it in production?

✅ Yes.
Use server-side secrets or environment variables to keep your key file safe.


🔒 Security Tips

  • Never upload your Service Account JSON key to public repos.
  • Use .env or cloud secret storage in production.
  • Regenerate your key if it’s ever exposed.

🧩 Example Use Cases

  • 🔹 SEO Dashboards in Next.js
  • 🔹 Automated Ranking Reports
  • 🔹 Custom WordPress/Node Analytics
  • 🔹 Embedded Widgets for Client Portals

🧰 Tech Stack

  • Node.js 14+
  • Google APIs Client Library
  • ESM + async/await support

📜 License

Licensed under the MIT License
© 2025 Rohit Saini


If you find this project useful, please give it a star on GitHub!
It helps others discover and trust the package.