Skip to content

Instantly share code, notes, and snippets.

@pspeter3
Created December 13, 2013 00:51
Show Gist options
  • Save pspeter3/7938322 to your computer and use it in GitHub Desktop.
Save pspeter3/7938322 to your computer and use it in GitHub Desktop.
Print out the tasks you mark today from asana
#!/usr/bin/python
import base64
import json
import os
import urllib
import urllib2
AUTHORIZATION = base64.encodestring(
"%s:" %(os.environ["ASANA_API_KEY"])).replace("\n", "")
def request(url):
req = urllib2.Request(url)
req.add_header("Authorization", "Basic %s" %(AUTHORIZATION))
res = urllib2.urlopen(req).read()
return json.loads(res).get("data")
user = request("https://app.asana.com/api/1.0/users/me")
data = {}
for workspace in user["workspaces"]:
query = urllib.urlencode({
"assignee": user["id"],
"workspace": workspace["id"],
"opt_fields": "name,assignee_status,completed"
})
tasks = request("https://app.asana.com/api/1.0/tasks?" + query)
print "%s:" %(workspace["name"])
for task in tasks:
if not task["completed"] and task["assignee_status"] == "today":
print " %s" %(task["name"])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment