@power-seo/search-console 1.0.7 → 1.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +236 -237
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,76 +1,89 @@
1
- # @power-seo/search-console — Google Search Console API Client for TypeScript — OAuth2, Service Account, URL Inspection & Auto-Paginated Analytics
1
+ # @power-seo/search-console
2
2
 
3
- [![npm version](https://img.shields.io/npm/v/@power-seo/search-console?style=flat-square)](https://www.npmjs.com/package/@power-seo/search-console)
4
- [![npm downloads](https://img.shields.io/npm/dm/@power-seo/search-console?style=flat-square)](https://www.npmjs.com/package/@power-seo/search-console)
5
- [![MIT License](https://img.shields.io/npm/l/@power-seo/search-console?style=flat-square)](../../LICENSE)
6
- [![TypeScript](https://img.shields.io/badge/TypeScript-strict-blue?style=flat-square)](https://www.typescriptlang.org/)
7
- [![Tree-shakeable](https://img.shields.io/badge/tree--shakeable-yes-brightgreen?style=flat-square)](#)
3
+ ![search-console banner](../../image/search-console/banner.svg)
8
4
 
9
- ---
10
-
11
- ## Overview
12
-
13
- **@power-seo/search-console** is a production-ready Google Search Console API client for TypeScript that helps you query search analytics, inspect URLs, and manage sitemaps — without writing OAuth2 token refresh boilerplate or pagination loops.
14
-
15
- **What it does**
16
-
17
- - ✅ **OAuth2 and service account auth** — `createTokenManager()` handles token refresh cycles and JWT signing automatically
18
- - ✅ **Search analytics queries** — clicks, impressions, CTR, and position by query, page, country, device, date
19
- - ✅ **Auto-paginated full fetch** — `querySearchAnalyticsAll()` transparently pages through the 25,000-row GSC API limit
20
- - ✅ **URL inspection** — indexing verdict, last crawl time, canonical URL, mobile usability, rich result status
21
- - ✅ **Sitemap management** — list, submit, and delete sitemaps from verified GSC properties
5
+ Typed Google Search Console API client for TypeScript — OAuth2 and service account auth, auto-paginated search analytics, URL inspection, and sitemap management with zero boilerplate.
22
6
 
23
- **What it is not**
7
+ [![npm version](https://img.shields.io/npm/v/@power-seo/search-console)](https://www.npmjs.com/package/@power-seo/search-console)
8
+ [![npm downloads](https://img.shields.io/npm/dm/@power-seo/search-console)](https://www.npmjs.com/package/@power-seo/search-console)
9
+ [![Socket](https://socket.dev/api/badge/npm/package/@power-seo/search-console)](https://socket.dev/npm/package/@power-seo/search-console)
10
+ [![npm provenance](https://img.shields.io/badge/npm-provenance-enabled-blue)](https://github.com/CyberCraftBD/power-seo/actions)
11
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
12
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.x-blue)](https://www.typescriptlang.org/)
13
+ [![tree-shakeable](https://img.shields.io/badge/tree--shakeable-yes-brightgreen)](https://bundlephobia.com/package/@power-seo/search-console)
24
14
 
25
- - **Not a reporting dashboard**returns raw data; use `@power-seo/analytics` to merge and visualize
26
- - ❌ **Not a site verification tool** — requires a property already verified in Google Search Console
15
+ `@power-seo/search-console` is a production-ready Google Search Console API client for TypeScript. Provide OAuth2 credentials or a service account key get back fully typed search analytics rows, URL inspection verdicts, and sitemap management operations. The token manager handles refresh cycles and JWT signing automatically. `querySearchAnalyticsAll()` transparently pages through the 25,000-row GSC API limit, merging all results into a single array. Use it in Next.js API routes, Remix loaders, Node.js scripts, and CI/CD pipelines. All operations are server-side only — service account credentials must never be exposed to the browser.
27
16
 
28
- **Recommended for**
29
-
30
- - **SEO automation pipelines**, **CI/CD keyword tracking**, **SaaS analytics dashboards**, and **reporting scripts** using GSC data
17
+ > **Zero runtime dependencies** — pure TypeScript with native `fetch` and `crypto`; no googleapis package required.
31
18
 
32
19
  ---
33
20
 
34
- ## Why @power-seo/search-console Matters
35
-
36
- **The problem**
37
-
38
- - **OAuth2 token refresh is complex** — access tokens expire every hour; service account JWT signing requires crypto operations
39
- - **GSC returns only 25,000 rows per request** — sites with many queries need pagination loops that every team reimplements
40
- - **URL inspection data is inaccessible without auth** — no simple way to check indexing status programmatically
21
+ ## Why @power-seo/search-console?
41
22
 
42
- **Why developers care**
23
+ | | Without | With |
24
+ | -------------------- | ------------------------------------------- | --------------------------------------------------------- |
25
+ | OAuth2 token refresh | ❌ 50+ lines of boilerplate per project | ✅ Auto-refresh via `createTokenManager()` |
26
+ | GSC data pagination | ❌ Manual rowOffset loops and array merging | ✅ `querySearchAnalyticsAll()` — one call, all rows |
27
+ | URL inspection | ❌ Manual GSC UI check only | ✅ Programmatic `inspectUrl()` in CI pipelines |
28
+ | Service accounts | ❌ Complex JWT signing setup | ✅ `createTokenManager({ type: 'service-account' })` |
29
+ | Type safety | ❌ Raw API responses typed as `any` | ✅ Fully typed request and response shapes |
30
+ | Sitemap management | ❌ Manual GSC UI operations | ✅ `submitSitemap()`, `listSitemaps()`, `deleteSitemap()` |
31
+ | Framework support | ❌ Tied to googleapis setup | ✅ Works in Next.js, Remix, Node.js, CI/CD |
43
32
 
44
- - **SEO:** Programmatic access to real click/impression data enables data-driven content decisions
45
- - **Performance:** Auto-paginated `querySearchAnalyticsAll` eliminates boilerplate that slows down analytics pipelines
46
- - **UX:** URL inspection in CI enables instant indexing health checks after deployments
33
+ ![Search Console Comparison](../../image/search-console/comparison.svg)
47
34
 
48
35
  ---
49
36
 
50
- ## Key Features
37
+ ## Features
51
38
 
52
39
  - **OAuth2 authentication** — `createTokenManager({ type: 'oauth' })` handles token refresh automatically
53
- - **Service account JWT authentication** — `createTokenManager({ type: 'service-account' })` signs JWTs for server-to-server access
40
+ - **Service account JWT authentication** — `createTokenManager({ type: 'service-account' })` signs JWTs for server-to-server access without user interaction
54
41
  - **Low-level auth primitives** — `exchangeRefreshToken()` and `getServiceAccountToken()` for custom auth flows
55
- - **Typed GSC client** — `createGSCClient(config)` returns a `GSCClient` scoped to a specific site URL
42
+ - **Typed GSC client** — `createGSCClient(config)` returns a `GSCClient` scoped to a specific verified site URL
56
43
  - **Search analytics** — `querySearchAnalytics()` supports all 6 dimensions: `query`, `page`, `country`, `device`, `date`, `searchAppearance`
57
44
  - **All search types** — `web`, `image`, `video`, and `news` search types
58
- - **Auto-paginated full fetch** — `querySearchAnalyticsAll()` merges all pages into a single `SearchAnalyticsRow[]` array
45
+ - **Auto-paginated full fetch** — `querySearchAnalyticsAll()` merges all pages into one `SearchAnalyticsRow[]` array
59
46
  - **URL inspection** — `inspectUrl()` returns verdict, indexing state, last crawl time, mobile usability, and rich result status
60
- - **Direct URL inspection** — `inspectUrlDirect()` for the direct URL inspection endpoint
47
+ - **Direct URL inspection** — `inspectUrlDirect()` for the direct URL inspection API endpoint
61
48
  - **Sitemap listing** — `listSitemaps()` with status, last download time, and error counts
62
49
  - **Sitemap submission and deletion** — `submitSitemap()` and `deleteSitemap()`
63
50
  - **Typed error handling** — `GSCApiError` class with `status`, `code`, and `message`
64
- - **Type-safe throughout** — full TypeScript types for all request and response shapes
51
+ - **Full TypeScript support** — complete type definitions for all request and response shapes
52
+
53
+ ![Search Console Dashboard UI](../../image/search-console/dashboard-ui.svg)
54
+
55
+ ---
56
+
57
+ ## Comparison
58
+
59
+ | Feature | google-auth-library | googleapis | custom fetch | @power-seo/search-console |
60
+ | ---------------------------------- | :-----------------: | :--------: | :----------: | :-----------------------: |
61
+ | OAuth2 token auto-refresh | ✅ | ✅ | ❌ | ✅ |
62
+ | Service account JWT signing | ✅ | ✅ | ❌ | ✅ |
63
+ | Auto-paginated analytics fetch | ❌ | ❌ | ❌ | ✅ |
64
+ | Typed GSC-specific response shapes | ❌ | ⚠️ | ❌ | ✅ |
65
+ | URL inspection support | ❌ | ⚠️ | ❌ | ✅ |
66
+ | Sitemap management | ❌ | ⚠️ | ❌ | ✅ |
67
+ | Zero runtime dependencies | ❌ | ❌ | ✅ | ✅ |
68
+ | TypeScript-first | ❌ | ⚠️ | ❌ | ✅ |
69
+
70
+ ![Pagination Accuracy](../../image/search-console/pagination-accuracy.svg)
65
71
 
66
72
  ---
67
73
 
68
- ## Benefits of Using @power-seo/search-console
74
+ ## Installation
75
+
76
+ ```bash
77
+ npm install @power-seo/search-console
78
+ ```
79
+
80
+ ```bash
81
+ yarn add @power-seo/search-console
82
+ ```
69
83
 
70
- - **Faster analytics pipelines**: No token refresh boilerplate; token manager handles expiry transparently
71
- - **Complete datasets**: `querySearchAnalyticsAll` fetches all rows regardless of API page limit
72
- - **Safer integration**: `GSCApiError` structured error class enables reliable error handling in production
73
- - **Faster delivery**: Connect to GSC in minutes; no OAuth2 library research required
84
+ ```bash
85
+ pnpm add @power-seo/search-console
86
+ ```
74
87
 
75
88
  ---
76
89
 
@@ -110,185 +123,133 @@ rows.forEach(({ keys, clicks, impressions, ctr, position }) => {
110
123
  });
111
124
  ```
112
125
 
113
- **What you should see**
114
-
115
- - A merged `SearchAnalyticsRow[]` array with all query-page combinations for the date range
116
- - `clicks`, `impressions`, `ctr`, and `position` for each row
117
-
118
- ---
119
-
120
- ## Installation
121
-
122
- ```bash
123
- npm i @power-seo/search-console
124
- # or
125
- yarn add @power-seo/search-console
126
- # or
127
- pnpm add @power-seo/search-console
128
- # or
129
- bun add @power-seo/search-console
130
- ```
126
+ ![Auth Benefit](../../image/search-console/auth-benefit.svg)
131
127
 
132
128
  ---
133
129
 
134
- ## Framework Compatibility
130
+ ## Usage
135
131
 
136
- **Supported**
137
-
138
- - ✅ Next.js (App Router / Pages Router) — use in API routes or server actions
139
- - ✅ Remix — use in loader functions and server-side actions
140
- - ✅ Node.js 18+ — pure TypeScript client with `fetch` API
141
- - ✅ CI/CD pipelines — run as standalone Node scripts in GitHub Actions or similar
142
-
143
- **Environment notes**
144
-
145
- - **SSR/SSG:** Fully supported — all operations are server-side
146
- - **Edge runtime:** Not supported (requires crypto for JWT signing)
147
- - **Browser-only usage:** Not supported — exposes credentials; server-side only
148
-
149
- ---
132
+ ### OAuth2 Authentication
150
133
 
151
- ## Use Cases
152
-
153
- - **Automated keyword ranking reports** — fetch all queries weekly and diff against previous week
154
- - **Indexing health monitoring** — `inspectUrl` after deployments to verify new pages are indexed
155
- - **Content gap analysis** — merge GSC data with `@power-seo/analytics` to find high-impression, low-click pages
156
- - **Sitemap automation** — submit new sitemaps programmatically after content migrations
157
- - **CI/CD SEO checks** — fail pipelines when key pages drop below position threshold
158
- - **Multi-site SaaS dashboards** — aggregate GSC data across multiple client properties
159
- - **Image and news search analytics** — query `image` and `news` search types separately
160
- - **Country and device breakdowns** — segment click data by country or device for regional SEO
161
-
162
- ---
163
-
164
- ## Example (Before / After)
134
+ ```ts
135
+ import { createTokenManager } from '@power-seo/search-console';
165
136
 
166
- ```text
167
- Before:
168
- - Manual OAuth2 token refresh: 50+ lines of token exchange code per project
169
- - Pagination loop: separate rowOffset counter, multiple fetch calls, manual array merging
170
- - URL inspection: no programmatic access → check Google Search Console UI manually
137
+ const tokenManager = createTokenManager({
138
+ type: 'oauth',
139
+ clientId: process.env.GSC_CLIENT_ID!,
140
+ clientSecret: process.env.GSC_CLIENT_SECRET!,
141
+ refreshToken: process.env.GSC_REFRESH_TOKEN!,
142
+ });
171
143
 
172
- After (@power-seo/search-console):
173
- - createTokenManager({ type: 'oauth', ... }) → tokens auto-refresh before every request
174
- - querySearchAnalyticsAll(client, { dimensions: ['query'] }) → one call, complete dataset
175
- - inspectUrl(client, url) → { verdict: 'PASS', lastCrawlTime: '...', mobileUsabilityResult: {...} }
144
+ const { accessToken } = await tokenManager.getAccessToken();
176
145
  ```
177
146
 
178
- ---
179
-
180
- ## Implementation Best Practices
181
-
182
- - **Use service accounts for CI/CD** — service accounts don't expire and don't require user interaction
183
- - **Cache `querySearchAnalyticsAll` results** — GSC data is delayed by ~2 days; daily fetches are sufficient
184
- - **Use `sc-domain:` prefix for domain properties** — e.g. `sc-domain:example.com` for domain-level verification
185
- - **Add service account email as GSC user** — Settings → Users and permissions → Add user
186
- - **Handle `GSCApiError` status 429** — implement exponential backoff for rate-limited requests
187
-
188
- ---
147
+ ### Service Account Authentication
189
148
 
190
- ## Architecture Overview
191
-
192
- **Where it runs**
193
-
194
- - **Build-time**: Fetch GSC data for static site revalidation or build-time content ranking
195
- - **Runtime**: Query analytics in serverless functions for real-time dashboard data
196
- - **CI/CD**: Check indexing status and keyword positions in automated pipelines
149
+ ```ts
150
+ import { createTokenManager } from '@power-seo/search-console';
197
151
 
198
- **Data flow**
152
+ const tokenManager = createTokenManager({
153
+ type: 'service-account',
154
+ clientEmail: process.env.GSC_SERVICE_ACCOUNT_EMAIL!,
155
+ privateKey: process.env.GSC_PRIVATE_KEY!,
156
+ scopes: ['https://www.googleapis.com/auth/webmasters.readonly'],
157
+ });
158
+ ```
199
159
 
200
- 1. **Input**: OAuth2 credentials or service account key + site URL + query parameters
201
- 2. **Analysis**: Token manager handles auth; client sends typed requests to GSC API
202
- 3. **Output**: Typed `SearchAnalyticsRow[]`, `InspectionResult`, `SitemapListResponse`
203
- 4. **Action**: Feed into `@power-seo/analytics` for dashboards, or export as CSV/JSON reports
160
+ ### Search Analytics Query
204
161
 
205
- ---
162
+ ```ts
163
+ import { createGSCClient, querySearchAnalytics } from '@power-seo/search-console';
206
164
 
207
- ## Features Comparison with Popular Packages
165
+ const client = createGSCClient({ siteUrl: 'https://example.com', tokenManager });
208
166
 
209
- | Capability | google-auth-library | googleapis | custom fetch | @power-seo/search-console |
210
- | ---------------------------------- | ------------------: | ---------: | -----------: | ------------------------: |
211
- | OAuth2 token auto-refresh | ✅ | ✅ | ❌ | ✅ |
212
- | Service account JWT signing | ✅ | ✅ | ❌ | ✅ |
213
- | Auto-paginated analytics fetch | ❌ | ❌ | ❌ | ✅ |
214
- | Typed GSC-specific response shapes | ❌ | ⚠️ | ❌ | ✅ |
215
- | URL inspection support | ❌ | ⚠️ | ❌ | ✅ |
216
- | Sitemap management | ❌ | ⚠️ | ❌ | ✅ |
167
+ const response = await querySearchAnalytics(client, {
168
+ startDate: '2026-01-01',
169
+ endDate: '2026-01-31',
170
+ dimensions: ['query', 'country'],
171
+ searchType: 'web',
172
+ rowLimit: 5000,
173
+ });
217
174
 
218
- ---
175
+ // response.rows → SearchAnalyticsRow[]
176
+ ```
219
177
 
220
- ## [@power-seo](https://www.npmjs.com/org/power-seo) Ecosystem
178
+ ### Auto-Paginated Full Fetch
221
179
 
222
- All 17 packages are independently installable — use only what you need.
180
+ ```ts
181
+ import { querySearchAnalyticsAll } from '@power-seo/search-console';
223
182
 
224
- | Package | Install | Description |
225
- | ------------------------------------------------------------------------------------------ | ----------------------------------- | ----------------------------------------------------------------------- |
226
- | [`@power-seo/core`](https://www.npmjs.com/package/@power-seo/core) | `npm i @power-seo/core` | Framework-agnostic utilities, types, validators, and constants |
227
- | [`@power-seo/react`](https://www.npmjs.com/package/@power-seo/react) | `npm i @power-seo/react` | React SEO components — meta, Open Graph, Twitter Card, breadcrumbs |
228
- | [`@power-seo/meta`](https://www.npmjs.com/package/@power-seo/meta) | `npm i @power-seo/meta` | SSR meta helpers for Next.js App Router, Remix v2, and generic SSR |
229
- | [`@power-seo/schema`](https://www.npmjs.com/package/@power-seo/schema) | `npm i @power-seo/schema` | Type-safe JSON-LD structured data — 20 builders + 18 React components |
230
- | [`@power-seo/content-analysis`](https://www.npmjs.com/package/@power-seo/content-analysis) | `npm i @power-seo/content-analysis` | Yoast-style SEO content scoring engine with React components |
231
- | [`@power-seo/readability`](https://www.npmjs.com/package/@power-seo/readability) | `npm i @power-seo/readability` | Readability scoring — Flesch-Kincaid, Gunning Fog, Coleman-Liau, ARI |
232
- | [`@power-seo/preview`](https://www.npmjs.com/package/@power-seo/preview) | `npm i @power-seo/preview` | SERP, Open Graph, and Twitter/X Card preview generators |
233
- | [`@power-seo/sitemap`](https://www.npmjs.com/package/@power-seo/sitemap) | `npm i @power-seo/sitemap` | XML sitemap generation, streaming, index splitting, and validation |
234
- | [`@power-seo/redirects`](https://www.npmjs.com/package/@power-seo/redirects) | `npm i @power-seo/redirects` | Redirect engine with Next.js, Remix, and Express adapters |
235
- | [`@power-seo/links`](https://www.npmjs.com/package/@power-seo/links) | `npm i @power-seo/links` | Link graph analysis — orphan detection, suggestions, equity scoring |
236
- | [`@power-seo/audit`](https://www.npmjs.com/package/@power-seo/audit) | `npm i @power-seo/audit` | Full SEO audit engine — meta, content, structure, performance rules |
237
- | [`@power-seo/images`](https://www.npmjs.com/package/@power-seo/images) | `npm i @power-seo/images` | Image SEO — alt text, lazy loading, format analysis, image sitemaps |
238
- | [`@power-seo/ai`](https://www.npmjs.com/package/@power-seo/ai) | `npm i @power-seo/ai` | LLM-agnostic AI prompt templates and parsers for SEO tasks |
239
- | [`@power-seo/analytics`](https://www.npmjs.com/package/@power-seo/analytics) | `npm i @power-seo/analytics` | Merge GSC + audit data, trend analysis, ranking insights, dashboard |
240
- | [`@power-seo/search-console`](https://www.npmjs.com/package/@power-seo/search-console) | `npm i @power-seo/search-console` | Google Search Console API — OAuth2, service account, URL inspection |
241
- | [`@power-seo/integrations`](https://www.npmjs.com/package/@power-seo/integrations) | `npm i @power-seo/integrations` | Semrush and Ahrefs API clients with rate limiting and pagination |
242
- | [`@power-seo/tracking`](https://www.npmjs.com/package/@power-seo/tracking) | `npm i @power-seo/tracking` | GA4, Clarity, PostHog, Plausible, Fathom — scripts + consent management |
183
+ // Fetches all rows automatically — handles the 25,000-row API limit
184
+ const allRows = await querySearchAnalyticsAll(client, {
185
+ startDate: '2026-01-01',
186
+ endDate: '2026-01-31',
187
+ dimensions: ['query'],
188
+ });
243
189
 
244
- ### Ecosystem vs alternatives
190
+ console.log(`Total rows: ${allRows.length}`);
191
+ ```
245
192
 
246
- | Need | Common approach | @power-seo approach |
247
- | -------------------- | ---------------------- | --------------------------------------------------- |
248
- | GSC search analytics | `googleapis` (verbose) | `@power-seo/search-console` — typed, auto-paginated |
249
- | Analytics dashboards | Google Looker Studio | `@power-seo/analytics` — merge GSC + audit data |
250
- | Sitemap submission | Manual GSC UI | `@power-seo/search-console` — `submitSitemap()` |
251
- | SEO auditing | Third-party tools | `@power-seo/audit` — in-code, CI-friendly |
193
+ ### URL Inspection
252
194
 
253
- ---
195
+ ```ts
196
+ import { inspectUrl } from '@power-seo/search-console';
254
197
 
255
- ## Enterprise Integration
198
+ const result = await inspectUrl(client, 'https://example.com/blog/my-post');
256
199
 
257
- **Multi-tenant SaaS**
200
+ console.log(result.verdict); // 'PASS' | 'FAIL' | 'NEUTRAL'
201
+ console.log(result.indexingState); // 'INDEXING_ALLOWED' | ...
202
+ console.log(result.lastCrawlTime); // ISO timestamp
203
+ console.log(result.mobileUsabilityResult.verdict); // 'PASS' | 'FAIL'
204
+ ```
258
205
 
259
- - **Per-client GSC properties**: Instantiate one `GSCClient` per client site; use service accounts for automation
260
- - **Aggregated dashboards**: Loop over multiple `siteUrl` values and merge analytics into a multi-site report
261
- - **Scheduled data sync**: Run `querySearchAnalyticsAll` on a daily cron for all client properties
206
+ ### Sitemap Management
262
207
 
263
- **ERP / internal portals**
208
+ ```ts
209
+ import { listSitemaps, submitSitemap, deleteSitemap } from '@power-seo/search-console';
264
210
 
265
- - Use URL inspection to verify that portal public pages are correctly indexed
266
- - Track keyword positions for internal knowledge base articles
267
- - Automate sitemap submission after content management system publishes
211
+ // List all submitted sitemaps
212
+ const sitemaps = await listSitemaps(client);
213
+ // sitemaps.sitemap SitemapEntry[]
268
214
 
269
- **Recommended integration pattern**
215
+ // Submit a new sitemap
216
+ await submitSitemap(client, 'https://example.com/sitemap.xml');
270
217
 
271
- - Use **service accounts** in CI/CD — no user interaction, no token expiry
272
- - Run `querySearchAnalyticsAll` in **weekly scheduled jobs**
273
- - Feed data into `@power-seo/analytics` for **trend analysis** and **ranking insights**
274
- - Export results as **JSON** to Jira/Notion/Slack for content team review
218
+ // Delete an old sitemap
219
+ await deleteSitemap(client, 'https://example.com/old-sitemap.xml');
220
+ ```
275
221
 
276
- ---
222
+ ### CI/CD Keyword Position Check
277
223
 
278
- ## Scope and Limitations
224
+ ```ts
225
+ import {
226
+ createTokenManager,
227
+ createGSCClient,
228
+ querySearchAnalyticsAll,
229
+ } from '@power-seo/search-console';
279
230
 
280
- **This package does**
231
+ const tokenManager = createTokenManager({
232
+ type: 'service-account',
233
+ clientEmail: process.env.GSC_SERVICE_ACCOUNT_EMAIL!,
234
+ privateKey: process.env.GSC_PRIVATE_KEY!,
235
+ scopes: ['https://www.googleapis.com/auth/webmasters.readonly'],
236
+ });
281
237
 
282
- - Authenticate with GSC API via OAuth2 and service account
283
- - ✅ Fetch search analytics data with auto-pagination
284
- - ✅ Inspect URL indexing status, mobile usability, and rich result status
285
- - ✅ Submit, list, and delete sitemaps from verified GSC properties
238
+ const client = createGSCClient({ siteUrl: 'sc-domain:example.com', tokenManager });
286
239
 
287
- **This package does not**
240
+ const rows = await querySearchAnalyticsAll(client, {
241
+ startDate: '2026-01-24',
242
+ endDate: '2026-01-31',
243
+ dimensions: ['query', 'page'],
244
+ });
288
245
 
289
- - Verify properties in GSC property must already be verified
290
- - Provide reporting UI — use `@power-seo/analytics` for dashboards
291
- - Access Google Analytics data — use `@power-seo/tracking` for GA4 API access
246
+ const dropped = rows.filter((r) => r.position > 20 && r.impressions > 100);
247
+ if (dropped.length > 0) {
248
+ console.error('Pages dropped below position 20:');
249
+ dropped.forEach((r) => console.error(' -', r.keys[1], `pos ${r.position.toFixed(1)}`));
250
+ process.exit(1);
251
+ }
252
+ ```
292
253
 
293
254
  ---
294
255
 
@@ -304,7 +265,7 @@ All 17 packages are independently installable — use only what you need.
304
265
  | `config.refreshToken` | `string` | OAuth2 refresh token (OAuth2 only) |
305
266
  | `config.clientEmail` | `string` | Service account email (service account only) |
306
267
  | `config.privateKey` | `string` | Service account private key PEM (service account only) |
307
- | `config.scopes` | `string[]` | OAuth2 scopes to request (service account only) |
268
+ | `config.scopes` | `string[]` | OAuth2 scopes (service account only) |
308
269
 
309
270
  Returns `TokenManager`: `{ getAccessToken(): Promise<TokenResult> }`.
310
271
 
@@ -313,7 +274,7 @@ Returns `TokenManager`: `{ getAccessToken(): Promise<TokenResult> }`.
313
274
  | Parameter | Type | Description |
314
275
  | --------------------- | -------------- | --------------------------------------------------------------------- |
315
276
  | `config.siteUrl` | `string` | Verified GSC property URL (`sc-domain:` prefix for domain properties) |
316
- | `config.tokenManager` | `TokenManager` | Token manager from `createTokenManager` |
277
+ | `config.tokenManager` | `TokenManager` | Token manager from `createTokenManager()` |
317
278
 
318
279
  Returns `GSCClient`.
319
280
 
@@ -330,7 +291,7 @@ Returns `GSCClient`.
330
291
 
331
292
  ### `querySearchAnalyticsAll(client, request)`
332
293
 
333
- Same as `querySearchAnalytics` but `rowLimit` and `startRow` are managed automatically. Returns `Promise<SearchAnalyticsRow[]>`.
294
+ Same parameters as `querySearchAnalytics()` but `rowLimit` and `startRow` are managed automatically. Returns `Promise<SearchAnalyticsRow[]>`.
334
295
 
335
296
  ### `inspectUrl(client, url)` / `inspectUrlDirect(client, url)`
336
297
 
@@ -338,68 +299,106 @@ Returns `Promise<InspectionResult>`: `{ verdict, indexingState, lastCrawlTime, m
338
299
 
339
300
  ### `listSitemaps(client)` / `submitSitemap(client, url)` / `deleteSitemap(client, url)`
340
301
 
341
- `listSitemaps` returns `Promise<SitemapListResponse>`. `submitSitemap` and `deleteSitemap` return `Promise<void>`.
302
+ `listSitemaps()` returns `Promise<SitemapListResponse>`. `submitSitemap()` and `deleteSitemap()` return `Promise<void>`.
342
303
 
343
304
  ### Types
344
305
 
345
- ```ts
346
- import type {
347
- OAuthCredentials,
348
- ServiceAccountCredentials,
349
- TokenResult,
350
- TokenManager,
351
- GSCClientConfig,
352
- GSCClient,
353
- SearchType,
354
- Dimension,
355
- SearchAnalyticsRequest,
356
- SearchAnalyticsRow,
357
- SearchAnalyticsResponse,
358
- InspectionResult,
359
- SitemapEntry,
360
- SitemapListResponse,
361
- } from '@power-seo/search-console';
362
- ```
306
+ | Type | Description |
307
+ | --------------------------- | ---------------------------------------------------------------------------- |
308
+ | `OAuthCredentials` | `{ clientId, clientSecret, refreshToken }` |
309
+ | `ServiceAccountCredentials` | `{ clientEmail, privateKey, scopes }` |
310
+ | `TokenResult` | `{ accessToken: string, expiresAt: number }` |
311
+ | `TokenManager` | `{ getAccessToken(): Promise<TokenResult> }` |
312
+ | `GSCClientConfig` | `{ siteUrl: string, tokenManager: TokenManager }` |
313
+ | `GSCClient` | Scoped API client instance |
314
+ | `SearchType` | `'web' \| 'image' \| 'video' \| 'news'` |
315
+ | `Dimension` | `'query' \| 'page' \| 'country' \| 'device' \| 'date' \| 'searchAppearance'` |
316
+ | `SearchAnalyticsRequest` | Request shape for `querySearchAnalytics()` |
317
+ | `SearchAnalyticsRow` | `{ keys: string[], clicks, impressions, ctr, position }` |
318
+ | `SearchAnalyticsResponse` | API response wrapper with `rows: SearchAnalyticsRow[]` |
319
+ | `InspectionResult` | URL inspection verdict, indexing state, and details |
320
+ | `SitemapEntry` | Single sitemap with status, lastDownloaded, errors |
321
+ | `SitemapListResponse` | `{ sitemap: SitemapEntry[] }` |
322
+ | `GSCApiError` | Error class with `status`, `code`, and `message` |
363
323
 
364
324
  ---
365
325
 
366
- ## Contributing
326
+ ## Use Cases
367
327
 
368
- - Issues: [github.com/cybercraftbd/power-seo/issues](https://github.com/cybercraftbd/power-seo/issues)
369
- - PRs: [github.com/cybercraftbd/power-seo/pulls](https://github.com/cybercraftbd/power-seo/pulls)
370
- - Development setup:
371
- 1. `pnpm i`
372
- 2. `pnpm build`
373
- 3. `pnpm test`
328
+ - **Automated keyword ranking reports** — fetch all queries weekly and diff against the previous week
329
+ - **Indexing health monitoring** — `inspectUrl()` after deployments to verify new pages are indexed
330
+ - **Content gap analysis** — merge GSC data with `@power-seo/analytics` to find high-impression, low-click pages
331
+ - **Sitemap automation** — submit new sitemaps programmatically after content migrations
332
+ - **CI/CD SEO checks** — fail pipelines when key pages drop below a position threshold
333
+ - **Multi-site SaaS dashboards** — aggregate GSC data across multiple client properties with one `GSCClient` per site
334
+ - **Image and news search analytics** — query `image` and `news` search types separately
335
+ - **Country and device breakdowns** — segment click data by country or device for regional SEO analysis
374
336
 
375
- **Release workflow**
337
+ ---
376
338
 
377
- - `npm version patch|minor|major`
378
- - `npm publish --access public`
339
+ ## Architecture Overview
379
340
 
380
- ---
341
+ - **Pure TypeScript** — no compiled binary, no native modules
342
+ - **Server-side only** — requires `crypto` for JWT signing; not edge or browser compatible
343
+ - **Zero runtime dependencies** — no googleapis package; uses native `fetch` and `crypto`
344
+ - **Auto-pagination** — `querySearchAnalyticsAll()` manages `rowOffset` and array merging transparently
345
+ - **Token caching** — access tokens are cached and reused until 5 minutes before expiry
346
+ - **Scoped clients** — each `GSCClient` is scoped to one verified GSC property via `siteUrl`
347
+ - **Typed errors** — `GSCApiError` carries HTTP status, error code, and message for reliable error handling
348
+ - **Dual ESM + CJS** — ships both formats via tsup for any bundler or `require()` usage
381
349
 
382
- ## About [CyberCraft Bangladesh](https://ccbd.dev)
350
+ ---
383
351
 
384
- **[CyberCraft Bangladesh](https://ccbd.dev)** is a Bangladesh-based enterprise-grade software engineering company specializing in ERP system development, AI-powered SaaS and business applications, full-stack SEO services, custom website development, and scalable eCommerce platforms. We design and develop intelligent, automation-driven SaaS and enterprise solutions that help startups, SMEs, NGOs, educational institutes, and large organizations streamline operations, enhance digital visibility, and accelerate growth through modern cloud-native technologies.
352
+ ## Supply Chain Security
385
353
 
386
- | | |
387
- | -------------------- | -------------------------------------------------------------- |
388
- | **Website** | [ccbd.dev](https://ccbd.dev) |
389
- | **GitHub** | [github.com/cybercraftbd](https://github.com/cybercraftbd) |
390
- | **npm Organization** | [npmjs.com/org/power-seo](https://www.npmjs.com/org/power-seo) |
391
- | **Email** | [info@ccbd.dev](mailto:info@ccbd.dev) |
354
+ - No install scripts (`postinstall`, `preinstall`)
355
+ - No runtime network access outside of GSC API calls
356
+ - No `eval` or dynamic code execution
357
+ - npm provenance enabled — every release is signed via Sigstore through GitHub Actions
358
+ - CI-signed builds all releases published via verified `github.com/CyberCraftBD/power-seo` workflow
359
+ - Safe for Node.js 18+ server environments
392
360
 
393
361
  ---
394
362
 
395
- ## License
363
+ ## The [@power-seo](https://www.npmjs.com/org/power-seo) Ecosystem
396
364
 
397
- **MIT**
365
+ All 17 packages are independently installable — use only what you need.
366
+
367
+ | Package | Install | Description |
368
+ | ------------------------------------------------------------------------------------------ | ----------------------------------- | ----------------------------------------------------------------------- |
369
+ | [`@power-seo/core`](https://www.npmjs.com/package/@power-seo/core) | `npm i @power-seo/core` | Framework-agnostic utilities, types, validators, and constants |
370
+ | [`@power-seo/react`](https://www.npmjs.com/package/@power-seo/react) | `npm i @power-seo/react` | React SEO components — meta, Open Graph, Twitter Card, breadcrumbs |
371
+ | [`@power-seo/meta`](https://www.npmjs.com/package/@power-seo/meta) | `npm i @power-seo/meta` | SSR meta helpers for Next.js App Router, Remix v2, and generic SSR |
372
+ | [`@power-seo/schema`](https://www.npmjs.com/package/@power-seo/schema) | `npm i @power-seo/schema` | Type-safe JSON-LD structured data — 23 builders + 21 React components |
373
+ | [`@power-seo/content-analysis`](https://www.npmjs.com/package/@power-seo/content-analysis) | `npm i @power-seo/content-analysis` | Yoast-style SEO content scoring engine with React components |
374
+ | [`@power-seo/readability`](https://www.npmjs.com/package/@power-seo/readability) | `npm i @power-seo/readability` | Readability scoring — Flesch-Kincaid, Gunning Fog, Coleman-Liau, ARI |
375
+ | [`@power-seo/preview`](https://www.npmjs.com/package/@power-seo/preview) | `npm i @power-seo/preview` | SERP, Open Graph, and Twitter/X Card preview generators |
376
+ | [`@power-seo/sitemap`](https://www.npmjs.com/package/@power-seo/sitemap) | `npm i @power-seo/sitemap` | XML sitemap generation, streaming, index splitting, and validation |
377
+ | [`@power-seo/redirects`](https://www.npmjs.com/package/@power-seo/redirects) | `npm i @power-seo/redirects` | Redirect engine with Next.js, Remix, and Express adapters |
378
+ | [`@power-seo/links`](https://www.npmjs.com/package/@power-seo/links) | `npm i @power-seo/links` | Link graph analysis — orphan detection, suggestions, equity scoring |
379
+ | [`@power-seo/audit`](https://www.npmjs.com/package/@power-seo/audit) | `npm i @power-seo/audit` | Full SEO audit engine — meta, content, structure, performance rules |
380
+ | [`@power-seo/images`](https://www.npmjs.com/package/@power-seo/images) | `npm i @power-seo/images` | Image SEO — alt text, lazy loading, format analysis, image sitemaps |
381
+ | [`@power-seo/ai`](https://www.npmjs.com/package/@power-seo/ai) | `npm i @power-seo/ai` | LLM-agnostic AI prompt templates and parsers for SEO tasks |
382
+ | [`@power-seo/analytics`](https://www.npmjs.com/package/@power-seo/analytics) | `npm i @power-seo/analytics` | Merge GSC + audit data, trend analysis, ranking insights, dashboard |
383
+ | [`@power-seo/search-console`](https://www.npmjs.com/package/@power-seo/search-console) | `npm i @power-seo/search-console` | Google Search Console API — OAuth2, service account, URL inspection |
384
+ | [`@power-seo/integrations`](https://www.npmjs.com/package/@power-seo/integrations) | `npm i @power-seo/integrations` | Semrush and Ahrefs API clients with rate limiting and pagination |
385
+ | [`@power-seo/tracking`](https://www.npmjs.com/package/@power-seo/tracking) | `npm i @power-seo/tracking` | GA4, Clarity, PostHog, Plausible, Fathom — scripts + consent management |
398
386
 
399
387
  ---
400
388
 
401
389
  ## Keywords
402
390
 
403
- ```text
404
- seo, google-search-console, gsc, search-analytics, url-inspection, sitemap, oauth2, service-account, typescript, nextjs, analytics, keyword-tracking, click-through-rate, impressions
405
- ```
391
+ seo · google-search-console · gsc · search-analytics · url-inspection · sitemap · oauth2 · service-account · typescript · nextjs · analytics · keyword-tracking · click-through-rate · impressions · ctr · position · auto-pagination · seo-automation · ci-cd · ranking-data
392
+
393
+ ---
394
+
395
+ ## About [CyberCraft Bangladesh](https://ccbd.dev)
396
+
397
+ **[CyberCraft Bangladesh](https://ccbd.dev)** is a Bangladesh-based enterprise-grade software development and Full Stack SEO service provider company specializing in ERP system development, AI-powered SaaS and business applications, full-stack SEO services, custom website development, and scalable eCommerce platforms. We design and develop intelligent, automation-driven SaaS and enterprise solutions that help startups, SMEs, NGOs, educational institutes, and large organizations streamline operations, enhance digital visibility, and accelerate growth through modern cloud-native technologies.
398
+
399
+ [![Website](https://img.shields.io/badge/Website-ccbd.dev-blue?style=for-the-badge)](https://ccbd.dev)
400
+ [![GitHub](https://img.shields.io/badge/GitHub-cybercraftbd-black?style=for-the-badge&logo=github)](https://github.com/cybercraftbd)
401
+ [![npm](https://img.shields.io/badge/npm-power--seo-red?style=for-the-badge&logo=npm)](https://www.npmjs.com/org/power-seo)
402
+ [![Email](https://img.shields.io/badge/Email-info@ccbd.dev-green?style=for-the-badge&logo=gmail)](mailto:info@ccbd.dev)
403
+
404
+ © 2026 [CyberCraft Bangladesh](https://ccbd.dev) · Released under the [MIT License](../../LICENSE)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@power-seo/search-console",
3
- "version": "1.0.7",
3
+ "version": "1.0.10",
4
4
  "description": "Google Search Console API client with OAuth2/service account auth, rate limiting, and retry",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -18,7 +18,7 @@
18
18
  "dist"
19
19
  ],
20
20
  "dependencies": {
21
- "@power-seo/core": "1.0.3"
21
+ "@power-seo/core": "1.0.10"
22
22
  },
23
23
  "devDependencies": {
24
24
  "rimraf": "^6.1.3",