Solved

API "since" parameter is not working as expected

  • 12 October 2022
  • 1 reply
  • 26 views

Badge

Hi,

I have this account for testing the API and I started my first campaign 1 day ago. All endpoints work, but I am having issues with the metric timeline endpoint to fetch events of all  metrics https://developers.klaviyo.com/en/reference/metrics-timeline . 

When not specifying the ‘since’ parameter I get all my event data (5 events) :

curl --location --request GET 'https://a.klaviyo.com/api/v1/metrics/timeline?count=100&api_key=APIKEY'

When I specify the ‘since’ to right now I get all my event data (5 events) :

curl --location --request GET 'https://a.klaviyo.com/api/v1/metrics/timeline?count=100&api_key=APIKEY&since=1665566767'

When I specify the ‘since’ parameter to 2 days ago (10 October 2022 01:52:22 : ‘1665366742’ ) I get NO data:

curl --location --request GET 'https://a.klaviyo.com/api/v1/metrics/timeline?count=100&api_key=APIKEY&since=1665366742'

When I specify the ‘since’ parameter to 12 April 2032 : ‘1965366742’ I would expect to get no data, but i still receive all the data 

curl --location --request GET 'https://a.klaviyo.com/api/v1/metrics/timeline?count=100&api_key=APIKEY&since=1965366742'

 

How does this since parameter work? 

  1. I would expect to get data when searching for the since=1665366742
  2. I would expect not to get any data for the since=1965366742

 

UPDATE : 

It seems to work when I set the sort = asc, but it’s confusing to why

icon

Best answer by Dov 12 October 2022, 18:11

View original

1 reply

Userlevel 7
Badge +61

Hi @AdamBak,

Thanks for sharing this with us.

The word since is a bit confusing in this context, it's really "show me all events that were created before this date”, but when you adjust the sorting to sort=asc it turns into "show me all events that were created after this date" which is why it works.

Thanks for being a community member.

Reply