Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Del.icio.us API with python (See related posts)

Taken from del.icio.us-py usage here.
>>> import delicious
>>> # add a post, user and passwd must be valid values for del.icio.us
>>> delicious.add('user', 'passwd', 'url', 'description', 'tag1 tag2', 
                  'extended', '2004-12-31T13:59:59Z')
True
>>> posts = delicious.get('user', 'passwd', count = 1)
>>> # posts is a list containing the post objects, these are dicts
>>> print posts
[{'url': u'url', 'dt': u''2004-12-31T13:59:59Z'', 'extended': u'extended', 
  'description': u'description', 'tags': 'tag1 tag2'}]
>>> posts[0]["tags"]
'tag1 tag2'
>>> delicious.delete('user', 'passwd', 'url')
True
>>>

>>> d = delicious.DeliciousAPI("user", "passwd")
>>> # DeliciousAPI offers all features of the API, see the docs for more
>>> posts = d.posts_all()                 # get all posts by user
>>> posts = d.posts_recent(tag = "tag1", count = 12)
>>> len(posts), type(posts)
(12,  <type 'dict'>)
>>> 

>>> d = delicious.DeliciousNOTAPI()
>>> # DeliciousNOTAPI offers access to features of delicious, that are not 
      accessible via its api
>>> posts = d.get_posts_by_user("username)
>>> posts = d.get_posts_by_tag("tag")
>>>

Comments on this post

peter posts on Dec 11, 2005 at 15:12
Seems like I've found another bug. We need to allow full stops in tag names!
peter posts on Dec 11, 2005 at 15:16
I've fixed it and also corrected the tags for you. :)
korakot posts on Dec 12, 2005 at 13:52
Thank you, Peter.

You need to create an account or log in to post comments to this site.


Click here to browse all 5147 code snippets

Related Posts