{% extends "help/layout.html" %} {% block help_body %}

{% trans %}Using the LodegeIt API{% endtrans %}

{% trans %} LodgeIt supports currently two APIs: XMLRPC and good old JSON. {% endtrans %}

{{ _('API URLs:') }}

{{ _('Note the trailing slash in both URLs!') }}

{% trans %}XMLRPC Quickstart{% endtrans %}

{% trans %} 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:{% endtrans %}

{% filter escape %}
>>> from xmlrpclib import ServerProxy
>>> s = ServerProxy('{{ pastebin_url|escape }}xmlrpc/')
{% endfilter %}

{% trans %}For example if you want to fetch one paste from the server you can do this:{% endtrans %}

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

{% trans %}JSON Quickstart{% endtrans %}

{% trans %} 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: {% endtrans %}

$ 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
}

{% trans %}Methods{% endtrans %}

{% trans %}For a list of all supported methods see the list below.{% endtrans %}

{% endblock %}