Source

Pypaste / templates / developer.html

The default branch has multiple heads

{% extends "base.html" %}
{% block title %}Pypaste Services{% endblock %}

{% block content %}
<div class="txt">
    <h1>Pypaste Services</h1>
    <p>Pypaste has an open Application Programming Interface (API for short). This means that anyone can write their own program to post public paste  in new and different ways. The Friendpaste API is available for outside developers without any limits.</p>
    <h2>Json API</h2>
    <p>The primary API for programmatically accessing the Friendpaste is a <a href="http://en.wikipedia.org/wiki/Representational_State_Transfer">REST</a> API. All data sent to the server should be encoded in JSON.</p>
    <h3>Get a paste</h3>
    <p>To retrieve a paste, simply perform a <em>GET</em> operation on the paste url.</>
    <pre>
GET /some_paste_id HTTP/1.0
Date: Tue, 29 Apr 2008 05:39:28 +0000GMT
</pre>
    <p>Here is the server response.</p>
    <pre>
HTTP/1.1 201 OK
Date: Tue, 29 Apr 2008 05:39:28 +0000GMT
Content-Type: application/json
Connection: close

{
 'id': 'some_paste_id'
 'revid': 'some_revision_id',
 'title': 'title of paste',
 'snippet': 'paste content',
 'language': 'text',
 'revisions': ['revision_id_1', 'revision_id_2']
}
</pre>
    <h3>Create a paste</h3>
    <p>To create a paste, perform a POST operation at <a href="http://www.pypaste.com">http://www.pypaste.com/</a> .</p>
    <p>The following is an example HTTP <em>POST</em>. It will cause the Friendpaste server to generate a new paste ID and save the content with it.</p>
    <pre>
POST / HTTP/1.0
Content-Length: 245
Date: Tue, 29 Apr 2008 05:39:28 +0000GMT
Content-Type: application/json

{
  "title":"I like to paste stuff",
  "snippet":"My own paste",
  "language":"text"
}
    </pre>
    <p>Here is the server's response.</p>

    <pre>
HTTP/1.1 201 OK
Date: Tue, 29 Apr 2008 05:39:28 +0000GMT
Content-Type: application/json
Connection: close

{"ok": true, "id": "some_paste_id", "url": "http://pypaste.com/some_paste_id"}
    </pre>
    <p>If the paste is created the server return you a JSON  object in which you get the id of created paste and the direct url to the paste.</p>
    <p>If any error happend whil pasting, here is the server response.</p>

    <pre>
HTTP/1.1 201 OK
Date: Tue, 29 Apr 2008 05:39:28 +0000GMT
Content-Type: application/json
Connection: close

{"ok": "false", "reason": "error message"}
    </pre>
    <h3>Update a paste</h3>
<p>To update a paste, perform a PUT operation at <a href="http://www.pypaste.com/">http://www.pypaste.com/some_paste_id</a> .</p>
    <p>The following is an example HTTP <em>PUT</em>. It will cause the Friendpaste server to generate a new revision of the paste and update current content with it.</p>
    <pre>
PUT /some_paste_id HTTP/1.0
Content-Length: 245
Date: Tue, 29 Apr 2008 05:39:28 +0000GMT
Content-Type: application/json

{
  "title":"I like to paste stuff",
  "snippet":"My own paste updated",
  "language":"text"
}
    </pre>
    <p>Here is the server's response.</p>

    <pre>
HTTP/1.1 201 OK
Date: Tue, 29 Apr 2008 05:39:28 +0000GMT
Content-Type: application/json
Connection: close

{"ok": true, "url": "http://pypaste.com/some_paste_id"}
    </pre>
    <p>If the paste is created the server return you a JSON  object in which you get the id of created paste and the direct url to the paste.</p>
    <p>If any error happend whil pasting, here is the server response.</p>

    <pre>
HTTP/1.1 201 OK
Date: Tue, 29 Apr 2008 05:39:28 +0000GMT
Content-Type: application/json
Connection: close

{"ok": "false", "reason": "error message"}
    </pre>

</div>
{% endblock %}