Hello! I’m wondering if anyone can advice me on how to use the mixpanel api to get all events coorelating with a single event id. I have figured out how to get all distinct ids in a date range, butI’m having a hard time querying all events associated with an id.
I’m wondering also, if that might provide me with any data that is not included already in the explore user tab.
Best answer by scotthavard92
Hi @rwr!
I want to share an easier and more efficient way of exporting the event data of a user than going the JQL route. You should use Mixpanel's export API (https://developer.mixpanel.com/docs/exporting-raw-data#section-export-api-reference).
You can export all events connected to a user by passing their distinct_id as part of the “where” parameter. The following snippit is an example curl request that achieves this.
You need to update your API secret, date range, and distinct id of user.
curl https://data.mixpanel.com/api/2.0/export/ \
-u <API_SECRET_HERE>: \
-d from_date="2019-05-01" \
-d to_date="2020-02-04" \
-d where='properties["$distinct_id"]=="<DISTINCT_ID_OF_USER>"'
Stephanie isn’t incorrect when she says “export API was built it was largely built with the scope to generate large dumps of raw event data and unfortunately not query”. Depending on what you mean by query the data (i.e. if you want to run queries in the actual HTTP request), then I would suggest you use the Query API: https://developer.mixpanel.com/docs/data-export-api (not the Raw Export API).
Hope this helps!