Simple and idiomatic Reddit API wrapper.
Rojo is available from Clojars.org. To use it, add the following as a dependency in your favorite build tool.
[rojo "0.x.x"]
rojo {:mvn/version "0.x.x"}
compile 'rojo:rojo:0.x.x'
<dependency>
<groupId>rojo</groupId>
<artifactId>rojo</artifactId>
<version>0.x.x</version>
</dependency>
In a first time, you should generate your credentials. Once created, you are be able to instanciate your first client:
(def creds {:user-client "44tt[..]"
:user-secret "MckC06DXMynW-[..]"})
(let [token (client/request-token
creds)]
; Use you token with methods
)
Posts result list is transduced for convenient hash manipulation:
[
{ :content { :banned_by , ... }, :post "t3_ap9ran" }
{ :content { :banned_by , ... }, :post "t3_apf8je" }
{ :content { :banned_by , ... }, :post "t3_ap4day" }
{ :content { :banned_by , ... }, :post "t3_apfbl8" }
...
]
(ns foobar
(:require [rojo.methods.search :as s]))
(s/search token :query "lisp" :limit 50)
;; [{:content {...}, :post "t3_ap4dap} ...]
Note that all key paramaters are mandatory, using fallback values, like 25 for limit.
(ns foobar
(:require [rojo.methods.subreddit :as s]))
(s/list-posts token :sub "programming" :limit 5)
Streaming methods are callback based, new events are pushed to inlet for the sake of concurency.
(defn stream-callback [coll] ; Post datastructure
(println (str "GOT PAYLOAD: " coll)))
(stream/stream-posts token
:interval 1 :callback stream-callback)
Copyright © iomonad.
Distributed under the Eclipse Public License, the same as Clojure.