Mixpanel Community Icon

How to Retrieve All User Aliases with API and JQL Queries

·
·

Hey all, Has anyone tried to get a list of all the aliases for a user? My backend engineer has tried running both API and JQL queries, and, at best, I can only get two of the unique IDs. I have some users who may have 5 or 6.

  • Avatar of Vlad S.
    Vlad S.
    ·
    ·

    you can get them in the UI by clicking under their name and expanding the distinct id field

  • Avatar of Vlad S.
    Vlad S.
    ·
    ·

    I don't know how to do it programatically though

  • Avatar of Seth T.
    Seth T.
    ·
    ·

    yeah, that's the problem I'm running into. We need to pull it programmatically, and the output only ever produces a maximum of two, regardless of how many are in the array

  • Avatar of Seth T.
    Seth T.
    ·
    ·

    if anyone has any insight on how to make it work for a api or jql call, we'd certainly appreciate the insight! We've got a ticket in with support, so, if we find out from elsewhere, I'll pop the answer in here, too

  • Avatar of Vlad S.
    Vlad S.
    ·
    ·

    are you on legacy ID merge or original?

  • Avatar of Seth T.
    Seth T.
    ·
    ·

    double-checking with my lead. Just a moment!

  • Avatar of Seth T.
    Seth T.
    ·
    ·

    original is my understanding

  • Avatar of Vlad S.
    Vlad S.
    ·
    ·

    i don't think aliases do anything or much for original id merge

  • Avatar of Vlad S.
    Vlad S.
    ·
    ·

    they're mostly for legacy id merge

  • Avatar of Seth T.
    Seth T.
    ·
    ·

    all right, here's what support gave us: We have an undocumented endpoint with our Query API /engage that can retrieve the distinct_ids in a cluster (programmatically). However, with this Alias endpoint, it does not have a way to query multiple distinct_ids/aliases at once (it can only query one alias/distinct_id at a time). Additionally, this endpoint is subject to the rate limits with our Query API (Formatted API) which can be found here: https://developer.mixpanel.com/reference/rate-limits so it may not work for your use case since you’re looking for a couple thousand users. Note - here is an example request:

    curl --request POST \
      --url 'https://mixpanel.com/api/2.0/engage/aliases?project_id=YOURPROJECTID' \
      --header 'Accept: application/json' \
      --header 'Authorization: Basic BASE_64_ENCODED_API_SECRET' \
      --header 'Content-Type: application/x-www-form-urlencoded' \
      --data distinct_id=TheUUIDFromInternalDB

    With the above in mind, I took a look at your account and I see it has the Data Pipelines package. With the package, it has a People Pipeline which exports an “Identity Mapping Table” to see and query identity clusters from a Mixpanel Project: https://docs.mixpanel.com/docs/data-pipelines/schematized-export-pipeline#user-identity-resolution My recommendation is to create a Schematized People Pipeline export to one of your data warehouses, and you can then use the identity mapping table going forward to find the clusters.

  • Avatar of Vlad S.
    Vlad S.
    ·
    ·

    ah that makes a lot of sense, the api endpoint is likely what they use on the frontend to display those ids in the user profile, which is why it only works one at a time and has strict limits on it

  • Avatar of Vlad S.
    Vlad S.
    ·
    ·

    I suppose you could also write a script that calls the users one by one and does exponential backoff when the limit is reached, and then you just run it for however long it takes

  • Avatar of Seth T.
    Seth T.
    ·
    ·

    Bummer, yeah. It's definitely going to be a long road to finishing it

  • Avatar of Vlad S.
    Vlad S.
    ·
    ·

    the data warehouse approach seems super quick, if you have a warehouse set up already, otherwise the script might be faster (to write, but maybe even to run)

  • Avatar of Vlad S.
    Vlad S.
    ·
    ·

    60 queries per hour comes to 100 hours for 6000 users, so like 5 days? it's not crazy, especially if you start it on a Friday and let it run through the weekend

  • Avatar of Seth T.
    Seth T.
    ·
    ·

    iirc, it's a little over 4200, so it's even a little better than that. I'll see what my guy says. Appreciate your insight!