Clojure wrapper for Reddit API
Declare creddit in your project.clj:
Use creddit in your clojure code:
(require '[creddit.core :as creddit])
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))
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)
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)
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)
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)
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)
Retrieve specific posts*
names: Sequence of fully specified fullnames.
(creddit/listing creddit-client names)
Run tests
$ lein test
Want to become a Creddit contributor?
Then checkout our code of conduct and contributing guidelines.
Copyright (c) 2017 Conor Hughes - Released under the MIT license.