PHPackages                             snlbaral/reddit-php - 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. [API Development](/categories/api)
4. /
5. snlbaral/reddit-php

ActiveLibrary[API Development](/categories/api)

snlbaral/reddit-php
===================

Reddit API for PHP.

0.2(4y ago)08BSD-3-ClausePHP

Since Jun 5Pushed 4y ago1 watchersCompare

[ Source](https://github.com/snlbaral/reddit-php)[ Packagist](https://packagist.org/packages/snlbaral/reddit-php)[ Docs](https://github.com/snlbaral/reddit-php)[ RSS](/packages/snlbaral-reddit-php/feed)WikiDiscussions main Synced 6d ago

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

reddit-php
==========

[](#reddit-php)

[![Latest Stable Version](https://camo.githubusercontent.com/da7b526f4f46a3d1a0e9f3a6e0e422f87fd179909e4c9288be617bc6e560ae79/68747470733a2f2f706f7365722e707567782e6f72672f736e6c626172616c2f7265646469742d7068702f76)](//packagist.org/packages/snlbaral/reddit-php) [![Total Downloads](https://camo.githubusercontent.com/29b60d5ef962878db2e9b9f26c3effba5b52581e89223839b0077d27b8b4f8cb/68747470733a2f2f706f7365722e707567782e6f72672f736e6c626172616c2f7265646469742d7068702f646f776e6c6f616473)](//packagist.org/packages/snlbaral/reddit-php) [![Latest Unstable Version](https://camo.githubusercontent.com/75a9fc0c294e69cacd7ed3b3f5e1a34cf5d37c5cb9687ba589c61586c74ebfc8/68747470733a2f2f706f7365722e707567782e6f72672f736e6c626172616c2f7265646469742d7068702f762f756e737461626c65)](//packagist.org/packages/snlbaral/reddit-php) [![License](https://camo.githubusercontent.com/95d728be162150ea5c42d15bc856324083acbbac10e9f169552a60d10ea3adb8/68747470733a2f2f706f7365722e707567782e6f72672f736e6c626172616c2f7265646469742d7068702f6c6963656e7365)](//packagist.org/packages/snlbaral/reddit-php)

This is an open source library that allows PHP applications to interact programmatically with the Reddit's API without the requirement of oauth.

Requirements
------------

[](#requirements)

Using this library for PHP requires the following:

- \[Composer\] or a manual install of the dependencies mentioned in `composer.json`.

Installation
------------

[](#installation)

The recommended way to install it PHP is to install it using

```
composer require snlbaral/reddit-php
```

Usages
------

[](#usages)

**Init**

```
require 'vendor/autoload.php';
use Snlbaral\Reddit\Reddit;

$reddit = new Reddit();
```

**Fetch Posts Of Subreddit**

```
// getPosts() @params $subreddit_name, $token (optional), $dist (optional), $sort (optional)
$posts = $reddit->getPosts('subreddit_name');
// returns array of posts, next page token, dist, sorting method, subreddit name
// print_r($posts);

// To Get next page/thread posts use following:
$next_page = $reddit->getPosts('subreddit_name', $posts['token']);
// returns array of next page/thread posts, next page token, dist, sorting method, subreddit name
```

**Fetch Subreddit Info**

```
$subreddit_info = $reddit->getInfo('subreddit_name');
```

**View/Get Single Post Info/Detail Page**

```
$postId = 'postId or token';
$post = $reddit->viewPost($postId);
```

**Fetch User Overview Page**

```
// userOverview() @params $username, $token (optional), $dist (optional), $sort (optional)
$overview = $reddit->userOverview('username');
// returns array of user's posts, comments, next page token, dist, sorting method, username

// To Get next page/thread posts and comments of user, use following
$next_page_overview = $reddit->userOverview('username', $overview['token']);
```

**Fetch User Posts Page**

```
// userPosts() @params $username, $token (optional), $dist (optional), $sort (optional)
$user_posts = $reddit->userPosts('username');
// returns array of user's posts next page token, dist, sorting method, username

// To Get next page/thread posts of user, use following
$next_page_user_posts = $reddit->userPosts('username', $user_posts['token']);
```

**Fetch User Comments Page**

```
// userComments() @params $username, $token (optional), $dist (optional), $sort (optional)
$comments = $reddit->userComments('username');
// returns array of user's comments, next page token, dist, sorting method, username

// To Get next page/thread comments of user, use following
$next_page_comments = $reddit->userComments('username', $comments['token']);
```

**Download Media Files From A Subreddit**

```
// downloadMediasBySub() @params $subreddit_name, $token (optional), $dist (optional), $sort (optional), $dir (optional)
$downloads = $reddit->downloadMediasBySub('subreddit_name');
// Downloads All Media Files from first page of subreddit using async, saves in $dir location
// returns array of next page token, dist, sorting method and subreddit name

// To download next page/thread media files, use following
$next_page_downloads = $reddit->downloadMediasBySub('subreddit_name', $downloads['token']);
// Downloads All Media Files from next page of subreddit using async, saves in $dir location
// returns array of next page token, dist, sorting method and subreddit name
```

**More Available Methods**

```
parseMediaByPosts($posts); //$posts array of posts from getPosts()
downloadMediasByPosts($posts); //$posts array of posts from getPosts()
parseMedia($media); //each $posts has media loop $posts and pass $post['media'];
```

**Example.php**

```
try {
	$downloads = $reddit->downloadMediasBySub('subreddit_name', false, 25, 'new', 'mydownloads');
	print_r($downloads);
	//echo $downloads['token'];
} catch (Exception $e) {

	if($e->getResponse()) {
		$response = $e->getResponse();
		$responseBodyAsString = $response->getBody()->getContents();
		var_dump($responseBodyAsString);
	} else {
		var_dump($e);
	}

}
```

License
-------

[](#license)

This library for PHP is licensed under the [3-Clause BSD License](https://opensource.org/licenses/BSD-3-Clause)

Credits
-------

[](#credits)

This library for PHP is developed and maintained by Sunil Baral.

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 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

Every ~0 days

Total

2

Last Release

1808d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/75522799?v=4)[Sunil Baral](/maintainers/snlbaral)[@snlbaral](https://github.com/snlbaral)

---

Top Contributors

[![snlbaral](https://avatars.githubusercontent.com/u/75522799?v=4)](https://github.com/snlbaral "snlbaral (7 commits)")

---

Tags

phpapisnlbaralreddit apinon oauth

### Embed Badge

![Health badge](/badges/snlbaral-reddit-php/health.svg)

```
[![Health](https://phpackages.com/badges/snlbaral-reddit-php/health.svg)](https://phpackages.com/packages/snlbaral-reddit-php)
```

###  Alternatives

[openai-php/laravel

OpenAI PHP for Laravel is a supercharged PHP API client that allows you to interact with the Open AI API

3.7k7.6M74](/packages/openai-php-laravel)[hubspot/api-client

Hubspot API client

23414.2M16](/packages/hubspot-api-client)[theodo-group/llphant

LLPhant is a library to help you build Generative AI applications.

1.5k311.5k5](/packages/theodo-group-llphant)[resend/resend-php

Resend PHP library.

564.7M21](/packages/resend-resend-php)[checkout/checkout-sdk-php

Checkout.com SDK for PHP

553.3M7](/packages/checkout-checkout-sdk-php)[scriptdevelop/whatsapp-manager

Paquete para manejo de WhatsApp Business API en Laravel

762.6k](/packages/scriptdevelop-whatsapp-manager)

PHPackages © 2026

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