Solved

Pulling cohort data out of mixpanel in real time

  • 21 May 2020
  • 1 reply
  • 351 views

We are looking to make an API call to poll a cohorts feature (Meeting certain property and event conditions) and retrieve a list of user IDs in real time. Our aim is to use those user IDs for our internal messaging service. 

 

Is this use case possible? 

 

Amplitude (who we are with currently), do not offer real time updates, only hourly sync and 500 calls per day :(

icon

Best answer by donna 10 July 2020, 21:12

Hi :smile:

If you’re looking to pull a list of user IDs (profiles) from a cohort you could try using our Formatted API’s (aka Query API) /engage endpoint.

 

Here are the dev docs for the /engage endpoint: Dev Docs for Query API

 

Below are steps you could follow to export the profiles from the cohort:

1. Build a Cohort in the UI (Users > Explore or Users > Cohorts) within your Project
2. Save the Cohort
3. Go to Users > Cohorts > Click on the Cohort you have just built
4. Grab the Cohort ID from the URL.
The Cohort ID is after the /cohorts#builder path in the URL:

.../cohorts#builder/im_the_cohort_id/name_of_cohort

5. Use the Cohort ID in the request to our /engage endpoint like below (in this example the Cohort ID is 752368):

curl https://mixpanel.com/api/2.0/engage/ \
-u 'YOUR_PROJECTS_API_SECRET': \
-d filter_by_cohort='{"id": 752368}' \
-d include_all_users=True 
# include_all_users=True will return the distinct_ids with and without profile properties - if you only want to grab distinct_ids with profile properties set this to False)

 

Please do note - there are rate limits with the Formatted API which you can find here: API Rate Limits

Hope that helps!

View original

1 reply

Hi :smile:

If you’re looking to pull a list of user IDs (profiles) from a cohort you could try using our Formatted API’s (aka Query API) /engage endpoint.

 

Here are the dev docs for the /engage endpoint: Dev Docs for Query API

 

Below are steps you could follow to export the profiles from the cohort:

1. Build a Cohort in the UI (Users > Explore or Users > Cohorts) within your Project
2. Save the Cohort
3. Go to Users > Cohorts > Click on the Cohort you have just built
4. Grab the Cohort ID from the URL.
The Cohort ID is after the /cohorts#builder path in the URL:

.../cohorts#builder/im_the_cohort_id/name_of_cohort

5. Use the Cohort ID in the request to our /engage endpoint like below (in this example the Cohort ID is 752368):

curl https://mixpanel.com/api/2.0/engage/ \
-u 'YOUR_PROJECTS_API_SECRET': \
-d filter_by_cohort='{"id": 752368}' \
-d include_all_users=True 
# include_all_users=True will return the distinct_ids with and without profile properties - if you only want to grab distinct_ids with profile properties set this to False)

 

Please do note - there are rate limits with the Formatted API which you can find here: API Rate Limits

Hope that helps!

Reply


Mixpanel