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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

entirius_py_google_ads_sdk-2.0.0.tar.gz (59.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

entirius_py_google_ads_sdk-2.0.0-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

Details for the file entirius_py_google_ads_sdk-2.0.0.tar.gz.

File metadata

  • Download URL: entirius_py_google_ads_sdk-2.0.0.tar.gz
  • Upload date:
  • Size: 59.6 kB
  • Tags: Source
  • Uploaded using 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}

File hashes

Hashes for entirius_py_google_ads_sdk-2.0.0.tar.gz
Algorithm Hash digest
SHA256 3d86b35b64633e58c9c743325c526b72ff0ae955b5a34af299070dd1fff547af
MD5 659dc7e7cbf0c223cc49a0478b1d06db
BLAKE2b-256 c5b6a89537850d9f779e7b83daf4b941d80d93002fa4edb929e57da25400d0f2

See more details on using hashes here.

File details

Details for the file entirius_py_google_ads_sdk-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: entirius_py_google_ads_sdk-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 13.6 kB
  • Tags: Python 3
  • Uploaded using 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}

File hashes

Hashes for entirius_py_google_ads_sdk-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3c1ccb76579c097abdb17c12c3608cea6511c3a447878d798dbe9de66c3064ed
MD5 b85a1ee4cee1a98933d32ef75a29c3a6
BLAKE2b-256 73389a34dad9014c99f47d473ea5e99966afbaab6877f603e243599a094ca4ee

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 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