Skip to content

iomonad/rojo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rojo Dependencies Status Clojars Project GitHub release

Reddit

Simple and idiomatic Reddit API wrapper.


Usage

Rojo is available from Clojars.org. To use it, add the following as a dependency in your favorite build tool.

Leiningen/Boot

[rojo "0.x.x"]

Clojure CLI/deps.edn

rojo {:mvn/version "0.x.x"}

Gradle

compile 'rojo:rojo:0.x.x'

Maven

<dependency>
  <groupId>rojo</groupId>
  <artifactId>rojo</artifactId>
  <version>0.x.x</version>
</dependency>

Basic

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 
 )           

Result data structure

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

Searching

(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.

Subreddit

(ns foobar
  (:require [rojo.methods.subreddit :as s]))
  
(s/list-posts token :sub "programming" :limit 5)

Streaming

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)

License

Copyright © iomonad.

Distributed under the Eclipse Public License, the same as Clojure.

About

Minimal toolkit to interact with Reddit's API, with simplicity in mind.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published