Skip to main content

google-ads-sdk

Volkanos wrapper around the official google-ads Python client. Currently exposes click-conversion uploads (ConversionsClient); designed to grow with ReportingClient, BudgetsClient, etc. as more Volkanos modules need them.

This SDK is stateless and Django-agnostic. Caller passes credentials as plain strings; caller stores them however it likes (encrypted DB column, env vars, vault).

Install

uv pip install entirius-py-google-ads-sdk

Or as a dependency in pyproject.toml:

"entirius-py-google-ads-sdk>=2.0.0"

Use

from google_ads_sdk import ConversionsClient, ClickConversion

client = ConversionsClient(
    developer_token="ABC...",  # global, from Google Ads dev console
    oauth_client_id="...apps.googleusercontent.com",
    oauth_client_secret="...",
    refresh_token="1//0gAa...",  # per-account, from OAuth flow (decrypt before passing)
    customer_id="8323936346",  # the account that owns the conversion actions
    login_customer_id=None,  # set if accessing via MCC
)

result = client.upload_click_conversions(
    [
        ClickConversion(
            conversion_action_id="9876543210",
            conversion_date_time="2026-04-19 14:30:00+00:00",
            conversion_value=200.0,
            currency_code="EUR",
            gclid="CjwK...",
        ),
        ClickConversion(
            conversion_action_id="9876543210",
            conversion_date_time="2026-04-19 14:31:00+00:00",
            conversion_value=200.0,
            currency_code="EUR",
            hashed_email="64-char-sha256-hex",  # enhanced fallback if no gclid
        ),
    ],
    partial_failure=True,
)
print(result.successes, result.failures)
# successes: list[int] — indices of accepted conversions
# failures:  list[ConversionFailure(index=int, error_message=str)]

OAuth refresh-token flow

The SDK does not implement OAuth interactively — it expects a working refresh token. The recommended flow:

  1. One-time interactive script (or a small admin endpoint) exchanges an authorization code for a refresh token via google-auth-oauthlib.
  2. Persist the refresh token encrypted at rest — the consuming Django module is responsible for encryption.
  3. Pass the decrypted token to ConversionsClient(...).

Partial failure semantics

upload_click_conversions(..., partial_failure=True) always returns an UploadResult. A whole-call failure (auth, network, malformed batch) raises GoogleAdsUploadError. Per-row failures are reported in result.failures keyed by input list index — callers can update their queue rows accordingly.

Tests

uv run pytest

The google-ads SDK is mocked at the client.get_service boundary. No real account or network access is needed.

Metadata

Release files for entirius-py-google-ads-sdk 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for entirius-py-google-ads-sdk 2.0.0
File Size Uploaded
entirius_py_google_ads_sdk-2.0.0.tar.gz 59.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for entirius-py-google-ads-sdk 2.0.0
File Interpreter ABI Platform
entirius_py_google_ads_sdk-2.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 73.2 kB

Release files / entirius_py_google_ads_sdk-2.0.0.tar.gz

Download URL entirius_py_google_ads_sdk-2.0.0.tar.gz
Size 59.6 kB
Tags Source
SHA-256 checksum
How to use checksums
3d86b35b64633e58c9c743325c526b72ff0ae955b5a34af299070dd1fff547af
BLAKE2b-256 checksum
How to use checksums
c5b6a89537850d9f779e7b83daf4b941d80d93002fa4edb929e57da25400d0f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.0 {"installer":{"name":"uv","version":"0.12.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / entirius_py_google_ads_sdk-2.0.0-py3-none-any.whl

Download URL entirius_py_google_ads_sdk-2.0.0-py3-none-any.whl
Size 13.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3c1ccb76579c097abdb17c12c3608cea6511c3a447878d798dbe9de66c3064ed
BLAKE2b-256 checksum
How to use checksums
73389a34dad9014c99f47d473ea5e99966afbaab6877f603e243599a094ca4ee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.0 {"installer":{"name":"uv","version":"0.12.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page