0.0
A long-lived project that still receives updates
A simple reddit api wrapper
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Runtime

~> 2.13.4
 Project Readme

SimplyReddit

A simple Ruby wrapper for the Reddit API.

Installation

Add this line to your application's Gemfile:

gem 'simply_reddit'

And then execute:

bundle install

Or install it yourself as:

gem install simply_reddit

Usage

Authentication

require 'simply_reddit'

client = SimplyReddit::Client.new(
  client_id: 'your_client_id',
  secret: 'your_client_secret',
  username: 'your_username',
  password: 'your_password'
)

Getting Current User Information

# Get information about the authenticated user
response = client.me
puts response.body # User data as JSON
puts response.status # HTTP status code

Working with Subreddits

# Access a specific subreddit
subreddit = client.subreddit('ruby')

# The subreddit object provides access to subreddit-specific functionality
# (specific methods depend on your Subreddit class implementation)

Working with Users

# Access a specific user's profile
user = client.user('spez')

# The user object provides access to user-specific functionality  
# (specific methods depend on your User class implementation)

Response Format

All API responses are wrapped in a Response object with the following structure:

response.status  # HTTP status code (200, 404, etc.)
response.headers # HTTP headers as a hash
response.body    # Parsed JSON response body

Error Handling

response = client.me

case response.status
when 200
  puts "Success: #{response.body}"
when 401
  puts "Authentication failed"
when 403
  puts "Forbidden - check your credentials"
else
  puts "Error: #{response.status}"
end