Skip to main content

At our team, we're looking to automate some reports, and one of the many pieces we need to achieve this is to find the size of a cohort (by its ID) at the time of analysis.

Having said that, we've been exploring the Behavioral Cohorts API for any leads, and so far the best matching endpoints are the following:

1: GET /api/3/cohorts
2: GET /api/3/cohorts/:id

1. returns all the discoverable cohorts' metadata, whereas 2. returns the requested cohort's metadata and members. The latter would be the best match, but given that all members are returned, it takes upwards of 10s to get a result out of this endpoint.

For some context, this is roughly the response of endpoint 1.:

{
"cohorts": s { COHORT_OBJECT }, ...]
}

Whereas the response of endpoint 2. is:
{
"cohort: { COHORT_OBJECT },
"amplitude_ids": s id1, id2, ...]
}

Are there any variants (either endpoints or query params), that would return something like:

{
"cohort: { COHORT_OBJECT }
}

that is, without the list of amplitude ids?

Hello @alejo.lemon!

Thanks for your post and happy to help!
 

At this time there is no endpoint within the Behavioral Cohort API that would allow you to pull only the cohort size alone. The best endpoint to use for pulling the current cohort size is the Get all cohorts endpoint (GET /api/3/cohorts).
 
You are also able to view the cohort population and export members of the cohort in the cohorts tab. Here is an example from the Amplitude Demo: https://analytics.amplitude.com/demo/cohort/jzpa0ft
?name=image.png
 

If this will not suffice, I have followed up with you directly to grab more details for submitting a feature request on your behalf. Kindly respond to my email and we can proceed with the feature request.

 

Hope this helps! Let us know if you have questions.


Reply