Skip to content

Instantly share code, notes, and snippets.

@thinkingserious
Created November 18, 2015 04:00
Show Gist options
  • Save thinkingserious/1165d480ec073e067927 to your computer and use it in GitHub Desktop.
Save thinkingserious/1165d480ec073e067927 to your computer and use it in GitHub Desktop.
Python Global Stats GET
import sendgrid
import os
if os.path.exists('.env'):
for line in open('.env'):
var = line.strip().split('=')
if len(var) == 2:
os.environ[var[0]] = var[1]
client = sendgrid.SendGridAPIClient(os.environ.get('SENDGRID_API_KEY'))
start_date = '2015-10-01'
end_date = None
aggregated_by = 'week' # must be day, week or month
status, msg = client.stats.get(
start_date=start_date,
end_date=end_date,
aggregated_by=aggregated_by)
print status
print msg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment