Solved

How do I get a list of all active users/events/sessions via the API?

  • 7 October 2021
  • 6 replies
  • 49 views

Badge

I would like to either get a list of all active users IDs, event IDs, or session IDs with a time filter of say a few hours, via the API. Is it possible to do so?

icon

Best answer by Saish Redkar 7 October 2021, 23:32

View original

6 replies

Userlevel 6
Badge +4

Hey @Wei Jie ,

Most of the endpoints listed in the Dashboard REST API documentation will give you aggregated numbers of active user counts, event counts and some session metrics depending on how you format the API calls using your date filter and other parameters. Afaik, there isn’t an endpoint which can directly give you list of all active users IDs, event IDs, or session IDs.

However. you can get a list of user ids for a datapoint in an event seg chart by downloading the users via Microscope or by downloading your cohort using the Behavioral Cohorts API

The only other way of getting ALL those IDs in one go would be the Export API, where every event record will have the user id, event id and session id. The lowest granular time range for this is 24 hours .i.e. a day’s worth of event data.

Let me know if I have interpreted your question correctly. Hope this helps!

Badge

Hi @Saish Redkar ,

 

Just to clarify, I would either need user or event or sessions, I would not need all of them at once, though that would be preferred.

 

Thank you for the suggestion on the Microscope feature in the event seg chart. Is there a way I can download the users via code?

 

As for Cohorts or the Export API, unfortunately the granularity of 1 day is too high and I would prefer it to be a few hours.

 

Thank you

Wei Jie

 

 

Userlevel 3
Badge +1

Hi Wei Jie,

 

If you are looking to export data for only a specific few hourly data points, then the method that Saish has recommended would be the best solution - you should use the Microscope to extract the data via CSV export.

 

The alternative is that you can set up a chart and use the Dashboard REST API by following the instructions here: https://developers.amplitude.com/docs/dashboard-rest-api#event-segmentation

 

Let me know if you have any questions!

Badge

Hi @serene.gan ,

 

If I’m not wrong, the Dashboard REST API for event segmentation only returns summary metrics like counts, but I would need to return the user IDs. Would that be possible with a formula?

 

Thank you

Wei Jie

Userlevel 6
Badge +4

A hacky way would be creating a cohort via Microscope for an event seg chart on realtime/hourly granularity and then getting that cohort via the Behavioral Cohort API , if at all you need to do it programmatically. But this would be a static cohort in most of the cases.

I don’t think there is any other way of getting user ids without going over a 1 day granularity.

Userlevel 3
Badge +1

Hi @serene.gan ,

 

If I’m not wrong, the Dashboard REST API for event segmentation only returns summary metrics like counts, but I would need to return the user IDs. Would that be possible with a formula?

 

Thank you

Wei Jie

Hi Wei Jie,

Apologies - I was under the impression that you could insert a group-by and it would break down the IDs for you. If you are on our paid plans, another way you could explore this would be to set up a cohort and then extract it programmatically via our Behavioral Cohorts API

Would it be possible for you to share a little more about your use case and why you are looking to extract the user IDs on an hourly basis? What I might be able to do for you here is to share this feedback with my Product team as a feature request on your behalf!

Best,

Serene

Reply