Reddit JSON API offers an easy way to retrieve data from subreddits in no time.

2.3.1 2021-01-20 08:31 UTC

This package is auto-updated.

Last update: 2021-10-18 03:06:15 UTC


CI codecov StyleCI Latest Stable Version Total Downloads Monthly Downloads License

Reddit JSON API is a PHP wrapper for handling JSON information from public subreddits.

🤝 Supporting

If you are using one or more Renoki Co. open-source packages in your production apps, in presentation demos, hobby projects, school projects or so, spread some kind words about our work or sponsor our work via Patreon. 📦

You will sometimes get exclusive content on tips about Laravel, AWS or Kubernetes on Patreon and some early-access to projects or packages.


🚀 Installation

You can install the package via composer:

composer require rennokki/reddit-json-api

🙌 Usage

use Rennokki\RedditApi\Reddit;

$app = Reddit::app(

$subreddit = Reddit::subreddit(
    'funny', // subreddit name

$posts = $subreddit->get();

foreach ($posts as $post) {
    $id = $post['id'];

When retrieving posts, the results are wrapped in a Rennokki\RedditApi\RedditList class. This class is based on Laravel Collection and you can pipeline actions on it more easily. Please see Laravel Collections documentantion.


For pagination purposes, you shall call nextPage() from the previous $posts:

$subreddit = Reddit::subreddit('funny', $app);

$posts = $subreddit->get();

$nextPageOfPosts = $posts->nextPage();


Reddit allows sorting by posts type. The currently used ones are:

public static $sorts = [
    'hot', 'new', 'controversial', 'top', 'rising',

To apply the sorting, you should call sort():

$subreddit = Reddit::subreddit('funny', $app);


Time Filtering

Same as sorting, time filters are only a few:

public static $times = [
    'hour', 'day', 'week', 'month', 'year', 'all',
$subreddit = Reddit::subreddit('funny', $app);

// Top, all time sorting.


By default, each call gives you 20 posts.

$subreddit = Reddit::subreddit('funny', $app);



If you wish to inspect the URL that is being called, you ca do so:

$subreddit = Reddit::subreddit('funny', $app);


$url = $subreddit->getCallableUrl();

🐛 Testing


🤝 Contributing

Please see CONTRIBUTING for details.

🔒 Security

If you discover any security related issues, please email instead of using the issue tracker.

🎉 Credits