Skip to main content

Documentation Status License GitHub stars PyPI version Monthly Downloads Codacy Badge Python Versions

RedditEasy

RedditEasy is a rapidly-fast API wrapper for getting posts using the Reddit JSON API with both sync and async options

Install

To install RedditEasy, do:

pip install redditeasy

OR

python -m pip install redditeasy

OR (not recommended)

pip install git+https://github.com/MakufonSkifto/RedditEasy.git

Documentation

Docs can be found here

Async RedditEasy

Yes, there is an async version of RedditEasy. To use it, you need to use the Async classes. Which are AsyncSubreddit and AsyncUser

Here is a small example on using AsyncSubreddit: https://github.com/MakufonSkifto/RedditEasy/blob/main/examples/async_meme.py

You can and should use this in a discord.py bot. The normal classes could cause a blocking in an async program.

This will not work outside an async function whatsoever.

Usage

Without Reddit API client info

This method is not suggested as it may be slow and throw errors more often

import redditeasy
import datetime

# To get your Reddit API client info go to
# https://www.reddit.com/prefs/apps
# and create an app

# For more detailed explanation, see this image: https://i.imgur.com/Ri13AQu.png


post = redditeasy.Subreddit()

postoutput = post.get_post(subreddit="dankmemes") # Subreddit name

# Formatted version of created_at
formatted_time = datetime.datetime.fromtimestamp(postoutput.created_at).strftime("%d/%m/%Y %I:%M:%S UTC")

print(f"Posts Title: {postoutput.title}\n"
      f"Posts Content: {postoutput.content}\n"
      f"Posts Author: u/{postoutput.author}\n"
      f"Posts URL: {postoutput.post_url}\n"
      f"Spoiler?: {postoutput.spoiler}\n"
      f"Post Created At: {formatted_time}\n"
      f"Posts Upvote Count: {postoutput.score}\n"
      f"Posts Award Count: {postoutput.total_awards}\n"
      f"NSFW?: {postoutput.nsfw}\n"
      f"Post Flair: {postoutput.post_flair}\n"
      f"User Flair: {postoutput.author_flair}\n"
      f"Subreddit Subscribers: {postoutput.subreddit_subscribers}\n"
      f"Comment count: {postoutput.comment_count}\n"
      f"Is Media?: {postoutput.is_media}\n"
      f"Subreddit Name: r/{postoutput.subreddit_name}\n"
      f"Content Type: {postoutput.content_type}")

With Reddit API client info

import redditeasy
import datetime

# To get your Reddit API client info go to
# https://www.reddit.com/prefs/apps
# and create an app

# For more detailed explanation, see this image: https://i.imgur.com/Ri13AQu.png


post = redditeasy.Subreddit(client_id="",            # Your client ID
                            client_secret="",        # Your client secret
                            user_agent=""            # Your user agent (ex: ClientName/0.1 by YourUsername")
                            )

postoutput = post.get_post(subreddit="dankmemes")    # Subreddit name

# Formatted version of created_at
formatted_time = datetime.datetime.fromtimestamp(postoutput.created_at).strftime("%d/%m/%Y %I:%M:%S UTC")

print(f"Posts Title: {postoutput.title}\n"
      f"Posts Content: {postoutput.content}\n"
      f"Posts Author: u/{postoutput.author}\n"
      f"Posts URL: {postoutput.post_url}\n"
      f"Spoiler?: {postoutput.spoiler}\n"
      f"Post Created At: {formatted_time}\n"
      f"Posts Upvote Count: {postoutput.score}\n"
      f"Posts Award Count: {postoutput.total_awards}\n"
      f"NSFW?: {postoutput.nsfw}\n"
      f"Post Flair: {postoutput.post_flair}\n"
      f"User Flair: {postoutput.author_flair}\n"
      f"Subreddit Subscribers: {postoutput.subreddit_subscribers}\n"
      f"Comment count: {postoutput.comment_count}\n"
      f"Is Media?: {postoutput.is_media}\n"
      f"Subreddit Name: r/{postoutput.subreddit_name}\n"
      f"Content Type: {postoutput.content_type}")

More examples are in the examples folder

Getting Reddit API client info

To get your Reddit API client info go to https://www.reddit.com/prefs/apps and create a script.

(You don't have to fill "redirect_uri")

Changelog

Changelog can be found here

Operating Systems

All of RedditEasy's versions were tested in Windows, Linux (Ubuntu) and MacOS

Errors

The module will raise redditeasy.exceptions.RequestError if there was an error with the request. Traceback will show the details about the error

The module will raise redditeasy.exceptions.EmptyResult if the given user / subreddit is empty

Issues

If you have any issues with RedditEasy, please report them via the issue tracker

Release files for redditeasy 4.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for redditeasy 4.0.0
File Size Uploaded
redditeasy-4.0.0.tar.gz 20.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for redditeasy 4.0.0
File Interpreter ABI Platform
redditeasy-4.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 43.6 kB

Release files / redditeasy-4.0.0.tar.gz

Download URL redditeasy-4.0.0.tar.gz
Size 20.2 kB
Tags Source
SHA-256 checksum
How to use checksums
2b36531109cf681a0f8507ed9ed26c730bb8495f340a34adab0ea4754bd62678
BLAKE2b-256 checksum
How to use checksums
1678366aba54f6abf71981050c2a206254373b3f38b87ea7e88773c6874c8057
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.26.0 requests-toolbelt/0.9.1 urllib3/1.26.6 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/1.5.0 colorama/0.4.4 CPython/3.10.0

Release files / redditeasy-4.0.0-py3-none-any.whl

Download URL redditeasy-4.0.0-py3-none-any.whl
Size 23.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0b1a9650f5d6ba77c0ba2b44158a7d89f48565d04555f3e23d1f1b946ca50352
BLAKE2b-256 checksum
How to use checksums
a3e51588eccd48375fd19343f7afa7cf00764136e1cdddb945fd5a00066d7129
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.26.0 requests-toolbelt/0.9.1 urllib3/1.26.6 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/1.5.0 colorama/0.4.4 CPython/3.10.0

Release history Release notifications | RSS feed

This release

4.0.0 This release

2 release files

3.6.3

2 release files

3.6.2

2 release files

3.6.1

2 release files

3.6.0

2 release files

3.5.0

2 release files

3.4.0

2 release files

3.3.1

2 release files

3.3.0

2 release files

3.2.1

2 release files

3.2.0

2 release files

3.1.0

2 release files

3.0.0

2 release files

2.9.1

2 release files

2.9.0

2 release files

2.8.0

2 release files

2.7.5

2 release files

2.7.3

2 release files

2.7.2

2 release files

2.7.1

2 release files

2.7.0

2 release files

2.6.0

2 release files

2.5.0

2 release files

2.2.0

2 release files

2.1.0

2 release files

2.0.0

2 release files

1.9.0

2 release files

1.8.0

2 release files

1.7.0

2 release files

1.5.0

2 release files

1.0.0

2 release files

0.1.6

2 release files

0.1.5

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page