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.
✅ 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
npm install gsc-trending-plusor
yarn add gsc-trending-plus- Go to Google Cloud Console.
- Create a new project (e.g., “yourdomain GSC API”).
- Navigate to APIs & Services → Library → search for “Search Console API” → click Enable.
- Go to APIs & Services → Credentials → Create Credentials → Service Account.
- Name it (e.g.,
gsc-service) → click Create and Continue → assign no special roles → click Done. - Click your new Service Account → Keys → Add Key → Create New Key → JSON.
- It will download a file like:
gsc-service-xxxxxxxxxxxx.json
- It will download a file like:
- Save this file securely (e.g., inside your project folder).
- Copy the Service Account Email (found in the Service Account details).
- Go to Google Search Console.
- Click Settings → Users and Permissions → Add User.
- Add your Service Account email (e.g.,
gsc-service@yourproject.iam.gserviceaccount.com). - Grant Full or Restricted access (both work for read-only API calls).
- 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.
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
}
]| 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 |
- 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.
❌ No.
All data is fetched securely from your own Google Search Console property.
✅ Yes.
Use server-side secrets or environment variables to keep your key file safe.
- Never upload your Service Account JSON key to public repos.
- Use
.envor cloud secret storage in production. - Regenerate your key if it’s ever exposed.
- 🔹 SEO Dashboards in Next.js
- 🔹 Automated Ranking Reports
- 🔹 Custom WordPress/Node Analytics
- 🔹 Embedded Widgets for Client Portals
- Node.js 14+
- Google APIs Client Library
- ESM + async/await support
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.