Feature: AdMob API integration for ad monetization reporting (admob/v1)
Summary
Integrate the Google AdMob API (v1) into the gplay CLI to provide programmatic access to AdMob account data, ad unit inventory, and ad revenue reporting — giving developers a unified monetization view alongside existing Play Console financial reports, subscriptions, and in-app purchase commands.
Why This Is Applicable to Google Play
A significant number of Play Console developers monetize their Android apps with AdMob. Ad revenue from banners, interstitials, rewarded ads, and app-open ads is a critical metric alongside IAP and subscription earnings. The gplay CLI already covers IAP (gplay iap), subscriptions (gplay subscriptions), one-time products (gplay otp), and financial reports (gplay reports financial) — but ad monetization data from AdMob is completely missing. Adding AdMob closes this gap and gives developers a single CLI for all Google Play monetization workflows.
Problem
Today, developers who monetize with AdMob must:
- Switch to the AdMob web console (admob.google.com) to check ad revenue, eCPM, fill rates, and impression data
- Manually cross-reference AdMob earnings with Play Console financial reports
- Cannot script or automate ad performance monitoring alongside their existing gplay CI/CD pipelines
- Have no CLI-based way to list ad units, inspect mediation performance, or generate ad revenue reports
Goals
- Provide read-only access to AdMob account data, apps, and ad units via the CLI
- Generate network reports (ad revenue, impressions, CTR, RPM) with flexible date ranges, dimensions, and metrics
- Generate mediation reports to analyze third-party ad source performance
- Support the same output formats as existing commands (JSON, table, markdown)
- Support
--paginatefor listing apps and ad units - Handle the OAuth2 authentication requirement (AdMob does not support service accounts — only OAuth2 desktop/web flows)
- Store AdMob publisher ID in gplay config for seamless usage
Proposed Commands
Account
# Get AdMob account info (publisher ID, timezone, currency)
gplay admob account get
# List all accessible AdMob publisher accounts
gplay admob account list
Apps
# List apps linked to the AdMob account
gplay admob apps list [--paginate] [--output json|table|markdown]
# Output includes: name, appId, platform (ANDROID/IOS), appApprovalState, linkedAppInfo
Ad Units
# List ad units for the account
gplay admob ad-units list [--paginate] [--output json|table|markdown]
# Filter by app
gplay admob ad-units list --app-id "ca-app-pub-1234567890~0987654321"
# Output includes: adUnitId, displayName, appId, adFormat (BANNER, INTERSTITIAL, REWARDED, NATIVE, APP_OPEN), adTypes
Network Reports
# Generate a network report (ad revenue from AdMob network)
gplay admob reports network \
--start-date 2026-03-01 \
--end-date 2026-03-31 \
--dimensions DATE,APP,COUNTRY \
--metrics ESTIMATED_EARNINGS,IMPRESSIONS,CLICKS,AD_REQUESTS,MATCHED_REQUESTS,MATCH_RATE \
[--sort ESTIMATED_EARNINGS:desc] \
[--filter-country US,CA,GB] \
[--currency USD] \
[--output json|table|markdown]
# Quick: last 7 days earnings summary
gplay admob reports network --last 7d --metrics ESTIMATED_EARNINGS,IMPRESSION_RPM
Mediation Reports
# Generate a mediation report (performance across ad sources)
gplay admob reports mediation \
--start-date 2026-03-01 \
--end-date 2026-03-31 \
--dimensions DATE,AD_SOURCE,APP \
--metrics ESTIMATED_EARNINGS,IMPRESSIONS,OBSERVED_ECPM,CLICKS \
[--sort OBSERVED_ECPM:desc] \
[--output json|table|markdown]
# Analyze a specific ad source
gplay admob reports mediation --last 30d --dimensions AD_SOURCE --metrics ESTIMATED_EARNINGS,OBSERVED_ECPM
Implementation Details
API Endpoints
| Resource | Method | Endpoint |
|---|---|---|
| Accounts | GET | GET /v1/accounts |
| Account | GET | GET /v1/{name=accounts/*} |
| Apps | LIST | GET /v1/{parent=accounts/*}/apps |
| Ad Units | LIST | GET /v1/{parent=accounts/*}/adUnits |
| Network Report | POST | POST /v1/{parent=accounts/*}/networkReport:generate |
| Mediation Report | POST | POST /v1/{parent=accounts/*}/mediationReport:generate |
Base URL: https://admob.googleapis.com
Discovery document: https://admob.googleapis.com/$discovery/rest?version=v1
Authentication Requirements
Important: AdMob API does NOT support service accounts. It requires OAuth2 user-based authorization.
- OAuth2 Scopes:
https://www.googleapis.com/auth/admob.readonly— full read access to account, inventory, mediation settings, and reportshttps://www.googleapis.com/auth/admob.report— read access to ad performance and earnings reports only
- Supported Flows: Desktop app (localhost redirect) or Web app (callback URL)
- Implementation: New
gplay admob authsubcommand to run the OAuth2 flow, store refresh token in config. This is separate from the existing Play Console service account auth.
# Authenticate with AdMob (opens browser for OAuth2 consent)
gplay admob auth login [--scope readonly|report]
# Check AdMob auth status
gplay admob auth status
New Packages
internal/cli/admob/— Command group and subcommands (account, apps, ad-units, reports, auth)internal/admobclient/— AdMob API client wrapper usinggoogle.golang.org/api/admob/v1
Go Client Library
Package: google.golang.org/api/admob/v1
Key types:
admob.Service— root serviceadmob.AccountsService— account operationsadmob.AccountsAppsService— app listing with paginationadmob.AccountsAdUnitsService— ad unit listing with paginationadmob.AccountsNetworkReportService— network report generationadmob.AccountsMediationReportService— mediation report generationadmob.NetworkReportSpec— date range, dimensions, metrics, filters, sort conditionsadmob.MediationReportSpec— same structure for mediation dataadmob.GenerateNetworkReportResponse— streaming response with Header, Row, Footeradmob.PublisherAccount— publisher ID, timezone, currency code
AdMob Account / Publisher ID Configuration
Add to ~/.gplay/config.yaml:
admob:
publisher_id: "pub-1234567890123456"
default_scope: "readonly"
# OAuth2 tokens stored securely
New environment variable: GPLAY_ADMOB_PUBLISHER_ID
Report Generation Details
Network Report Dimensions: DATE, MONTH, WEEK, AD_UNIT, APP, AD_TYPE, COUNTRY, FORMAT, PLATFORM, MOBILE_OS_VERSION, GMA_SDK_VERSION, APP_VERSION_NAME, SERVING_RESTRICTION
Network Report Metrics: AD_REQUESTS, CLICKS, ESTIMATED_EARNINGS, IMPRESSIONS, IMPRESSION_CTR, IMPRESSION_RPM, MATCHED_REQUESTS, MATCH_RATE, SHOW_RATE
Mediation Report Dimensions: DATE, MONTH, WEEK, AD_SOURCE, AD_SOURCE_INSTANCE, AD_UNIT, APP, MEDIATION_GROUP, COUNTRY, FORMAT, PLATFORM, MOBILE_OS_VERSION, GMA_SDK_VERSION, APP_VERSION_NAME, SERVING_RESTRICTION
Mediation Report Metrics: AD_REQUESTS, CLICKS, ESTIMATED_EARNINGS, IMPRESSIONS, IMPRESSION_CTR, MATCHED_REQUESTS, MATCH_RATE, OBSERVED_ECPM
Date Ranges: Specified via --start-date / --end-date (YYYY-MM-DD) or convenience flag --last (7d, 30d, 90d)
Sorting: --sort METRIC:asc|desc (e.g., --sort ESTIMATED_EARNINGS:desc)
Filtering: --filter-country US,CA maps to DimensionFilter with MatchesAny
Timezone note: The API only supports the account default timezone and America/Los_Angeles
Streaming responses: Report endpoints return streaming JSON (header → rows → footer). The client must aggregate rows before formatting output.
Earnings format: ESTIMATED_EARNINGS and IMPRESSION_RPM are returned in micros (1,000,000 = $1.00). The CLI should convert to human-readable currency in table/markdown output.
Output Format Considerations
- JSON output: raw API response (micros for monetary values, preserving full precision)
- Table/markdown output: convert micros to currency (e.g.,
$6.50), format rates as percentages, use the account'sCurrencyCode - Report headers should show the date range and any applied filters
- Footer warnings (e.g., data delays) should be shown on stderr
Acceptance Criteria
- [ ]
gplay admob account getreturns publisher ID, timezone, and currency code - [ ]
gplay admob account listlists all accessible publisher accounts - [ ]
gplay admob apps listlists AdMob apps with pagination support - [ ]
gplay admob ad-units listlists ad units with optional app filter and pagination - [ ]
gplay admob reports networkgenerates network reports with configurable date range, dimensions, metrics, filters, and sort - [ ]
gplay admob reports mediationgenerates mediation reports with the same configurability - [ ]
gplay admob auth loginruns OAuth2 desktop flow and persists refresh token - [ ]
gplay admob auth statusshows current authentication state - [ ] All commands support
--output json|table|markdown - [ ] Monetary values in micros are converted to human-readable format in table/markdown output
- [ ]
--paginateworks for apps and ad-units listing - [ ]
--dry-runworks for report generation (shows the request spec without executing) - [ ] Publisher ID configurable via
--publisher-idflag, config file, orGPLAY_ADMOB_PUBLISHER_IDenv var - [ ] Comprehensive test coverage including CLI flag validation, output formatting, and API client mocking
- [ ] Commands registered in
internal/cli/registry/registry.go - [ ]
--helpis self-documenting for all new commands and flags
References
- AdMob API Overview
- AdMob API v1 REST Reference
- Getting Started Guide
- OAuth Setup
- Prerequisites
- Report Generation Guide
- Metrics and Dimensions List
- Go Client Library (v1)
- Go Client Library (v1beta) — has additional endpoints (campaign reports, ad sources, mediation groups CRUD)
- API Discovery Document
Implementation Checklist
Command & Registration
- [ ] Command group
gplay admobininternal/cli/admob/ - [ ] Subcommands:
accounts list/get,apps list,ad-units list,reports network,reports mediation,reports generate - [ ] Registered in
internal/cli/registry/registry.go - [ ]
UsageFunc: shared.DefaultUsageFuncset on all commands - [ ] Dedicated client wrapper for
admob/v1API - [ ] Required flags validated with stderr error messages
Tests
- [ ] CLI black-box tests in
internal/cmdtest/admob_test.go - [ ] Unit tests for report date range validation and metric formatting
- [ ] Error paths: missing
--account, invalid date range, unknown report type
Docs & Help
- [ ]
--helpoutput follows existing conventions - [ ] Command docs regenerated:
gplay docs generate
Validation (before opening PR)
make format
make lint
make test
make build
/tmp/gplay admob --help
/tmp/gplay admob accounts list --help
/tmp/gplay admob reports network --help
/tmp/gplay admob reports network # missing required flags → stderr error
Addendum to checklist above — docs CI gate:
The PR CI now runs make check-docs on every PR. This means:
- After implementing the command, run
make docsto regenerateGPLAY.md - Commit the updated
GPLAY.mdalongside your code changes - If you forget, the PR check will fail with: "GPLAY.md is out of date"
This ensures every user-facing command, flag, and help text is always reflected in the reference docs.
Consolidating individual feature requests into the roadmap so new visitors see a clean tracker. This item is on the roadmap: #245 — please 👍 there and comment which item you're waiting on. Reopen or file a fresh issue if you start on a PR.