{ "info": { "author": "Sean Coonce, Francis Genet, Patrick McNally, Harry Marr, @robin900", "author_email": "cooncesean@gmail.com", "bugtrack_url": null, "classifiers": [ "Environment :: Web Environment", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python" ], "description": "# mixpanel-query-py\n\nThe 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.\n\n\n# Installation\n\nTo install mixpanel-query-py, simply:\n\n```\n$ pip install mixpanel-query-py\n```\n\nor alternatively (you really should be using pip though):\n\n```\n$ easy_install mixpanel-query-py\n```\n\nor from source:\n\n```\n$ git clone git@github.com:cooncesean/mixpanel-query-py.git\n$ cd mixpanel-query-py\n$ python setup.py install\n```\n\n# Usage\n\nYou 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\".\n\n```python\nfrom mixpanel_query.client import MixpanelQueryClient\nfrom your_project.conf import MIXPANEL_API_KEY, MIXPANEL_API_SECRET\n\n# Instantiate the client\nquery_client = MixpanelQueryClient(MIXPANEL_API_KEY, MIXPANEL_API_SECRET)\n\n# Query your project's data\ndata = query_client.get_events_unique(['Some Event Name'], 'hour', 24)\nprint data\n{\n 'data': {\n 'series': ['2010-05-29', '2010-05-30', '2010-05-31'],\n 'values': {\n 'account-page': {'2010-05-30': 1},\n 'splash features': {\n '2010-05-29': 6,\n '2010-05-30': 4,\n '2010-05-31': 5, # Date + unique event counts\n }\n }\n },\n 'legend_size': 2\n}\n```\n\n### Authentication\nBy 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:\n\n```python\nfrom mixpanel_query.client import MixpanelQueryClient\nfrom mixpanel_query.auth import SecretAuth, SignatureAuth\nfrom your_project.conf import MIXPANEL_API_KEY, MIXPANEL_API_SECRET\n\n# Instantiate a secret-based auth client\nsecret_auth_client = MixpanelQueryClient(MIXPANEL_API_KEY, MIXPANEL_API_SECRET, auth_class=SecretAuth)\n\n# Instantiate a signature-based auth client explicitly\nsig_auth_client = MixpanelQueryClient(MIXPANEL_API_KEY, MIXPANEL_API_SECRET, auth_class=SignatureAuth)\n```\n\nView the [api reference](#api-reference) for details on accessing different endpoints.\n\n# API Reference\n\nMixpanels' full [API reference is documented here](https://mixpanel.com/docs/api-documentation/data-export-api).\n\n\n# Python Support\n\nThis library now supports both by Python >2.7.6 as well as