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 🙏

© 2026 – Pkg Stats / Ryan Hefner

gscdump

v0.2.0

Published

Google Search Console API wrapper with typed query builder, streaming pagination, and SEO analysis functions

Readme

gscdump

npm version npm downloads license

Google Search Console API wrapper with typed query builder, streaming pagination, and SEO analysis functions.

Features

  • Typed Query Builder - Drizzle-style API with filter constraints narrowing result types
  • Streaming Pagination - Memory-efficient iteration over large datasets (>25k rows)
  • SEO Analysis - Pure functions for cannibalization, striking distance, movers & shakers, decay detection
  • Edge-Compatible - Works in Cloudflare Workers, Deno, and other edge runtimes
  • Full API Coverage - Sites, sitemaps, indexing, and analytics

Install

npm install gscdump

Usage

import { fetchKeywordsWithComparison, fetchPagesWithComparison } from 'gscdump'
import { daysAgo, today } from 'gscdump/query'

// Auth accepts token string or object
const auth = 'ya29.xxx...'
// or: { accessToken: 'ya29.xxx...' }

const range = {
  period: { start: daysAgo(28), end: today() },
}

// Pages with top keyword per page
const pages = await fetchPagesWithComparison(auth, site, range)

// Keywords with change percentages
const keywords = await fetchKeywordsWithComparison(auth, site, range)

Streaming Large Datasets

For memory-efficient pagination of large datasets (>25k rows):

import { queryRecursiveStream } from 'gscdump'

// Stream keyword+page combinations - yields batches as they're fetched
for await (const batch of queryRecursiveStream(client, site, {
  dimensions: ['query', 'page'] as const, // as const required for type inference
  startDate: '2024-01-01',
  endDate: '2024-01-31',
})) {
  // batch: { keyword: string, page: string, clicks, impressions, ctr, position }[]
  await db.insert(batch)
}

Typed Query Builder

Drizzle-style query builder with full type safety. Filter constraints flow through to result types.

import { and, between, contains, country, Country, date, device, Device, eq, gsc, inArray, page } from 'gscdump/query'

const body = gsc
  .select('page', 'query', 'device', 'country')
  .where(and(
    eq(device, Device.MOBILE),
    inArray(country, [Country.USA, Country.GBR]),
    contains(page, '/blog/'),
    between(date, '2024-01-01', '2024-01-31')
  ))
  .toBody()

// Use with client.searchAnalytics.query(siteUrl, body)

With date helpers:

import { and, between, date, daysAgo, gsc, query, regex, today } from 'gscdump/query'

const q = gsc
  .select('query', 'page')
  .where(and(
    between(date, daysAgo(28), today()),
    regex(query, /how to/)
  ))
  .limit(100)

Operators:

| Operator | Narrows Type? | Description | |----------|---------------|-------------| | eq(col, val) | ✓ | Exact match | | ne(col, val) | ✗ | Not equal | | inArray(col, [a, b]) | ✓ | Value in array (becomes a \| b) | | contains(col, str) | ✗ | String contains | | like(col, '%pattern%') | ✗ | SQL LIKE pattern | | regex(col, /pattern/) | ✗ | Regex match | | notRegex(col, /pattern/) | ✗ | Regex exclusion | | between(col, start, end) | ✗ | Inclusive range (primarily for date) | | gte(col, val) | ✗ | Greater than or equal | | lte(col, val) | ✗ | Less than or equal | | gt(col, val) | ✗ | Greater than | | lt(col, val) | ✗ | Less than | | and(...filters) | ✓ | Merge constraints | | or(...filters) | ✗ | Any match | | not(filter) | ✗ | Invert filter |

Analysis Functions

Analysis functions are pure - they operate on typed data arrays and return typed results.

import {
  analyzeCannibalization,
  analyzeDecay,
  analyzeMovers,
  analyzeStrikingDistance,
  fetchKeywordsWithComparison,
} from 'gscdump'

// Fetch data first
const { current, previous } = await fetchKeywordsWithComparison(auth, site, range)

// Run pure analysis on the data
const striking = analyzeStrikingDistance(current)
const movers = analyzeMovers(current, previous)
const decay = analyzeDecay(current, previous)
const cannibalization = analyzeCannibalization(keywordPageData)

Exports

Sites: fetchSites, fetchSitesWithSitemaps, fetchSitemaps, getSitemap, submitSitemap, deleteSitemap, inspectUrl, batchInspectUrls

Indexing: requestIndexing, getIndexingMetadata, batchRequestIndexing

Analytics: fetchAnalyticsWithComparison, fetchPagesWithComparison, fetchKeywordsWithComparison, fetchDevicesWithComparison, fetchCountriesWithComparison, fetchSearchAppearanceWithComparison, fetchDates, fetchDatesWithComparison, fetchPages, fetchPage, fetchKeyword

Analysis (Pure): analyzeStrikingDistance, analyzeOpportunity, analyzeBrandSegmentation, analyzeConcentration, analyzeDecay, analyzeMovers, analyzeCannibalization, analyzeZeroClick, analyzeSeasonality, analyzeClustering

Low-level: gscClient, queryRecursive, queryRecursiveStream, createQueryBody, withPropertyAggregation, withSearchAppearance, withDataType, withFreshData, withFinalData

Query Builder (gscdump/query): gsc, eq, ne, and, or, inArray, contains, like, regex, notRegex, not, between, gte, gt, lte, lt, page, query, device, country, date, searchAppearance, Device, Country, today, daysAgo

Error Utilities: isQuotaError, isRateLimitError, isAuthError, getErrorCode, getErrorMessage, getRetryAfter, analyzeGscError, formatGscErrorForCli

Utils: formatDateGsc, percentDifference

Related Packages

License

MIT