reddit: Library for interfacing with Reddit's API

[ bsd2, library, network ] [ Propose Tags ]
This version is deprecated.

A library for interfacing with Reddit's API in Haskell. Handles logins, rate-limiting and converting to and from JSON responses. Supports most user-facing Reddit API functions, as well as some moderator endpoints. Check out the readme at https://github.com/intolerable/reddit. Contributions are welcome.


[Skip to Readme]

Modules

[Last Documentation]

  • Reddit
    • Reddit.Actions
      • Reddit.Actions.Captcha
      • Reddit.Actions.Comment
      • Reddit.Actions.Flair
      • Reddit.Actions.Message
      • Reddit.Actions.Moderation
      • Reddit.Actions.Post
      • Reddit.Actions.Search
      • Reddit.Actions.Subreddit
      • Reddit.Actions.Thing
      • Reddit.Actions.User
      • Reddit.Actions.Voting
      • Reddit.Actions.Wiki
    • Reddit.Login
    • Reddit.Types
      • Reddit.Types.Captcha
      • Reddit.Types.Comment
      • Reddit.Types.Error
      • Reddit.Types.Flair
      • Reddit.Types.Listing
      • Reddit.Types.Message
      • Reddit.Types.Moderation
      • Reddit.Types.Options
      • Reddit.Types.Post
      • Reddit.Types.Reddit
      • Reddit.Types.SearchOptions
      • Reddit.Types.Subreddit
      • Reddit.Types.SubredditSettings
      • Reddit.Types.Thing
      • Reddit.Types.User
      • Reddit.Types.Wiki

Downloads

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.1.1.0, 0.2.0.0, 0.2.1.0, 0.2.2.0, 0.2.2.1, 0.2.2.2, 0.2.3.0, 0.3.0.0 (info)
Dependencies aeson (>=0.9 && <1.2.2), api-builder (>=0.10 && <0.15), base (>=4.6 && <4.12), bytestring (>=0.10 && <0.11), data-default-class (>=0.0.1 && <0.2), free (>=4 && <5), http-client (>=0.4.30 && <0.6), http-client-tls (>=0.2 && <0.4), http-types (>=0.8 && <0.11), network (>=2.6 && <2.7), text (>=1 && <2), time (>=1.5 && <1.9), transformers (>=0.4 && <0.6), unordered-containers (>=0.2.5 && <0.3), vector (>=0.10 && <0.13) [details]
License BSD-2-Clause
Copyright Copyright (c) Fraser Murray, 2013-2018
Author Fraser Murray
Maintainer fraser.m.murray@gmail.com
Revised Revision 1 made by HerbertValerioRiedel at 2019-02-10T10:35:34Z
Category Network
Home page https://github.com/intolerable/reddit
Source repo head: git clone https://github.com/intolerable/reddit
Uploaded by Intolerable at 2018-01-09T21:51:24Z
Distributions
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 4689 total (23 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs not available [build log]
All reported builds failed as of 2018-01-09 [all 3 reports]

Readme for reddit-0.2.2.0

[back to package description]

reddit for haskell Build Status

A Haskell library for interacting with the Reddit API.

### A couple of examples

Let's get all the posts from the frontpage of Reddit and write a summary of each of them to the console:

{-# LANGUAGE OverloadedStrings #-}
import Reddit
import Reddit.Types.Post

import Control.Monad
import Control.Monad.IO.Class
import Data.Monoid
import qualified Data.Text as Text
import qualified Data.Text.IO as Text

main = runRedditAnon $ do
  Listing _ _ posts <- getPosts
  forM_ posts $ \post -> do
    liftIO $ Text.putStrLn $
       "[" <> tshow (score post) <> "] " <>
       title post <> " (" <> tshow (subreddit post) <> ")"

tshow = Text.pack . show

Let's check to see which of a group of users has the highest link karma:

{-# LANGUAGE OverloadedStrings #-}
import Reddit
import Reddit.Types.User

import Data.List
import Data.Ord

usersToCheck = ["nikita-volkov", "simonmar", "bos", "roche"]

main = runRedditAnon $ do
  infos <- mapM (getUserInfo . Username) usersToCheck
  return $ maximumBy (comparing linkKarma) infos

Testing

Pure tests

cabal test test

This suite will only run test that don't require doing any IO. Helpful because it runs quickly and isn't subject to any network problems.

Anonymous tests

cabal test test-anon

There's also a suite of tests that can be run anonymously without having to set up a user account and an empty subreddit.

Full IO tests

cabal test test-io

The test test suite will run the tests that don't rely on doing any IO, but the test-io should be used too to ensure that IO functions do what they're supposed to do. If you want to run the IO suite, add a file test.cfg to the reddit/ directory, containing (one field per line):

  • a reddit username
  • a reddit password
  • a subreddit name (the user should be a moderator for the subredit)