search a ads

This commit is contained in:
JiriUhlir
2026-06-18 12:43:42 +02:00
parent 9cd5c8011b
commit 125b112967
12 changed files with 748 additions and 191 deletions
+26 -3
View File
@@ -1,7 +1,8 @@
# analytics
Stateless API proxy for **Google Analytics 4** and **Sklik** (Seznam), running
in AppFactory behind the Caddy reverse proxy at `/apps/analytics`.
Stateless API proxy for **Google Analytics 4**, **Google Search Console**,
**Google Ads** and **Sklik** (Seznam), running in AppFactory behind the Caddy
reverse proxy at `/apps/analytics`.
The service stores no secrets. Every credential is supplied **per request** as
an `X-` header and used only to call the upstream API.
@@ -23,6 +24,10 @@ Interactive docs (Swagger UI): `/docs` — publicly `https://services.csbot.cz/a
| GA4 Admin | GET | `/ga/admin/accounts`, `/ga/admin/accountSummaries` |
| GA4 Admin | GET | `/ga/admin/properties` (`?accountId=`), `/ga/admin/properties/{id}` |
| GA4 Admin | GET | `/ga/admin/properties/{id}/dataStreams` |
| Search Console | POST | `/gsc/searchAnalytics/query` (`?siteUrl=`), `/gsc/urlInspection` |
| Search Console | GET | `/gsc/sites`, `/gsc/site`, `/gsc/sitemaps`, `/gsc/sitemap` (`?siteUrl=`) |
| Google Ads | POST | `/googleads/customers/{id}/search`, `/googleads/customers/{id}/searchStream` |
| Google Ads | GET | `/googleads/customers:listAccessibleCustomers` |
| Sklik | POST | `/sklik/login`, `/sklik/report/{entity}`, `/sklik/rpc/{method}` |
| Sklik | GET | `/sklik/limits` |
@@ -36,6 +41,19 @@ Interactive docs (Swagger UI): `/docs` — publicly `https://services.csbot.cz/a
| `X-GA-Credentials` | one of these | Base64-encoded service-account JSON key; the proxy mints a token. |
| `X-GA-Quota-Project` | no | Google Cloud project id for quota/billing. |
**Google Search Console** — same model, prefix `X-GSC-` (scope `webmasters.readonly`):
`X-GSC-Access-Token` / `X-GSC-Credentials` (+ `X-GSC-Quota-Project`).
**Google Ads** — same OAuth (scope `adwords`) plus a developer token:
| Header | Required | Meaning |
| --- | --- | --- |
| `X-GAds-Developer-Token` | yes | Google Ads developer token. |
| `X-GAds-Access-Token` | one of these | Ready OAuth2 access token. |
| `X-GAds-Credentials` | one of these | Base64 service-account JSON (needs domain-wide delegation). |
| `X-GAds-Login-Customer-Id` | no | Manager (MCC) id → `login-customer-id`. |
| `X-GAds-Quota-Project` | no | Google Cloud project id. |
**Sklik:**
| Header | Required | Meaning |
@@ -43,6 +61,9 @@ Interactive docs (Swagger UI): `/docs` — publicly `https://services.csbot.cz/a
| `X-Sklik-Token` | yes | Sklik API token from account settings. |
| `X-Sklik-User-Id` | no | Managed account id for agency/MCC access. |
Where to obtain each credential is described at the top of `/docs` (Swagger) and
in [documentation/](documentation/).
## Run locally
```bash
@@ -54,7 +75,9 @@ uvicorn app.main:app --reload --port 8000
## Configuration (env)
Non-secret only — see [app/config.py](app/config.py): `ROOT_PATH`,
`GA_DATA_BASE_URL`, `GA_ADMIN_BASE_URL`, `GA_SCOPE`, `SKLIK_BASE_URL`,
`GA_DATA_BASE_URL`, `GA_ADMIN_BASE_URL`, `GA_SCOPE`, `GSC_DATA_BASE_URL`,
`GSC_INSPECT_BASE_URL`, `GSC_SCOPE`, `GOOGLE_ADS_BASE_URL`,
`GOOGLE_ADS_API_VERSION`, `GOOGLE_ADS_SCOPE`, `SKLIK_BASE_URL`,
`HTTP_TIMEOUT_SECONDS`, `LOG_LEVEL`.
See [documentation/](documentation/) for per-integration detail.