DZone 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

Snippets has posted 5883 posts at DZone. View Full User Profile

Del.icio.us API With Python

12.11.2005
| 3234 views |
  • submit to reddit
        Taken from del.icio.us-py usage <a href=http://delicious-py.berlios.de/usage.html>here</a>.
>>> 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

Snippets Manager replied on Mon, 2012/05/07 - 2:17pm

Thank you, Peter.

Snippets Manager replied on Mon, 2012/05/07 - 2:17pm

I've fixed it and also corrected the tags for you. :)

Snippets Manager replied on Mon, 2012/05/07 - 2:17pm

Seems like I've found another bug. We need to allow full stops in tag names!