Same Con to Hoyci — too many choices —

A blog about Web development, usability and AI.

Using Jaiku API with Python

 by Ville Säävuori

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


def get_jaiku_presence():
    """Returns user Jaiku presence as dict or False if errors."""

    url = '' % JAIKU_USERNAME
    	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()
{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 :)

Follow @uninen on Twitter