cooncesean / mixpanel-query-py

The Python interface to fetch data from Mixpanel.
MIT License
29 stars 17 forks source link

Old documentation #24

Closed noodlebreak closed 8 years ago

noodlebreak commented 8 years ago

Hi, I just tried out your package today. I was going to do this:

query_client.get_events_unique

But turned out, there is no get_events_unique in your client module. I can only find these:

In [14]: qc.get_events
qc.get_events      qc.get_events_top 
cooncesean commented 8 years ago

Try using qc.get_events(data_type=qc.DATA_TYPE_UNQIUE).

Here is the "unique" data type

Here is the get_events method signature.

Let me know if this works for ya :)

noodlebreak commented 8 years ago

Yeah I actually figured it out once I took a look the client module that day.

Anyways, can you help me with a query I can't figure out how to achieve using your API?

What I want to do is, basically, get the total counts of $referrers between a time range.

Currently, doing this:

api.get_segmentation('visit', '2016-04-30', '2016-05-01',
limit=5, on='properties["$referrer"]', where='"noodlebreak" == properties["username"]')

Gives me this:

{u'data': {u'series': [u'2016-04-30', u'2016-05-01'],
           u'values': {u'http://m.facebook.com': {u'2016-04-30': 96,
                                                  u'2016-05-01': 144},
                       u'http://m.facebook.com/': {u'2016-04-30': 112,
                                                   u'2016-05-01': 191},
                       u'https://www.google.co.in/': {u'2016-04-30': 178,
                                                      u'2016-05-01': 159},
                       u'undefined': {u'2016-04-30': 315,
                                      u'2016-05-01': 342}}},

But I want the total counts of all the days, instead of getting the values for each top referrer by date, within the specified start and end time. Something like this:

{u'data': 
    {u'series': [u'2016-04-30', u'2016-05-01'],
     u'values': {
                    u'http://m.facebook.com': 240 ,
                    u'http://m.facebook.com/': 303,
                    u'https://www.google.co.in/': 337,
                    u'undefined': 657
                }
    }
}

I have looked over each method of the API, and I can't think of any that can do this.

cooncesean commented 8 years ago

@thesmallestduck do you know if Mixpanel's API supports this type of query?

thesmallestduck commented 8 years ago

Hi @noodlebreak . This library utilizes the published API endpoints you can find here: https://mixpanel.com/docs/api-documentation/data-export-api (and some un published ones as well). The sum roll-up you are requesting seems like more of a post-processing step to me? Is there a reason you can't map a sum operation across the date values in the segments your request to achieve the totals you're looking for?

noodlebreak commented 8 years ago

@thesmallestduck I am actually doing that in Python yes, but I just wanted to know if it was doable on Mixpanel itself. The closes thing I found was /events/properties/values endpoint, but it didn't have filtering with the where clause like the segmentation API.