PHPackages                             nivshah/discourse-api-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. nivshah/discourse-api-php

ActiveLibrary

nivshah/discourse-api-php
=========================

Discourse API library for PHP

016PHP

Since May 15Pushed 2y agoCompare

[ Source](https://github.com/nivshah/discourse-api-php)[ Packagist](https://packagist.org/packages/nivshah/discourse-api-php)[ RSS](/packages/nivshah-discourse-api-php/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

discourse-api-php
=================

[](#discourse-api-php)

This is a composer packaged version of the PHP library for accessing the Discourse API.

More about Discourse:

Discourse API docs:

Features
========

[](#features)

- Supports header-based authentication (required by Discourse as of April 2020)
- Includes test suite for developers

### Changelog

[](#changelog)

- 2.1 - Fixing a nasty little bug

### History

[](#history)

Originally as published by DiscourseHosting at .

With contributions from:

-
-
-
-
-
-

Now lives at

How to Use
==========

[](#how-to-use)

Just include it with Composer: `composer require nivshah/discourse-api-php`

And then:

```
// set up key in Discourse first - recommend system key for all users
$key = 'my-secret-discourse-api-key';
$hostname = 'forums.example.com';

$api = new \nivshah\DiscourseAPI($hostname, $key);

// and you're off and running!
// look through the src/DiscourseAPI.php file for methods
// for example:
$results = $api->getTopTopics();

// if you aren't sure what the API returns from a call, just look at it:
$results = $api->getUserByDiscourseId( 1 );
var_dump($results);

// you can also get a lot of info from the tests (see tests/DiscourseApiTest.php).
```

For Developers
==============

[](#for-developers)

I'd love to see your changes and improvements to this library! Please feel free to submit a pull request, and please include a new test if you are adding/refactoring methods.

Testing
-------

[](#testing)

### Setup

[](#setup)

1. Run `composer install` to install PHPUnit and other helper libraries
2. Copy the `.env.example` file in the tests folder, change the name to `.env` and fill in the blanks

### Running tests

[](#running-tests)

In the terminal, from the root directory of this project, enter: `./vendor/bin/phpunit tests/DiscourseApiTest.php`

###  Health Score

14

—

LowBetter than 2% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity18

Early-stage or recently created project

 Bus Factor1

Top contributor holds 58.3% 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.

### Community

Maintainers

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

---

Top Contributors

[![pnoeric](https://avatars.githubusercontent.com/u/447652?v=4)](https://github.com/pnoeric "pnoeric (77 commits)")[![richp10](https://avatars.githubusercontent.com/u/3863621?v=4)](https://github.com/richp10 "richp10 (31 commits)")[![nivshah](https://avatars.githubusercontent.com/u/685145?v=4)](https://github.com/nivshah "nivshah (13 commits)")[![ajimix](https://avatars.githubusercontent.com/u/30565?v=4)](https://github.com/ajimix "ajimix (6 commits)")[![martinduparc](https://avatars.githubusercontent.com/u/839534?v=4)](https://github.com/martinduparc "martinduparc (5 commits)")

### Embed Badge

![Health badge](/badges/nivshah-discourse-api-php/health.svg)

```
[![Health](https://phpackages.com/badges/nivshah-discourse-api-php/health.svg)](https://phpackages.com/packages/nivshah-discourse-api-php)
```

PHPackages © 2026

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