Skip to content

Navigation Menu

Sign up
Raynes edited this page Jan 5, 2012 · 25 revisions

Introduction

RefHeap has a simple API. The API is token-based and also works without authentication (for now -- future API methods may require authentication). To get an API token, create an account on RefHeap and go to the API page. You can view/generate API tokens there.

All of the API methods return JSON. If there is an exception, the JSON object returned will have an error key.

Methods

/api/paste/create

  • username: Optional.
  • token: Optional. Token associated with username.
  • private: Optional. Either "true" or "false". Defaults to "false".
  • language: Optional. A string of which language to use for the paste. If this is not provided or the language is unrecognizable, the API defaults to "Plain Text". The language must be exactly the same as how it is listed in the dropdown on RefHeap. If the language is "Nginx Configuration" then that is exactly how it must appear when passed to the API.
  • contents: Required. A string of text that will be the body of the paste. This cannot be empty.

Create a new paste.

If a username and token is provided then the paste will be associated with that account. Otherwise, it will be anonymous.

Here is an example using Clojure and clj-http:

user=> (clj-http.client/post "http://localhost:8080/api/v1/paste/create"
 {:form-params {:contents "i like foo" :username "Raynes"
 :token "REDACTED"
 :private true
 :language "IRC Logs"}})
{:status 200,
 :cookies
 {"ring-session"
 {:path "/",
 :version 0,
 :discard true,
 :value "69f1008e-4c04-4366-880f-7a868a48f5f6"}},
 :headers
 {"server" "Jetty(6.1.25)",
 "content-type" "application/json; charset=ISO-8859-1",
 "date" "Thu, 05 Jan 2012 04:18:03 GMT",
 "connection" "close"},
 :body "{\"lines\":1,\"date\":\"2012-01-05T04:18:03.473Z\",\"paste-id\":\"4f05247bd6c4d4f67f6cd123\",\"language\":\"Plain Text\",\"private\":true,\"url\":\"http://refheap.com/paste/4f05247bd6c4d4f67f6cd123\",\"user\":\"raynes\",\"contents\":\"i like foo\"}"}

Clone this wiki locally

AltStyle によって変換されたページ (->オリジナル) /