Skip to main content

Hello.
In my company we need to extract user session counts data from the API to enrich the analysis with business data, but according to the documentation, the Sessions endpoint does not receive any more parameters to be able to segment the resulting data. 
I have tried to extract using the event segmentation endpoint but I cannot find the code for the Amplitude Start Session event.
What is the correct way to extract session data segmented by custom user properties?

Hi ​@seba Garces 

If you are looking to just extract the total session counts of a user till date, then the User Activity endpoint might be a better bet - https://amplitude.com/docs/apis/analytics/dashboard-rest#user-activity
 

 


Hi Seba,

Saish has a great suggestion here with regards to utilizing the number of user sessions in this fashion. One additional suggestion I'd make if you aren't querying a specific user would be to create a User Sessions chart and then use the Dashboard Rest API 'Results From Existing Chart' endpoint to generate the results. You can read about this here: https://amplitude.com/docs/apis/analytics/dashboard-rest#get-results-from-an-existing-chart

Otherwise, hope this helps and thanks for hopping in Saish!

Best,
Jarren


P.S. Checkout upcoming events and user meetups on our events page.

Hi Seba,

Saish has a great suggestion here with regards to utilizing the number of user sessions in this fashion. One additional suggestion I'd make if you aren't querying a specific user would be to create a User Sessions chart and then use the Dashboard Rest API 'Results From Existing Chart' endpoint to generate the results. You can read about this here: https://amplitude.com/docs/apis/analytics/dashboard-rest#get-results-from-an-existing-chart

Otherwise, hope this helps and thanks for hopping in Saish!

Best,
Jarren


P.S. Checkout upcoming events and user meetups on our events page.

Thanks for your reply.


I have tried the way to extract data from existing reports and it works but it has limits on the number of rows to extract. For further context, I need to group the data by a custom user property and this generates truncated data. Is there any way to increase this limit that the reports have?


Hi ​@seba Garces 

If you are looking to just extract the total session counts of a user till date, then the User Activity endpoint might be a better bet - https://amplitude.com/docs/apis/analytics/dashboard-rest#user-activity
 

 

That's a good suggestion, thank you very much.

However, I would have to iterate over all the active users in the system to be able to group the data by the custom field that we need.
Is there an endpoint where I can obtain a list with all the users (Amplitude ID)?


Hi Seba,

Since you're trying to iterate over all users in the system there are some things to keep in mind:

1. You can create the User Sessions chart and use the Dashboard REST API to pull the results from that existing chart, but this will be bound to a limit of 365 days.
2. You can also create a cohort to isolate and gather these user IDs.

The first suggestion still remains the best approach for counting sessions from what I understand about your use case, but if you are trying to gather a list of those user's Amplitude IDs then it may be helpful to first create a cohort of users who had performed Any Active Event over the last 365 days which you would be able to download the CSV of that cohort. The CSV export should include all associated Amplitude IDs for the users that qualify.

So TLDR; it is recommended to come at this with a two pronged approach. 1 to address the overall session counts within a given timeframe. 2 would be helpful for getting a list of these user's IDs. You can see an example of #2 in the screenshot below:
![](https://amplitude.zendesk.com/attachments/token/rbWzyV0iHQvHvnvpfKVXZdC5b/?name=Screenshot+2025-01-07+at+9.55.26+AM.png)

Hope this helps! Please let me know if you have any questions.

Best,
Jarren


P.S. Checkout upcoming events and user meetups on our events page.

Reply