mixpanel

Downloading Mixpanel events with Raw Export API and filter on distinct_id


I have some events in Mixpanel which I can successfully download using the Raw Export API. In this example, I am filtering on the "city" field. This works.

    import requests
    
    url = "https://data.mixpanel.com/api/2.0/export?project_id=<project id>&from_date=2023-11-16&to_date=2023-11-16&limit=10&where=properties%5B%22%24city%22%5D%20%3D%3D%20%22San%20Antonio%22"

    
    headers = {
        "accept": "text/plain",
        "authorization": "Basic <token>"
    }
    
    response = requests.get(url, headers=headers)
    
    print(response.text)

However, when I try to filter on the distinct_id property, searching for a value which I know has matching events, I get 0 events returned (status code 200).

    import requests
    
    url = "https://data.mixpanel.com/api/2.0/export?project_id=<project id>&from_date=2023-11-16&to_date=2023-11-16&limit=10&where=properties%5B%22distinct_id%22%5D%20%3D%3D%20%22fa1bd247-b252-498a-bace-6b31f876f09%22"

    
    headers = {
        "accept": "text/plain",
        "authorization": "Basic <token>"
    }
    
    response = requests.get(url, headers=headers)
    
    print(response.text)

Does anyone know why, of all fields, distinct_id cannot be used for filtering? Am I missing something?

Thanks.

Note: I am able to filter on other uuid-string properties as well, so the format or length does not appear to be the issue.


Solution

  • Upon feedback from the Mixpanel support team, distinct_id is a special field and therefore requires a '$' in front of it for querying, even though there isn't one in the name of the actual field.