Skip to main content

The Python interface to query data from Mixpanel.

Project description

# mixpanel-query-py

The Python interface to fetch data from Mixpanel via [Mixpanel's Data Query API](https://mixpanel.com/docs/api-documentation/data-export-api). Note, this differs from the official [Python binding](https://github.com/mixpanel/mixpanel-python) which only provides an interface to send data to Mixpanel.


# Installation

To install mixpanel-query-py, simply:

```
$ pip install mixpanel-query-py
```

or alternatively (you really should be using pip though):

```
$ easy_install mixpanel-query-py
```

or from source:

```
$ git clone git@github.com:cooncesean/mixpanel-query-py.git
$ cd mixpanel-query-py
$ python setup.py install
```

# Usage

You will need a [Mixpanel account](https://mixpanel.com/register/) and your `API_KEY` + `API_SECRET` to access your project's data via their API; which can be found in "Account" > "Projects".

```python
from mixpanel_query.client import MixpanelQueryClient
from your_project.conf import MIXPANEL_API_KEY, MIXPANEL_API_SECRET

# Instantiate the client
query_client = MixpanelQueryClient(MIXPANEL_API_KEY, MIXPANEL_API_SECRET)

# Query your project's data
data = query_client.get_events_unique(['Some Event Name'], 'hour', 24)
print data
{
'data': {
'series': ['2010-05-29', '2010-05-30', '2010-05-31'],
'values': {
'account-page': {'2010-05-30': 1},
'splash features': {
'2010-05-29': 6,
'2010-05-30': 4,
'2010-05-31': 5, # Date + unique event counts
}
}
},
'legend_size': 2
}
```

### Authentication
By default the `MixpanelQueryClient` will use signature-based authentication when issuing requests to Mixpanel. If you would like to use the secret-based authentication method, you can do so like this:

```python
from mixpanel_query.client import MixpanelQueryClient
from mixpanel_query.auth import SecretAuth, SignatureAuth
from your_project.conf import MIXPANEL_API_KEY, MIXPANEL_API_SECRET

# Instantiate a secret-based auth client
secret_auth_client = MixpanelQueryClient(MIXPANEL_API_KEY, MIXPANEL_API_SECRET, auth_class=SecretAuth)

# Instantiate a signature-based auth client explicitly
sig_auth_client = MixpanelQueryClient(MIXPANEL_API_KEY, MIXPANEL_API_SECRET, auth_class=SignatureAuth)
```

View the [api reference](#api-reference) for details on accessing different endpoints.

# API Reference

Mixpanels' full [API reference is documented here](https://mixpanel.com/docs/api-documentation/data-export-api).


# Python Support

This library now supports both by Python >2.7.6 as well as <Python 3.4.3 with [recent additions](https://github.com/cooncesean/mixpanel-query-py/pull/15) added by @robin900.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mixpanel-query-py-0.1.9.tar.gz (11.5 kB view details)

Uploaded Source

Built Distribution

mixpanel_query_py-0.1.9-py2-none-any.whl (13.4 kB view details)

Uploaded Python 2

File details

Details for the file mixpanel-query-py-0.1.9.tar.gz.

File metadata

File hashes

Hashes for mixpanel-query-py-0.1.9.tar.gz
Algorithm Hash digest
SHA256 b365844ba342b75f716d022ef8978eeb781eb318cbde177ea9964ff3179d7a91
MD5 77fedb39321d443a8548e1a968c33b07
BLAKE2b-256 99c5583a17f0775973d12a1f52ed15c2787cb74cb2b9ce0cba42f124fac77e4b

See more details on using hashes here.

File details

Details for the file mixpanel_query_py-0.1.9-py2-none-any.whl.

File metadata

File hashes

Hashes for mixpanel_query_py-0.1.9-py2-none-any.whl
Algorithm Hash digest
SHA256 93d41e0fd133c393d93b934e35cc82ec654b01664dd4ca4da824ae36ea5a2839
MD5 52287b63156418b19d0f22fdb544a9db
BLAKE2b-256 183262a61701b5d7b920b6227dccbf54ec5ef5a241975f5f098cc72546e1e2fd

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page