Source

Pypaste / templates / services / json.html

The default branch has multiple heads

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

{% block content %}
<div class="txt">

    <h1><a href="/services">Services</a> / Json API</h1>
    <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>
    <h2>Get a paste</h2>
    <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'
 'nb_revision': 'some_revision_number',
 'title': 'title of paste',
 'snippet': 'paste content',
 'language': 'text'
}
</pre>
    <h2>Create a paste</h2>
    <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", "nb_revision": "paste_revision_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>
    <h2>Update a paste</h2>
<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, "id": "some_paste_id", "nb_revision": "new_revision_number", "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>
    <h2>Get revisions</h2>
    <p>To retrieve all revisions of a paste, simply perform a <em>GET</em> operation on <a href="http://pypaste.com/some_paste_id/revisions">http://pypaste.com/some_paste_id/revisions</a>.</>
    <pre>
GET /some_paste_id/revisions HTTP/1.0
Date: Tue, 29 Apr 2008 05:39:28 +0000GMT
</pre>
    <p>Here is the server response.</p>
    <pre class="wrap">
HTTP/1.1 200 OK
Date: Tue, 29 Apr 2008 05:39:28 +0000GMT
Content-Type: application/json
Connection: close

[{"next": "", "updated": "2008-11-16T17:45:01Z", "nb_revision": 1, "itemType": "paste", "parent": "", "title": "", "fork_parent": "", "_rev": "147337384", "forked_atrevision": "", "pasteid": "GmLNJBa6", "revid": "343837396237", "created": "2008-11-16T17:45:01Z", "content": "test2", "language": "text", "forked": false, "_id": "26980d60971ed9c1eaf6216a2e9e93e1", "changes": [{"base": {"lines": ["test<del></del>"], "offset": 0}, "type": "mod", "changed": {"lines": ["test<ins>2</ins>"], "offset": 0}}], "previous": "80e3f46a1ebd5032a06d6d1a3cf75998"}, {"updated": "2008-11-16T17:44:56Z", "nb_revision": 0, "itemType": "revision", "parent": "GmLNJBa6", "title": "", "fork_parent": "", "_rev": "2290957423", "forked_atrevision": "", "pasteid": "GmLNJBa6", "revid": "636462366666", "next": "", "content": "test", "language": "text", "created": "2008-11-16T17:44:56Z", "forked": false, "_id": "80e3f46a1ebd5032a06d6d1a3cf75998", "changes": [], "previous": ""}]
</pre>

    <h2>Get a changeset</h2>
    <p>To retrieve a changeset, simply perform a <em>GET</em> operation on <a href="http://pypaste.com/some_paste_id/changeset?rev=some_rev_id">http://pypaste.com/some_paste_id/changeset?rev=some_rev_id</a>.  Changeset are in unidiff format</>
    <pre>
GET /some_paste_id/changeset?rev=some_rev_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 200 OK
Date: Tue, 29 Apr 2008 05:39:28 +0000GMT
Content-Type: application/json
Connection: close

{
 'id': 'some_paste_id'
 'rev': 'some_revision_id',
 'changeset': 'changeset in unidiff format'
}
</pre>
    <h2>Get all languages</h2>
    <p>To retrieve list of all languages supported by Friendpaste, simply perform a <em>GET</em> operation on <a href="http://pypaste.com/_all_languages">http://pypaste.com/_all_languages</a> url.</>
    <pre>
GET /_all_languages HTTP/1.0
Date: Tue, 29 Apr 2008 05:39:28 +0000GMT
</pre>
    <p>Here is the server response.</p>
    <pre class="wrap">
HTTP/1.1 200 OK
Date: Tue, 29 Apr 2008 05:39:28 +0000GMT
Content-Type: application/json
Connection: close

[["apacheconf", "ApacheConf"], ["as", "ActionScript"], ["as3", "ActionScript 3"], ["basemake", "Makefile"],
 ["bash", "Bash"], ["bat", "Batchfile"], ["bbcode", "BBCode"], ["befunge", "Befunge"], ["boo", "Boo"], 
["brainfuck", "Brainfuck"], ["c", "C"], ["c-objdump", "c-objdump"], ["cheetah", "Cheetah"], ["clojure", 
"Clojure"], ["common-lisp", "Common Lisp"], ["control", "Debian Control file"], ["cpp", "C++"], 
["cpp-objdump", "cpp-objdump"], ["csharp", "C#"], ["css", "CSS"], ["css+django", "CSS+Django/Jinja"], 
["css+erb", "CSS+Ruby"], ["css+genshitext", "CSS+Genshi Text"], ["css+mako", "CSS+Mako"], ["css+myghty",
 "CSS+Myghty"], ["css+php", "CSS+PHP"], ["css+smarty", "CSS+Smarty"], ["d", "D"], ["d-objdump", 
"d-objdump"], ["delphi", "Delphi"], ["diff", "Diff"], ["django", "Django/Jinja"], ["dpatch", "Darcs Patch"],
 ["dylan", "Dylan"], ["erb", "ERB"], ["erlang", "Erlang"], ["fortran", "Fortran"], ["gas", "GAS"], ["genshi",
 "Genshi"], ["genshitext", "Genshi Text"], ["gnuplot", "Gnuplot"], ["groff", "Groff"], ["haskell", "Haskell"],
 ["html", "HTML"], ["html+cheetah", "HTML+Cheetah"], ["html+django", "HTML+Django/Jinja"], ["html+genshi",
 "HTML+Genshi"], ["html+mako", "HTML+Mako"], ["html+myghty", "HTML+Myghty"], ["html+php", "HTML+PHP"],
 ["html+smarty", "HTML+Smarty"], ["ini", "INI"], ["io", "Io"], ["irc", "IRC logs"], ["java", "Java"]]
</pre>

</div>
{% endblock %}