Solved

Using the latest API to get data about each email send

  • 14 December 2023
  • 2 replies
  • 51 views

Badge +2
  • Contributor I
  • 4 replies

I’m migrating from an old version of the API to the latest (2023-10-15). I would like to query for all of the individual email sends that have happened over a time period, including data about the recipients of the email. Previously, I was doing this in Ruby like this:

 

 metrics = Klaviyo::Metrics.get_metric_timeline(

   "TTP7r5",

   count: 50,

   since: 1.week.ago,

   sort: "desc"

 )

 

In the new API, I see that there is an endpoint for getting metrics, but it seems to only return data about the metric itself. And then there is the metric aggregates endpoint, but I don’t want an aggregate, I’d like the individual events. The only thing I’ve been able to figure out that this endpoint will return is counts of emails sent. Is there a way to get the individual email events now?

icon

Best answer by saulblum 14 December 2023, 23:10

View original

2 replies

Userlevel 5
Badge +7

Get Events is your friend. You’d use a filter param such as:

equals(metric_id,"TTP7r5"),less-than(datetime,2023-12-14T00:00:00Z),greater-than(datetime,2023-12-07T00:00:00Z)

This will return the properties of each event.

Badge +2

Thanks so much @saulblum! I’m not sure I would have ever figured that out.

Reply