Help

Using the LodegeIt API

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

API URLs:

  • XMLRPC: http://rn0.ru/xmlrpc/
  • JSON: http://rn0.ru/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://rn0.ru/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)

  • pastes.getLanguages()

  • pastes.getLast()

  • pastes.getPaste(paste_id)

  • pastes.getRecent(amount=5)

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

  • styles.getStyles()

  • styles.getStylesheet(name)