klaviyo / klaviyo-api-python

Python SDK for Klaviyo API
https://developers.klaviyo.com
MIT License
36 stars 6 forks source link

Filter does not work on profiles endpoint #3

Closed pepa-from-meiro closed 1 year ago

pepa-from-meiro commented 1 year ago

Calling the following method with the filter:

klaviyo.Profiles.get_profiles(filter="greater-than(created,2022-07-26T13:36:45+00:00),less-than(created,2022-07-26T13:36:47+00:00)"

I am expecting profiles that were created between entered dates. But it seems that I am getting all the profiles.

jon-batscha commented 1 year ago

Hey! great question! (and apologies for the delayed response...)

I see 2 issues here:

  1. The Datetime formatting:

It looks like the format you used is not supported; I was able to get results using a single filter, with both of the following formats:

  1. Separately though, it looks like you caught a limitation in our API, in that it doesn't not currently support multiple datetime filters at once.

I'll reach out to my team to let them know, and see if we can support this.

Until then, my recommendation to get around this limitation is to provide just one limit, and provide a sort param to make up for the missing one.

For example: if you're interested in events between 2021-2022, you can provide the following filter: "greater-than(created,2021-01-00T00:00:00.00Z)", and provide sort as created (which sorts by created, ascending). You can then page through the results, checking the created date, for each profile/page, and stopping the iteration once you've reached your desired upper-limit datetime.

I'll follow up here once I've heard back from my team. Until then, hopefully you or others can find this workaround helpful.

Cheers, Jon