This guide walks you through installing the Kard Python SDK, authenticating with the Kard API, and making your first request.
KARD_CLIENT_ID and KARD_CLIENT_SECRETpipImport and instantiate the KardApi client using your credentials.
This SDK supports two authentication methods:
OAuth Client Credentials
Bearer Token Authentication
The client automatically handles authentication, retries, and timeouts.
1. Creating a User:
To enhance offer targeting and attribution, you can include a hashed email (HEM) when creating users. The SDK includes a built-in generate_hem utility that normalizes and hashes email addresses:
The function normalizes the email before hashing (removes whitespace, lowercases, and handles Gmail-specific rules like dot and + suffix removal). It raises a ValueError for invalid inputs.
2. Fetching Offers for User with Extended API:
3. Submitting Transaction for User:
All SDK methods return typed responses and raise typed errors.
The SDK also provides an async client for non-blocking API calls.
If an API request fails (4xx or 5xx), the SDK raises an ApiError.
Retries are enabled by default (max 2 attempts).
The SDK defaults to a 60 second timeout. Timeouts can be configured at the client or request level.
To inspect headers or status codes, use with_raw_response.
You can supply a custom httpx.Client to customize transports, proxies, or networking behavior.