Using Jaiku API with Python

I’ve slowly fallen in love with Jaiku. It’s a microblogging platform much like Twitter, but with fun features like ability to add feeds from other services (like Flickr,, or any arbitrary source) to your stream and a nifty client for Series 60 phones. Jaiku also has an open API for easy hacking. I was amazed how easy it was to use.

My goal was to get my current presence data and location from Jaiku. After 30 minutes of coding (of which I watched the Simpsons about 20 minutes) I had the following 25 lines of code in my

 from django.utils import simplejson  from urllib import urlopen from time import strptime from datetime import datetime, timedelta  JAIKU_USERNAME = 'uninen'  def get_jaiku_presence():     """Returns user Jaiku presence as dict or False if errors."""      url = '' % JAIKU_USERNAME      try:         result = simplejson.load(urlopen(url))          # pythonize needed fields         time = strptime(result['created_at'], "%Y-%m-%dT%H:%M:%S GMT")         result['created_at'] = datetime(*time[:5]) + timedelta(hours=3)         result['comments'] = len(result['comments']) or False          return result      except IOError:         return False

It’s very simple and dead easy to use:

In [1]: from unessanet.misc.jaiku import get_jaiku_presence  In [2]: get_jaiku_presence() Out[2]:  {u'comments': False,  u'content': u'Savitehtaankatu, Turku, Finland',  u'created_at': datetime.datetime(2007, 8, 17, 0, 20),  u'created_at_relative': u'3 hours, 8 minutes ago',  u'icon': u'',  u'id': u'9552365',  u'location': u'Savitehtaankatu, Turku, Finland',  u'title': u'Enjoying the rain',  u'url': u'',  u'user': {u'avatar': u'',            u'first_name': u'Ville',            u'last_name': u'S\xe4\xe4vuori',            u'nick': u'Uninen',            u'url': u''}}

Feel free to modify this to your needs.

Next up is a system for storing these presences to a local database and drawing a location trail to Google Maps or something similar…

PS. My Jaiku stream is at 🙂

It Could Be Worse

After a long-awaited summer vacation (including an unforgettable visit to Norway) I’m back to sitting indoors during these amazingly beautiful summer days.

This monday felt truly a monday until I saw this blogpost revealing the code for Facebook home page. Man, that gives one perspective. It’s been only about eighteen months since I dropped PHP for Python. The switch has been almost as fulfilling as the switch to my first Mac back in the day. Seeing that ugly and messy PHP code just made me smile; at least I don’t have to put up with anything like that anymore!

This is not to bash PHP or PCs (although they both suck) but to remind me that it’s really great to be able to work on interesting projects with Python and Django. It could be much worse. I just forget it much too often.