Skip to main content
Solved

Extract data via API Sessions Endpoint


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?

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:
![](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.
View original
Did this topic help you find an answer to your question?

6 replies

Saish Redkar
Expert
Forum|alt.badge.img+10

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
 

 


jarren.patao
Community Manager
  • Technical Support
  • 70 replies
  • January 3, 2025
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.

  • Author
  • New Member
  • 2 replies
  • January 6, 2025
jarren.patao wrote:

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?


  • Author
  • New Member
  • 2 replies
  • January 6, 2025
Saish Redkar wrote:

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)?


jarren.patao
Community Manager
  • Technical Support
  • 70 replies
  • Answer
  • January 7, 2025
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.

Forum|alt.badge.img+1
  • Experienced
  • 13 replies
  • March 18, 2025

If you're using the Sessions endpoint to extract data via API, keep in mind that it returns aggregated session data rather than raw event logs. If you need specific event details within sessions, you might have to pull data from the Export API instead. Also, make sure you're passing the right parameters like start and end dates to get the data range you need.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings