Google Tasks API case study

This post is an update of

Update 2011-05-12 the official API is now at thanks to Josh for the ping.

There is no official API for Google Tasks at this time. But, below is full read-only access to all your tasks across all your lists. I am including a simple app that sends this to you via email (This mail WILL go to your spam folder). I have this running at home to automatically print out a copy of all task lists periodically.

cd /tmp
rm -f message; touch message

curl \
-d \
-d source=privacylog \
-d service=goanna_mobile > token

AUTH=$(sed -n '/Au/s/A/a/p' token)
HEADER="Authorization: GoogleLogin $AUTH"
curl --header "$HEADER" "$URL" > main

for list in $(grep -o '"[0-9:]\{20,25\}:0"' main | tr -d '"' | sort -u)
curl --header "$HEADER" "$URL?listid=$list" > list
echo >> message
title=$(sed -n 's|.*selected="selected">\([^<]\+\).*|\1|gp' list | head -n1)
echo "### $title ###" >> message
sed -n 's|\([^<]\{1,\}\).*|[ ]  \1|p' list >> message
# This one below indents sub tasks but only works on Linux
# sed -n -e 's/.* .*//p' -e 's|\([^<]\+\).*|\1|p' list | sed -n -e '/./!{N;s/\n/  /}' -e '/./p' | sed 's/^/[ ]  /' >> message

mail -s "Weekly review" < message

rm token main list message
Notes for Mac: use * instead of \+,