Client Setup
How to initialize the Python SDK client and user data
Before sending any events, you need to create a client instance with your API key and base URL, and prepare the user data object.
from audiencelab_python_sdk import (
Client, UserData, RegisterUser, FetchToken,
RetentionData, PurchaseData, AdData, AppEvent
)
api_key = "your_api_key"
base_url = "https://example.com"
client = Client(api_key, base_url)
user_data = UserData() \
.set_user_id("user_12345") \
.set_user_ip("123.123.1.1") \
.set_event_timestamp("2024-10-05T16:48:00+02:00") \
.set_device_info({
"device_name": "My Device",
"height": 2436,
"width": 1125,
"os": "iOS",
"os_version": "14.4",
"device_model": "iPhone15,4",
"timezone": "America/New_York"
})
⚠️ Important: Detailed device_info is only required during the initial user registration. For later events, you only need to provide user_id and user_ip.
If the event did not happen in real time, include an event_timestamp in ISO 8601 format.
You’re now ready to register the user or fetch the creative token.