Skip to content

Instantly share code, notes, and snippets.

@drmarshall
Created December 23, 2014 02:48
Show Gist options
  • Save drmarshall/c2b1bb2eb405938b20ee to your computer and use it in GitHub Desktop.
Save drmarshall/c2b1bb2eb405938b20ee to your computer and use it in GitHub Desktop.
# extending the Mixpanel API class for large data to avoid maxing out ram and slowing request to point of failure
def request_highvolume(self, methods, params):
"""
methods - List of methods to be joined, e.g. ['events', 'properties', 'values']
will give us http://mixpanel.com/api/2.0/events/properties/values/
params - Extra parameters associated with method
"""
params['api_key'] = self.api_key
params['expire'] = int(time.time()) + 600 # Grant this request 10 minutes.
if 'sig' in params: del params['sig']
params['sig'] = self.hash_args(params)
request_url = '/'.join([self.ENDPOINT, str(self.VERSION)] + methods) + '/?' + self.unicode_urlencode(params)
request = urllib.urlretrieve(request_url, output_file)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment