Skip to content

sli/creddit

 
 

Repository files navigation

Creddit

Clojure wrapper for Reddit API

Build Status Clojars Project

Installation

Declare creddit in your project.clj:

Clojars Project

Use creddit in your clojure code:

(require '[creddit.core :as creddit])

Usage

You will need your Reddit application credentials found here https://www.reddit.com/prefs/apps/

I would recommend using a library such as cprop or environ to load them in

Your credentials should like this:

{:user-client <USER_CLIENT>,
 :user-secret <USER_SECRET>}

Once you have your credentials loaded in you can initialise the client:

(def creddit-client (creddit/init credentials))

Functions

Frontpage

Retrieve posts from frontpage

limit: Maximum number of posts to retrieve (Minimum: 1, Maximum: 100)
time: Time span of query (One of :hour, :day, :week, :month, :year, :all)

(creddit/frontpage creddit-client limit time)

(creddit/controversial creddit-client limit time)

(creddit/new creddit-client limit time)

(creddit/rising creddit-client limit time)

(creddit/top creddit-client limit time)

Subreddit

Retrieve posts from subreddit

subreddit: Name of subreddit (Eg: "programming", "funny", "pics" etc...)
limit: Maximum number of posts to retrieve (Minimum: 1, Maximum: 100)
time: Time span of query (One of :hour, :day, :week, :month, :year, :all)

(creddit/subreddit creddit-client subreddit limit time)

(creddit/subreddit-controversial creddit-client subreddit limit time)

(creddit/subreddit-new creddit-client subreddit limit time)

(creddit/subreddit-rising creddit-client subreddit limit time)

(creddit/subreddit-top creddit-client subreddit limit time)

Retrieve recent comments from subreddit

subreddit: Name of subreddit (Eg: "programming", "funny", "pics" etc...)
limit: Maximum number of comments to retrieve (Minimum: 1, Maximum: 100)

(creddit/subreddit-comments creddit-client subreddit limit)

Search subreddit's posts

subreddit: Name of subreddit (Eg: "programming", "funny", "pics" etc...)
query: Search term (Eg: "clojure tutorials", "dank memes" etc...)
limit: Maximum number of posts to retrieve (Minimum: 1, Maximum: 100)

(creddit/subreddit-search creddit-client subreddit query limit)

Retrieve about from subreddit

subreddit: Name of subreddit (Eg: "programming", "funny", "pics" etc...)

(creddit/subreddit-about creddit-client subreddit)

Subreddits

Retrieve list of subreddits

limit: Maximum number of subreddits to retrieve (Minimum: 1, Maximum: 100)

(creddit/subreddits creddit-client limit)

(creddit/subreddits-new creddit-client limit)

(creddit/subreddits-popular creddit-client limit)

(creddit/subreddits-gold creddit-client limit)

(creddit/subreddits-default creddit-client limit)

Search for subreddit

subreddit: Subreddit search term (Eg: "programming", "clojure", "nodejs" etc...)
limit: Maximum number of subreddits to retrieve (Minimum: 1, Maximum: 100)

(creddit/subreddits-search creddit-client subreddit limit)

User

Retrieve user profile

username: Name of user (Eg: "thisisbillgates", "awildsketchappeared", "way_fairer" etc...)

(creddit/user creddit-client username)

(creddit/user-trophies creddit-client username)

Retrieve user posts

username: Name of user (Eg: "thisisbillgates", "awildsketchappeared", "way_fairer" etc...)
limit: Maximum number of posts to retrieve (Minimum: 1, Maximum: 100)
time: Time span of query (One of :hour, :day, :week, :month, :year, :all)

(creddit/user-posts creddit-client username limit time)

Retrieve user comments

username: Name of user (Eg: "thisisbillgates", "awildsketchappeared", "way_fairer" etc...)
limit: Maximum number of posts to retrieve (Minimum: 1, Maximum: 100)
time: Time span of query (One of :hour, :day, :week, :month, :year, :all)

(creddit/user-comments creddit-client username limit time)

Users

Retrieve users

limit: Maximum number of users to retrieve (Minimum: 1, Maximum: 100)

(creddit/users creddit-client limit)

(creddit/users-new creddit-client limit)

(creddit/users-popular creddit-client limit)

Listings

Retrieve specific posts*

names: Sequence of fully specified fullnames.

(creddit/listing creddit-client names)

Development

Testing

Run tests

$ lein test

Contributing

Want to become a Creddit contributor?
Then checkout our code of conduct and contributing guidelines.

Copyright & License

Copyright (c) 2017 Conor Hughes - Released under the MIT license.

About

Clojure wrapper for Reddit API

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Clojure 100.0%