Services / Json API

The primary API for programmatically accessing the Friendpaste is a REST API. All data sent to the server should be encoded in JSON.

Get a paste

To retrieve a paste, simply perform a GET operation on the paste url.

GET /some_paste_id HTTP/1.0
Date: Tue, 29 Apr 2008 05:39:28 +0000GMT
Accept: application/json

Here is the server response.

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

Create a paste

To create a paste, perform a POST operation at https://www.friendpaste.com/ .

The following is an example HTTP POST. It will cause the Friendpaste server to generate a new paste ID and save the content with it.

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

Here is the server's response.

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": "https://friendpaste.com/some_paste_id"}
    

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.

If any error happend whil pasting, here is the server response.

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

Update a paste

To update a paste, perform a PUT operation at https://www.friendpaste.com/some_paste_id .

The following is an example HTTP PUT. It will cause the Friendpaste server to generate a new revision of the paste and update current content with it.

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

Here is the server's response.

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": "https://friendpaste.com/some_paste_id"}
    

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.

If any error happend whil pasting, here is the server response.

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

Get revisions

To retrieve all revisions of a paste, simply perform a GET operation on https://friendpaste.com/some_paste_id/revisions.

GET /some_paste_id/revisions HTTP/1.0
Date: Tue, 29 Apr 2008 05:39:28 +0000GMT
Accept: application/json

Here is the server response.

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"], "offset": 0}, "type": "mod", "changed": {"lines": ["test2"], "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": ""}]

Get a changeset

To retrieve a changeset, simply perform a GET operation on https://friendpaste.com/some_paste_id/changeset?rev=some_rev_id. Changeset are in unidiff format

GET /some_paste_id/changeset?rev=some_rev_id HTTP/1.0
Date: Tue, 29 Apr 2008 05:39:28 +0000GMT
Accept: application/json

Here is the server response.

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

Get all languages

To retrieve list of all languages supported by Friendpaste, simply perform a GET operation on https://friendpaste.com/_all_languages url.

GET /_all_languages HTTP/1.0
Date: Tue, 29 Apr 2008 05:39:28 +0000GMT

Here is the server response.

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"]]