PHPackages                             usman/reddit-php-api - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. usman/reddit-php-api

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

usman/reddit-php-api
====================

Reddit SDK. Handles OAuth, CSRF protection. Easy to implement and extend. This is a standalone library for any composer project.

v1.0.1(8mo ago)018[1 issues](https://github.com/UsmanMalik748/reddit-php-api/issues)MITPHPPHP ^8.0

Since Nov 28Pushed 8mo ago1 watchersCompare

[ Source](https://github.com/UsmanMalik748/reddit-php-api)[ Packagist](https://packagist.org/packages/usman/reddit-php-api)[ Docs](https://github.com/UsmanMalik748/reddit-php-api)[ RSS](/packages/usman-reddit-php-api/feed)WikiDiscussions main Synced 1mo ago

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

Reddit API client in PHP
========================

[](#reddit-api-client-in-php)

A PHP library to handle authentication and communication with Reddit API. The library/SDK helps you to get an access token and when authenticated it helps you to send API requests. You will not get *everything* for free though... You have to read the [Reddit documentation](https://developer.Reddit.com/core-concepts) to understand how you should query the API.

To get an overview what this library actually is doing for you. Take a look at the authentication page from the [API docs](https://developer.Reddit.com/documents/authentication).

Features
--------

[](#features)

Here is a list of features that might convince you to choose this Reddit client over some of our competitors'.

- Flexible and easy to extend
- Developed with modern PHP standards
- Not developed for a specific framework.
- Handles the authentication process
- Respects the CSRF protection

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

[](#installation)

**TL;DR**

```
composer require php-http/curl-client guzzlehttp/psr7 php-http/message usman/reddit-php-api
```

This library does not have a dependency on Guzzle or any other library that sends HTTP requests. We use the awesome HTTPlug to achieve the decoupling. We want you to choose what library to use for sending HTTP requests. Consult this list of packages that support [php-http/client-implementation](https://packagist.org/providers/php-http/client-implementation)find clients to use. For more information about virtual packages please refer to [HTTPlug](http://docs.php-http.org/en/latest/httplug/users.html). Example:

```
composer require php-http/guzzle6-adapter
```

You do also need to install a PSR-7 implementation and a factory to create PSR-7 messages (PSR-17 whenever that is released). You could use Guzzles PSR-7 implementation and factories from php-http:

```
composer require guzzlehttp/psr7 php-http/message
```

Now you may install the library by running the following:

```
composer require usman/reddit-php-api
```

Usage
-----

[](#usage)

In order to use this API client (or any other Reddit clients) you have to [register your application](https://www.Reddit.com/secure/developer)with Reddit to receive an API key. Once you've registered your Reddit app, you will be provided with an *API Key* and *Secret Key*.

### Reddit login

[](#reddit-login)

This example below is showing how to login with Reddit.

```
