PHPackages                             raicem/reddit-public-api-wrapper - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. raicem/reddit-public-api-wrapper

ActiveLibrary

raicem/reddit-public-api-wrapper
================================

A simple wrapper for Reddit's public API

1.0.0(7y ago)220MITPHPPHP 7.\*

Since Aug 20Pushed 7y agoCompare

[ Source](https://github.com/raicem/reddit-public-api-wrapper)[ Packagist](https://packagist.org/packages/raicem/reddit-public-api-wrapper)[ RSS](/packages/raicem-reddit-public-api-wrapper/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (1)Versions (2)Used By (0)

Reddit Public API PHP Wrapper
=============================

[](#reddit-public-api-php-wrapper)

Reddit provides a very convenient access to its data just by adding `.json` to the end of normal URLs. For example, `https://www.reddit.com/r/formula1.json` will present you the json response.

This is a very simple wrapper around this feature of Reedit. Thies to grant easy access to subreddit and user data.

### 1. Installation

[](#1-installation)

Install it as a dependency using [Composer](https://getcomposer.org/)

```
composer require raicem/reddit-public-api-wrapper
```

### 2. Instantiate

[](#2-instantiate)

```
use RedditWrapper\Wrapper;
use RedditWrapper\WrapperClient;

$wrapper = new Wrapper(new WrapperClient());
```

### 3. Queries

[](#3-queries)

#### 3.1. Subreddit Query

[](#31-subreddit-query)

Fetches information about a certain subreddit.

```
use RedditWrapper\Queries\SubredditQuery;
use RedditWrapper\Enums\SubredditSort;
use RedditWrapper\Enums\SubredditSortTime;

$query = new SubredditQuery([
    'subreddit' => 'formula1',
]);

$response = $wrapper->fetch($query);
```

You may add sort options to your query for best, top, rising, controversial posts in a subreddit. You may use the constants provided with the `RedditWrapper\Enums\SubredditSort` and `RedditWrapper\Enums\SubredditSortTime`.

```
use RedditWrapper\Queries\SubredditQuery;
use RedditWrapper\Enums\SubredditSort;
use RedditWrapper\Enums\SubredditSortTime;

$query = new SubredditQuery([
    'subreddit' => 'formula1',
    'sort' => SubredditSort::TOP,
    'sortTime' => SubredditSortTime::WEEK,
]);

$response = $wrapper->fetch($query);
```

#### 3.2. User Query

[](#32-user-query)

Fetches the feed belonging to a user.

```
use RedditWrapper\Queries\UserQuery;

$query = new UserQuery([
    'username' => 'unidan',
]);

$response = $wrapper->fetch($query);
```

All of these queries extends the `QueryInterface` in the package. So you can create your own query implementing `QueryInterface` in your code base and then provide it to the `Wrapper`.

### 4. Magic Stuff

[](#4-magic-stuff)

#### 4.1. \_\_call method on the Wrapper

[](#41-__call-method-on-the-wrapper)

I believe the main function of this library will be to fetch subreddit information. I wanted to streamline that functionality as much as possible.

So without creating a new query, you may call the subreddit's name as a method on this wrapper.

```
use RedditWrapper\Wrapper;
use RedditWrapper\WrapperClient;

$wrapper = new Wrapper(new WrapperClient());

$response = $wrapper->formula1();
```

#### 4.2. `fetchSimple` method on Wrapper

[](#42-fetchsimple-method-on-wrapper)

When fetching subreddit information, Reddit sends a lot of information that is probaby not neccessery. The default response can very difficult to get through. `fetchSimple` method removes all the clutter and tries to present response with only more general values.

```
$query = new SubredditQuery([
    'subreddit' => 'formula1',
    'sort' => SubredditSort::TOP,
    'sortTime' => SubredditSortTime::WEEK,
]);

$response = $wrapper->fetchSimple($query);
```

`fetchSimple` method returns these values. This method only works for `SubredditQuery` instances.

Valuetitleidthumbnailpermalinknum\_commentsscorecreated

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2823d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d8034cfc9140d8140dd734c596c058662d0aa22fd55149e7a4c0f6f8496d4760?d=identicon)[raicem](/maintainers/raicem)

---

Top Contributors

[![raicem](https://avatars.githubusercontent.com/u/10389957?v=4)](https://github.com/raicem "raicem (13 commits)")

---

Tags

api-wrapperphpreddit

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/raicem-reddit-public-api-wrapper/health.svg)

```
[![Health](https://phpackages.com/badges/raicem-reddit-public-api-wrapper/health.svg)](https://phpackages.com/packages/raicem-reddit-public-api-wrapper)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
