
Gpc Sdk Usage
- 26 installs
- 1 repo stars
- Updated August 1, 2026
- yasserstudio/gpc-skills
Helps with ai & agent building tasks.
About
gpc-sdk-usage is a Claude Code skill for ai & agent building. It helps solo builders move faster with AI-assisted coding.
- gpc-sdk-usage
- AI & Agent Building
- AI-coding skill
Gpc Sdk Usage by the numbers
- 26 all-time installs (skills.sh)
- Ranked #9,667 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
- Data as of Aug 2, 2026 (Skillselion catalog sync)
npx skills add https://github.com/yasserstudio/gpc-skills --skill gpc-sdk-usageAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 26 |
|---|---|
| repo stars | ★ 1 |
| Last updated | August 1, 2026 |
| Repository | yasserstudio/gpc-skills ↗ |
What it does
Helps with ai & agent building tasks.
Files
gpc-sdk-usage
Use @gpc-cli/api and @gpc-cli/auth as standalone TypeScript SDK packages for programmatic Google Play access.
When to use
- Building a backend service that interacts with Google Play
- Creating custom dashboards or automation scripts
- Programmatic release management from TypeScript/JavaScript
- Using the typed API client directly (not through the CLI)
- Integrating Google Play operations into a larger application
Inputs required
- Node.js 20+ and TypeScript 5+
- @gpc-cli/api and @gpc-cli/auth packages
- Service account key — JSON file or raw JSON string
Procedure
0. Install packages
npm install @gpc-cli/api @gpc-cli/authThese are standalone packages — no need to install the full CLI.
1. Authenticate
import { resolveAuth } from "@gpc-cli/auth";
// From file path
const auth = await resolveAuth({
serviceAccountPath: "/path/to/key.json",
});
// From JSON string (e.g., from environment variable)
const auth = await resolveAuth({
serviceAccountJson: process.env.PLAY_SA_KEY,
});
// From environment (GPC_SERVICE_ACCOUNT or GOOGLE_APPLICATION_CREDENTIALS)
const auth = await resolveAuth();Read: references/auth-patterns.md for advanced auth patterns and token caching.
2. Create API client
import { createApiClient } from "@gpc-cli/api";
const client = createApiClient({
auth,
maxRetries: 3,
timeout: 30_000,
});The client provides typed access to all 217 Google Play Developer API endpoints across the Android Publisher v3, Play Developer Reporting v1beta1, and (new in v0.9.56) Play Custom App Publishing v1 APIs.
2a. Create the Enterprise client (v0.9.56+)
For private app publishing via the Play Custom App Publishing API, use a separate factory:
import { createEnterpriseClient, type CustomApp } from "@gpc-cli/api";
const enterprise = createEnterpriseClient({ auth });
const app: CustomApp = await enterprise.apps.create(
"1234567890", // developer account ID (int64, from Play Console URL)
"./app.aab", // bundle path
{
title: "My Private App",
languageCode: "en_US",
organizations: [{ organizationId: "customer-org-id" }],
},
);
console.log("Assigned package name:", app.packageName);
// com.google.customapp.A1B2C3D4E5 (Google-assigned, you cannot influence)Notes:
- Private apps are permanently private. Once created, they cannot be made public.
- After creation, subsequent operations (version uploads, tracks, listings) go through the regular
createApiClient()using the returnedpackageName. - Requires the "create and publish private apps" permission on your service account in Play Console.
- The underlying
HttpClient.uploadCustomApp<T>(path, filePath, metadata, contentType)method handles a multipart resumable upload where the initial session-initiation POST carries the JSON metadata. SeeResumableUploadOptions.initialMetadatafor reusing this pattern with other Google APIs.
See the gpc-enterprise skill for the CLI equivalent and full setup walkthrough.
Read: references/api-reference.md for the complete client API with all namespaces and methods.
3. Edit lifecycle
Most Google Play operations require an edit session:
const APP = "com.example.app";
// 1. Create an edit
const edit = await client.edits.insert(APP);
// 2. Make changes within the edit
const tracks = await client.tracks.list(APP, edit.id);
const details = await client.details.get(APP, edit.id);
// 3. Validate before committing
await client.edits.validate(APP, edit.id);
// 4. Commit the edit (applies all changes)
await client.edits.commit(APP, edit.id);
// Optional: commit with options (v0.9.51+)
await client.edits.commit(APP, edit.id, {
changesNotSentForReview: true,
changesInReviewBehavior: "HALT_REVIEW",
});Important: Only one edit can be open at a time. Always commit or delete edits.
4. Common patterns
Create a custom closed testing track (v0.9.79+)
// Create a custom closed testing track before uploading to it
const track = await client.edits.tracks.create(packageName, "my-custom-track");Custom tracks must be created before any release can be assigned to them. After creation, use the standard client.tracks.update() call to push a release to the new track.
Upload a release
const edit = await client.edits.insert(APP);
// Upload the bundle
const bundle = await client.bundles.upload(APP, edit.id, "app-release.aab");
// Upload with device tier config (v0.9.51+)
const bundle2 = await client.bundles.upload(APP, edit.id, "app-release.aab", {
deviceTierConfigId: "my-tier-config",
});
// Set the track
await client.tracks.update(APP, edit.id, "beta", {
track: "beta",
releases: [{
versionCodes: [bundle.versionCode],
status: "completed",
releaseNotes: [
{ language: "en-US", text: "Bug fixes and improvements" },
],
}],
});
// Commit
await client.edits.validate(APP, edit.id);
await client.edits.commit(APP, edit.id);List and respond to reviews
// No edit needed for reviews
const reviews = await client.reviews.list(APP, {
maxResults: 50,
translationLanguage: "en",
startIndex: 0, // pagination offset (v0.9.51+)
});
for (const review of reviews.reviews ?? []) {
if (review.comments?.[0]?.userComment?.starRating <= 2) {
await client.reviews.reply(APP, review.reviewId, "Thanks for the feedback!");
}
}Manage subscriptions
// No edit needed for subscriptions
const subs = await client.subscriptions.list(APP);
// Get a specific subscription
const sub = await client.subscriptions.get(APP, "premium_monthly");
// Update with mutation options (v0.9.51+)
await client.subscriptions.update(APP, "premium_monthly", data, "price", {
allowMissing: true,
latencyTolerance: "PRODUCT_UPDATE_LATENCY_TOLERANCE_LATENCY_TOLERANT",
});
// Activate a base plan
await client.subscriptions.activateBasePlan(APP, "premium_monthly", "monthly");Verify purchases
// No edit needed for purchases
const purchase = await client.purchases.getProduct(APP, "coins_100", purchaseToken);
if (purchase.purchaseState === 0 && purchase.acknowledgementState === 0) {
await client.purchases.acknowledgeProduct(APP, "coins_100", purchaseToken);
}Upload deobfuscation files (v0.9.51+)
// Upload ProGuard mapping
await client.deobfuscation.upload(APP, edit.id, versionCode, "mapping.txt", "proguard");
// Upload native debug symbols
await client.deobfuscation.upload(APP, edit.id, versionCode, "symbols.zip", "nativeCode");Manage expansion files (v0.9.51+)
// Get expansion file info
const obb = await client.expansionFiles.get(APP, edit.id, versionCode, "main");
// Upload a new expansion file
const uploaded = await client.expansionFiles.upload(APP, edit.id, versionCode, "main", "main.obb");
// Patch expansion file references
await client.expansionFiles.patch(APP, edit.id, versionCode, "main", {
referencesVersion: 10,
});List one-time products with pagination (v0.9.51+)
const products = await client.oneTimeProducts.list(APP, {
pageSize: 25,
pageToken: nextToken,
});5. Pagination
Use the built-in pagination utilities for large result sets:
import { paginate, paginateAll } from "@gpc-cli/api";
// Async generator (stream results)
for await (const page of paginate(
(token) => client.subscriptions.list(APP, { pageToken: token }),
{ limit: 100 },
)) {
for (const sub of page) {
console.log(sub.productId);
}
}
// Collect all results
const all = await paginateAll(
(token) => client.subscriptions.list(APP, { pageToken: token }),
);6. Rate limiting
Since v0.9.47, createApiClient() automatically applies rate limiting to all API calls using Google's 6-bucket model (3,000 queries/min each). No manual configuration needed:
// Rate limiting is automatic — all calls are throttled by resource type
const client = createApiClient({ auth });
// Buckets: edits, purchases, reviews, reporting, monetization, defaultTo customize rate limits (e.g., for shared quota across multiple processes):
import { createRateLimiter, RATE_LIMIT_BUCKETS } from "@gpc-cli/api";
// Override specific buckets
const limiter = createRateLimiter([
{ ...RATE_LIMIT_BUCKETS.edits, maxTokens: 1500 }, // Half of default
{ ...RATE_LIMIT_BUCKETS.purchases, maxTokens: 1500 },
]);
const client = createApiClient({ auth, rateLimiter: limiter });The resolveBucket(path) function maps API paths to buckets automatically:
/edits/paths →editsbucket/purchases/,/orders→purchasesbucket/reviews→reviewsbucket- Reporting API →
reportingbucket /subscriptions,/oneTimeProducts,/inappproducts→monetizationbucket- Everything else →
defaultbucket
7. Error handling
import { PlayApiError } from "@gpc-cli/api";
import { AuthError } from "@gpc-cli/auth";
try {
await client.edits.insert(APP);
} catch (error) {
if (error instanceof AuthError) {
console.error(`Auth failed: ${error.code}`);
} else if (error instanceof PlayApiError) {
console.error(`API error ${error.status}: ${error.code}`);
console.error(`Suggestion: ${error.suggestion}`);
}
}Changelog generation (v0.9.62+)
The changelog pipeline from gpc changelog generate is exposed as standalone @gpc-cli/core exports — useful for CI tooling that wants the clustered/linted data structure directly.
import {
generateChangelog,
resolveLocales,
renderPlayStore,
PLAY_STORE_LIMIT, // 500
type LocaleBundle,
type GeneratedChangelog,
} from "@gpc-cli/core";
const generated: GeneratedChangelog = await generateChangelog({
from: "v0.9.61",
to: "HEAD",
});
// GitHub target: three renderers exposed as RENDERERS["md" | "json" | "prompt"]
// Play Store target: resolveLocales + renderPlayStore
const locales = await resolveLocales("en-US,fr-FR,de-DE");
const { output, bundle } = renderPlayStore(generated, {
locales,
format: "json",
});
for (const entry of bundle.locales) {
console.log(`${entry.language}: ${entry.chars}/${entry.limit} (${entry.status})`);
}For --locales auto, pass { client, packageName } as the second arg to resolveLocales — it calls client.listings.list to infer the locale set from your live Play Store listing.
Apply release notes to a draft (v0.9.64+)
import {
applyReleaseNotes,
validateBundleForApply,
bundleToReleaseNotes,
waitForBundleProcessing,
} from "@gpc-cli/core";
// Convert a LocaleBundle to the API shape
const releaseNotes = bundleToReleaseNotes(bundle);
// Validate (returns blocked locale errors, if any)
const errors = validateBundleForApply(bundle);
if (errors.length > 0) throw new Error(errors.join(", "));
// Write into the latest draft on a track
await applyReleaseNotes(client, "com.example.app", "production", releaseNotes);
// waitForBundleProcessing (v0.9.64+, extended v0.9.77): polls bundles.list
// after AAB upload with Fibonacci backoff (2s, 3s, 5s, 8s, 13s, 21s, 34s ~86s)
// until the uploaded versionCode appears. Fixes large-AAB race.
// v0.9.77 also adds multi-retry guard on validate/commit (15s, 30s, 45s).
await waitForBundleProcessing(client, "com.example.app", editId, versionCode);VitalsThresholds in config types (v0.9.82+)
VitalsThresholds is now part of the typed config surface exposed by @gpc-cli/config:
import type { GpcConfig } from "@gpc-cli/config";
const config: GpcConfig = {
vitals: {
thresholds: { crashRate: 2.0 },
},
};VitalsThresholds is also present on ResolvedConfig (the fully merged runtime shape). Use it when building tooling that reads or writes GPC config files programmatically.
OfferPhaseDetails on Orders (v0.9.79+)
The flat offerPhase string field on Orders is deprecated. Read from offerPhaseDetails instead:
const order = await client.purchases.orders.get(APP, orderId);
// Deprecated: order.offerPhase
// Preferred:
const phase = order.offerPhaseDetails; // OfferPhaseDetails — phase type, cycle counts, pricingdownload() exponential backoff (v0.9.80+)
client.download() (used for APK/AAB binary downloads) now retries automatically with exponential backoff, matching the retry behavior of request(). No code changes needed — transient 5xx errors and network timeouts are retried transparently.
API correctness history (recent)
- v0.9.57:
apprecovery.cancel/deployURLs now use plural/appRecoveries/.dataSafety.updateisPOST, notPUT. PhantomdataSafety.getwas removed.onetimeproducts.offers.activateOffer/deactivateOfferadded. NewgetVitalsErrorCountfunction. - v0.9.58 / v0.9.59: Vitals LMK metric set is
lmkRateMetricSetwith metricsuserPerceivedLmkRate,userPerceivedLmkRate7dUserWeighted,userPerceivedLmkRate28dUserWeighted,distinctUsers. (v0.9.58 shipped the wrong resource name; v0.9.59 is the corrected build.)
Verification
resolveAuth()returns a valid auth clientcreateApiClient({ auth })creates a working clientclient.edits.insert(APP)successfully opens an edit- API calls return typed responses
- Error handling catches
PlayApiErrorandAuthError
Failure modes / debugging
| Symptom | Likely Cause | Fix |
|---|---|---|
AUTH_NO_CREDENTIALS | No auth source found | Pass serviceAccountPath or set GPC_SERVICE_ACCOUNT |
AUTH_INVALID_KEY | Bad JSON in key file | Re-download from Google Cloud Console |
| Edit insert fails with 403 | Service account lacks API access | Enable Google Play Developer API in GCP |
| Concurrent edit conflict | Another edit is open | Commit or delete the existing edit first |
PlayApiError with status 429 | Rate limited | Use createRateLimiter() with appropriate buckets |
| Types not resolving | Wrong TypeScript config | Ensure moduleResolution: "bundler" or "node16" |
Related skills
- gpc-setup — service account creation and auth configuration
- gpc-plugin-development — building plugins that use the SDK internally
- gpc-troubleshooting — interpreting API error codes
{
"skill_name": "gpc-sdk-usage",
"evals": [
{
"id": 1,
"prompt": "I want to build a Node.js backend service that verifies in-app purchases and acknowledges them automatically. I have a service account key. Can you show me how to use @gpc-cli/api and @gpc-cli/auth to do this programmatically?",
"expected_output": "Shows how to set up auth, create API client, verify purchases, and acknowledge them",
"files": [],
"expectations": [
"Installs @gpc-cli/api and @gpc-cli/auth packages",
"Uses resolveAuth with serviceAccountPath or serviceAccountJson",
"Creates client with createApiClient({ auth })",
"Shows client.purchases.getProduct to verify a purchase",
"Shows client.purchases.acknowledgeProduct for acknowledgement"
]
},
{
"id": 2,
"prompt": "I need to write a script that uploads an AAB to the beta track using the TypeScript SDK, not the CLI. I want to handle the full edit lifecycle — insert, upload, set track, validate, commit. Show me the complete code.",
"expected_output": "Complete TypeScript code showing the full edit lifecycle for uploading a release",
"files": [],
"expectations": [
"Shows client.edits.insert to create an edit",
"Shows client.bundles.upload to upload the AAB",
"Shows client.tracks.update to set the beta track with the version code",
"Shows client.edits.validate before committing",
"Shows client.edits.commit to apply all changes"
]
},
{
"id": 3,
"prompt": "I'm building a dashboard that shows all reviews across our 3 apps and lets us reply. The reviews API has rate limits. How do I set up the API client with rate limiting and pagination to handle this safely?",
"expected_output": "Shows rate limiter setup with review-specific buckets and pagination for listing reviews",
"files": [],
"expectations": [
"Uses createRateLimiter with RATE_LIMIT_BUCKETS.reviewsGet and reviewsPost",
"Shows pagination with paginate or paginateAll for listing reviews",
"Creates separate auth or uses the same auth for multiple apps",
"Shows client.reviews.list and client.reviews.reply",
"Mentions the 200 GET/hour and 2000 POST/day rate limits"
]
}
]
}
API Client Reference
Complete reference for the PlayApiClient returned by createApiClient(). Covers all 217 endpoints.
Contributor rules (v0.9.74+)
- URL path parameters: All path parameters must be wrapped with the
p()helper (encodeURIComponent) inhttp.ts. Never interpolate raw values. Example:/${p(packageName)}/edits/${p(editId)}. - Rate limiter: Per-bucket promise-chain mutex — no interval scheduling. Concurrent calls to the same bucket queue automatically.
- SSRF guard:
validateSessionUri()runs on every resumable upload session URI. Do not bypass. - Error redaction:
redactPath()runs on all error messages —/tokens/,/purchases/,/purchaseToken/values are replaced with[REDACTED]. Logerror.message, not raw URLs.
Client namespaces
edits — Edit sessions
client.edits.insert(packageName): Promise<AppEdit>
client.edits.get(packageName, editId): Promise<AppEdit>
client.edits.validate(packageName, editId): Promise<void>
client.edits.commit(packageName, editId, options?): Promise<void> // options: EditCommitOptions
client.edits.delete(packageName, editId): Promise<void>details — App details
client.details.get(packageName, editId): Promise<AppDetails>
client.details.update(packageName, editId, details): Promise<AppDetails>
client.details.patch(packageName, editId, partial): Promise<AppDetails>bundles — AAB uploads
client.bundles.list(packageName, editId): Promise<BundleList>
client.bundles.upload(packageName, editId, filePath, deviceTierConfigId?): Promise<Bundle>tracks — Release tracks
client.tracks.list(packageName, editId): Promise<Track[]>
client.tracks.get(packageName, editId, track): Promise<Track>
client.tracks.update(packageName, editId, track, release): Promise<Track>
client.tracks.patch(packageName, editId, track, release): Promise<Track>releases — Release lifecycle (no edit needed)
client.releases.list(packageName, track): Promise<ReleaseSummary[]>listings — Store listings
client.listings.list(packageName, editId): Promise<Listing[]>
client.listings.get(packageName, editId, language): Promise<Listing>
client.listings.update(packageName, editId, language, listing): Promise<Listing>
client.listings.patch(packageName, editId, language, partial): Promise<Listing>
client.listings.delete(packageName, editId, language): Promise<void>
client.listings.deleteAll(packageName, editId): Promise<void>images — Store images
client.images.list(packageName, editId, language, imageType): Promise<Image[]>
client.images.upload(packageName, editId, language, imageType, filePath): Promise<Image>
client.images.delete(packageName, editId, language, imageType, imageId): Promise<void>
client.images.deleteAll(packageName, editId, language, imageType): Promise<void>reviews — User reviews (no edit needed)
client.reviews.list(packageName, options?): Promise<ReviewsResponse> // options accepts startIndex
client.reviews.get(packageName, reviewId, translationLanguage?): Promise<Review>
client.reviews.reply(packageName, reviewId, replyText): Promise<ReviewReply>subscriptions — Subscriptions (no edit needed)
client.subscriptions.list(packageName, options?): Promise<SubscriptionList>
client.subscriptions.get(packageName, productId): Promise<Subscription>
client.subscriptions.create(packageName, data): Promise<Subscription>
client.subscriptions.update(packageName, productId, data, updateMask?, mutationOptions?): Promise<Subscription> // mutationOptions: MutationOptions
client.subscriptions.delete(packageName, productId): Promise<void>
client.subscriptions.batchGet(packageName, productIds): Promise<Subscription[]>
client.subscriptions.batchUpdate(packageName, requests): Promise<SubscriptionsBatchUpdateResponse>
client.subscriptions.activateBasePlan(packageName, productId, basePlanId): Promise<void>
client.subscriptions.deactivateBasePlan(packageName, productId, basePlanId): Promise<void>
client.subscriptions.deleteBasePlan(packageName, productId, basePlanId): Promise<void>
client.subscriptions.migratePrices(packageName, productId, basePlanId, body): Promise<void>
client.subscriptions.listOffers(packageName, productId, basePlanId): Promise<Offer[]>
client.subscriptions.getOffer(packageName, productId, basePlanId, offerId): Promise<Offer>
client.subscriptions.createOffer(packageName, productId, basePlanId, data): Promise<Offer>
client.subscriptions.updateOffer(packageName, productId, basePlanId, offerId, data, updateMask?): Promise<Offer>
client.subscriptions.deleteOffer(packageName, productId, basePlanId, offerId): Promise<void>
client.subscriptions.activateOffer(packageName, productId, basePlanId, offerId): Promise<void>
client.subscriptions.deactivateOffer(packageName, productId, basePlanId, offerId): Promise<void>inappproducts — IAP (no edit needed)
client.inappproducts.list(packageName, options?): Promise<InAppProductList>
client.inappproducts.get(packageName, sku): Promise<InAppProduct>
client.inappproducts.create(packageName, data): Promise<InAppProduct>
client.inappproducts.update(packageName, sku, data): Promise<InAppProduct>
client.inappproducts.delete(packageName, sku): Promise<void>
client.inappproducts.batchDelete(packageName, skus): Promise<void>purchases — Purchase verification (no edit needed)
client.purchases.getProduct(packageName, productId, token): Promise<ProductPurchase>
client.purchases.getProductV2(packageName, token): Promise<ProductPurchaseV2>
client.purchases.acknowledgeProduct(packageName, productId, token, body?): Promise<void>
client.purchases.consumeProduct(packageName, productId, token): Promise<void>
client.purchases.getSubscriptionV2(packageName, token): Promise<SubscriptionPurchaseV2>
client.purchases.getSubscriptionV1(packageName, subscriptionId, token): Promise<SubscriptionPurchase>
client.purchases.cancelSubscription(packageName, subscriptionId, token): Promise<void>
client.purchases.cancelSubscriptionV2(packageName, token, body?): Promise<void>
client.purchases.deferSubscription(packageName, subscriptionId, token, body): Promise<DeferralInfo>
client.purchases.deferSubscriptionV2(packageName, token, body): Promise<DeferralResponse>
client.purchases.revokeSubscriptionV2(packageName, token, body?: RevokeSubscriptionV2Request): Promise<void>
client.purchases.acknowledgeSubscription(packageName, subscriptionId, token, body?: AcknowledgeSubscriptionRequest): Promise<void>
client.purchases.listVoided(packageName, options?): Promise<VoidedPurchaseList>orders — Orders and refunds (no edit needed)
client.orders.get(packageName, orderId): Promise<Order>
client.orders.batchGet(packageName, orderIds): Promise<Order[]>
client.orders.refund(packageName, orderId, body?): Promise<void>monetization — Pricing (no edit needed)
client.monetization.convertRegionPrices(packageName, price): Promise<RegionPrices>deobfuscation -- Deobfuscation files (requires edit, v0.9.51+)
client.deobfuscation.upload(packageName, editId, versionCode, filePath, fileType?): Promise<DeobfuscationFile>
// fileType: DeobfuscationFileType ('proguard' | 'nativeCode')expansionFiles -- APK expansion files (requires edit, v0.9.51+)
client.expansionFiles.get(packageName, editId, versionCode, expansionFileType): Promise<ExpansionFile>
client.expansionFiles.update(packageName, editId, versionCode, expansionFileType, data): Promise<ExpansionFile>
client.expansionFiles.patch(packageName, editId, versionCode, expansionFileType, partial): Promise<ExpansionFile>
client.expansionFiles.upload(packageName, editId, versionCode, expansionFileType, filePath): Promise<ExpansionFile>oneTimeProducts -- One-time products (no edit needed, v0.9.51+)
client.oneTimeProducts.list(packageName, options?): Promise<OneTimeProductList>
// options accepts pageSize and pageToken for paginationtesters -- Beta testers (requires edit)
client.testers.get(packageName, editId, track): Promise<Testers>
client.testers.update(packageName, editId, track, testers): Promise<Testers>Types (v0.9.51+)
// Options for edits.commit()
type EditCommitOptions = {
changesNotSentForReview?: boolean;
changesInReviewBehavior?: "UNSPECIFIED" | "HALT_REVIEW";
};
// Options for subscriptions.update() and similar mutation endpoints
type MutationOptions = {
allowMissing?: boolean;
latencyTolerance?: ProductUpdateLatencyTolerance;
};
type ProductUpdateLatencyTolerance =
| "PRODUCT_UPDATE_LATENCY_TOLERANCE_UNSPECIFIED"
| "PRODUCT_UPDATE_LATENCY_TOLERANCE_LATENCY_SENSITIVE"
| "PRODUCT_UPDATE_LATENCY_TOLERANCE_LATENCY_TOLERANT";
// File type for deobfuscation uploads
type DeobfuscationFileType = "proguard" | "nativeCode";Utilities
Pagination
import { paginate, paginateAll } from "@gpc-cli/api";
// Async generator
for await (const page of paginate(fetchFn, { limit: 100 })) { ... }
// Collect all
const all = await paginateAll(fetchFn);Rate limiting
As of v0.9.74, each bucket uses a per-bucket promise-chain mutex instead of interval-based scheduling. Concurrent callers within the same bucket queue in arrival order without token races.
import { createRateLimiter, RATE_LIMIT_BUCKETS } from "@gpc-cli/api";
const limiter = createRateLimiter([
RATE_LIMIT_BUCKETS.default, // 200 req/s
RATE_LIMIT_BUCKETS.reviewsGet, // 200 req/hour
RATE_LIMIT_BUCKETS.reviewsPost, // 2000 req/day
RATE_LIMIT_BUCKETS.voidedBurst, // 30 req/30s
RATE_LIMIT_BUCKETS.voidedDaily, // 6000 req/day
]);Client options
createApiClient({
auth, // Required: AuthClient
maxRetries: 3, // Retry on 5xx and network errors
timeout: 30_000, // Request timeout in ms
baseDelay: 1_000, // Initial retry backoff
maxDelay: 60_000, // Maximum retry backoff
rateLimiter: createRateLimiter(), // Optional rate limiter
onRetry: (entry) => { ... }, // Retry event callback
});Auth Patterns for SDK Usage
Advanced authentication patterns when using @gpc-cli/auth programmatically.
Resolution order
resolveAuth() tries credentials in this order:
1. serviceAccountJson option (raw JSON string) 2. serviceAccountPath option (file path) 3. GPC_SERVICE_ACCOUNT environment variable 4. GOOGLE_APPLICATION_CREDENTIALS environment variable 5. Application Default Credentials (ADC)
Pattern 1: Service account from file
import { resolveAuth } from "@gpc-cli/auth";
const auth = await resolveAuth({
serviceAccountPath: "/path/to/key.json",
});
const token = await auth.getAccessToken();
const email = auth.getClientEmail();Pattern 2: Service account from environment
// Set GPC_SERVICE_ACCOUNT to the JSON content or file path
const auth = await resolveAuth();Works in CI where the secret is injected as an env var.
Pattern 3: Application Default Credentials
// Uses gcloud auth application-default login locally
// or metadata server on GCP
const auth = await resolveAuth();No key file needed — uses the ambient credentials.
Pattern 4: Token caching
const auth = await resolveAuth({
serviceAccountPath: "/path/to/key.json",
cachePath: "/tmp/gpc-cache",
});
// First call: fetches token from Google
// Subsequent calls: returns cached token
// Auto-refreshes when token expires (1 hour)
const token = await auth.getAccessToken();Pattern 5: Multiple auth clients
const mainAuth = await resolveAuth({
serviceAccountPath: "/keys/main.json",
});
const clientAuth = await resolveAuth({
serviceAccountPath: "/keys/client.json",
});
const mainClient = createApiClient({ auth: mainAuth });
const clientClient = createApiClient({ auth: clientAuth });Pattern 6: Clear cached tokens
import { clearTokenCache } from "@gpc-cli/auth";
await clearTokenCache("/tmp/gpc-cache");Error handling
import { AuthError } from "@gpc-cli/auth";
try {
const auth = await resolveAuth();
} catch (error) {
if (error instanceof AuthError) {
switch (error.code) {
case "AUTH_NO_CREDENTIALS":
console.error("No credentials found");
break;
case "AUTH_INVALID_KEY":
console.error("Key file is malformed");
break;
case "AUTH_FILE_NOT_FOUND":
console.error("Key file doesn't exist");
break;
case "AUTH_TOKEN_FAILED":
console.error("Couldn't get access token");
break;
}
}
}#!/usr/bin/env node
/**
* Detection script for GPC CLI.
* Returns JSON with installation status, version, auth state, and config.
* Used by Claude Code skill system for deterministic environment detection.
*
* Exit codes:
* 0 — GPC detected (may or may not be authenticated)
* 1 — GPC not found
*/
import { execSync } from "node:child_process";
import { existsSync } from "node:fs";
import { join } from "node:path";
function run(cmd) {
try {
return execSync(cmd, { encoding: "utf-8", timeout: 10000 }).trim();
} catch {
return null;
}
}
const result = {
installed: false,
version: null,
installMethod: null,
authStatus: null,
authMethod: null,
profile: null,
envAuth: false,
defaultApp: null,
configFile: null,
nodeVersion: process.version,
};
// Check if gpc is installed globally
const versionOutput = run("gpc --version");
if (!versionOutput) {
// Try npx
const npxVersion = run("npx gpc --version 2>/dev/null");
if (!npxVersion) {
console.log(JSON.stringify(result, null, 2));
process.exit(1);
}
result.version = npxVersion;
result.installed = true;
result.installMethod = "npx";
} else {
result.version = versionOutput;
result.installed = true;
result.installMethod = "global";
}
// Check auth status
const authOutput = run("gpc auth status --json 2>/dev/null");
if (authOutput) {
try {
const auth = JSON.parse(authOutput);
result.authStatus = auth.status || "unknown";
result.authMethod = auth.method || null;
result.profile = auth.profile || null;
} catch {
result.authStatus = "parse_error";
}
}
// Check for env-based auth
if (process.env.GPC_SERVICE_ACCOUNT) {
result.envAuth = true;
}
// Check default app
const configOutput = run("gpc config get app --json 2>/dev/null");
if (configOutput) {
try {
const config = JSON.parse(configOutput);
result.defaultApp = config.value || config.app || null;
} catch {
result.defaultApp = configOutput || null;
}
}
// Check for .gpcrc.json in current directory
const rcPath = join(process.cwd(), ".gpcrc.json");
if (existsSync(rcPath)) {
result.configFile = rcPath;
}
console.log(JSON.stringify(result, null, 2));
process.exit(0);