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?
Solved
Extract data via API Sessions Endpoint
Best answer by jarren.patao
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:

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.
View originalSince 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:

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
Welcome to the Amplitude Community!
If you don't have an Amplitude account, you can create an Amplitude Starter account for free and enjoy direct access to the Community via SSO. Create an Amplitude account. You can also create a Guest account below!
If you're a current customer, select the domain you use to sign in with Amplitude.
analytics.amplitude.com analytics.eu.amplitude.comor
Welcome to the Amplitude Community!
If you don't have an Amplitude account, you can create an Amplitude Starter account for free and enjoy direct access to the Community via SSO. Create an Amplitude account. Want to sign up as a guest? Create a Community account.
If you're a current customer, select the domain you use to sign in with Amplitude.
analytics.amplitude.com analytics.eu.amplitude.comor
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.