Solved

How to get raw data using Dashboard Rest API

  • 9 September 2021
  • 4 replies
  • 790 views

Badge

Hi I am trying to get the raw data for an event using the dashboard rest api that Amplitude offers. I am completely new to Amplitude and REST APIs. I have an event that want to group it by two properties and get the raw data for lets say 3 days. The expected output in a csv format should look like below:

" keywords; [Amplitude] User ID"," 2021-06-09"," 2021-06-10"," 2021-06-11",

" vaccine; AhL67nr8JDA","0","0","1",

" important themes; C1VzZXJQcm9ma","0","1","0",

" broadband; agxzfnViZX","1","0","0",

" oklahoma; Y2VyGSC1VzZX","1","1","0"

,where keywords and User ID are the two properties that I group by the data on. I see such a data in the breakdown table in Amplitude UI but don’t know how I can extract this data using the REST API.

Any help is appreciated. 

icon

Best answer by Saish Redkar 9 September 2021, 19:20

View original

4 replies

Userlevel 7
Badge +10

Hey @MahsaAzizi ,

If this is a one off thing and you just want the csv output of that chart, then you can just export the csv for that chart to get that format ( which I believe is how you got the csv format here ).

The Dashboard REST API doesn’t give a formatted csv/tabular output as such, but depending on what call you are making to the /api/2/events/segmentation end point, the raw data points returned would be nested as json lists/objects in the series, seriesLabels , seriesCollapsed and xValues keys. You will have to parse and extract these values to create a formatted output of your choice accordingly.

 

The group by clause for your use case would look something like this - 

"group_by": [ { "type": "user","value":"gp:keywords" }, { "type": "user","value":"user_id" }]

Hope this helps!

Badge

Hey @Saish Redkar ,

Thank you so much for your response.

Right, I can not simply have a CSV formatted output using the API and have to convert the JSON to CSV. No problem with that. 

The group_bu clause you wrote is what I needed, a question though, can I only have the two types of ‘event’ and ‘user’ properties in the group_by clause? I have another set of properties other than Event Properties and User Properties that is called Amplitude User Properties and need to use that as one of my properties in group_by. So, need something like this:

"group_by": [ { "type": "user","value":"gp:keywords" }, { "type": "amplitude user","value":"user_id" }]
Userlevel 7
Badge +10

Hey @MahsaAzizi ,

It would look like this if you are using the default Amplitude User properties - 

"group_by": [ { "type": "user","value":"gp:keywords" }, { "type": "user","value":"user_id" }]

For non-Amplitude, custom user properties, prepend the user property name with "gp:". "gp:" is not needed for event properties. For using an event property, you can use "type": "event" if you are using it in the group by . 

 

Let me know if that worked!

Badge

I see, thank you so much for your help, @Saish Redkar!

Reply