Server-SidePython SDK
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.
UserData Methods
Prop | Type | Default |
---|---|---|
user_id | string | - |
ip_address | string | - |
timestamp? | string | - |
last_login? | string | - |
Device Info Object
Prop | Type | Default |
---|---|---|
device_name | string | - |
device_model | string | - |
timezone | string | - |
height | integer | - |
width | integer | - |
window_height | integer | - |
window_width | integer | - |
os | string | - |
os_version | string | - |
device_vendor? | string | - |
madid? | string | - |
advertiser_tracking_enabled? | boolean | - |
application_tracking_enabled? | boolean | - |
dpi? | integer | - |
screen_density? | double | - |
cores? | integer | - |
ext_stor_size? | integer | - |
free_stor? | integer | - |
low_battery_level? | boolean | - |
locale? | string | - |
carrier? | string | - |
Creative Token Info Object
Prop | Type | Default |
---|---|---|
creative_token? | string | - |
madid? | string | - |
os_system? | string | - |
device_name? | string | - |
device_model? | string | - |
utc_offset? | string | - |
install_date? | string | - |
last_login_date? | string | - |
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.