Using the LodegeIt API

LodgeIt supports currently two APIs: XMLRPC and good old JSON.

API URLs:

  • XMLRPC: http://paste.plurk.com/xmlrpc/
  • JSON: http://paste.plurk.com/json/

Note the trailing slash in both URLs!

XMLRPC Quickstart

You can connect to the XMLRPC interface with any XMLRPC library. If you're using Python the following piece of code connects you to the XMLRPC service:

>>> from xmlrpclib import ServerProxy
>>> s = ServerProxy('http://paste.plurk.com/xmlrpc/')

For example if you want to fetch one paste from the server you can do this:

>>> paste = s.pastes.getPaste(23)
>>> print paste['code']
'{% if users %}\n...'

JSON Quickstart

Alternatively you can use the JSON API. Basically what you do is sending the function arguments as a serialized JSON object or array to the JSON URL from above with the method name as URL parameter. You can do this for example by using the curl command line tool:

$ curl -d '{"paste_id": 23}' -H 'Content-Type: application/json'
  'http://localhost:5000/json/?method=pastes.getPaste'
{
"data": {
"code": '{% if users %}\n...',
"parsed_code": ...,
"language": 'html+django',
"url": "/show/23/",
"parent_id": null,
"paste_id": 23
},
"error": null
}

Methods

For a list of all supported methods see the list below.

  • pastes.getDiff(old_id, new_id)

    Compare the two pastes and return an unified diff.

  • pastes.getLanguages()

    Get a list of supported languages.

  • pastes.getLast()

    Get information dict (see `getPaste`) for the most recent paste.

  • pastes.getPaste(paste_id)

    Get all known information about a paste by a given paste id. Return a dictionary with these keys: `paste_id`, `code`, `parsed_code`, `pub_date`, `language`, `parent_id`, `url`.

  • pastes.getPasteTitle(paste_id)

  • pastes.getRecent(amount=5)

    Return information dict (see `getPaste`) about the last `amount` pastes.

  • pastes.newPaste(language, code, parent_id=None, filename='', mimetype='', private=False, user_id=None)

    Create a new paste. Return the new ID. `language` can be None, in which case the language will be guessed from `filename` and/or `mimetype`.

  • styles.getStyles()

    Get a list of supported styles.

  • styles.getStylesheet(name)

    Return the stylesheet for a given style.