Hi, so I am trying to retrieve Klaviyo events using Python klaviyo-api package (12.0.0). I am having trouble filtering mentioned events on datetime - it seems that I am unable to chain two filters together either by seperating them with a comma or using the and() method.
Sample code:
from klaviyo_api import KlaviyoAPI
klaviyo = KlaviyoAPI("xxxxxx", max_delay=60, max_retries=3, test_host=None)
start_timestamp = "2024-08-29T00:00:00.00Z"
end_timestamp = "2024-08-29T02:00:00.00Z"
# Define the filter for timestamps
date_filter = f"greater-or-equal(datetime,{start_timestamp}),less-than(datetime,{end_timestamp})"
data = []
# Call the get_events method with the filter
events_response = klaviyo.Events.get_events(filter=date_filter)
data += events_response["data"]
next = events_response["links"]["next"]
while next:
events_response = klaviyo.Events.get_events(page_cursor=next)
data += events_response["data"]
next = events_response["links"]["next"]
The while loop never stops and if I manually stop the loop, I can see that the min() and max() datetimes are:
- 2024-08-29T01:59:43+00:00
- 2024-08-28T20:14:42+00:00
Based on this the greater-or-equal filter is not applied. I have also tried applying said filters using the following syntax:
date_filter = f"and(greater-or-equal(datetime,{start_timestamp}),less-than(datetime,{end_timestamp}))"
Without any luck. Any help is appreciated. Thanks!