Flarum API Client is a generic PHP API client you can use in any project. You can simply include this package as a dependency to your project to use it.
It creates a bridge between your project and Flarum, allowing you to use it to get data from Flarum.
The only supported installation method is via Composer:
composer require maicol07/flarum-api-client
Other installation methods may be possible, but are not suggested and they won’t be supported!
In order to start working with the client you might need a Flarum master key:
api_keys
table using phpmyadmin/adminer or another solution.The master key is required to access non-public discussions and running actions otherwise reserved for Flarum administrators. If you don’t need these privileges, then you can go ahead without any token
You can find the client API Docs here:
A basic example:
<?php
require_once "vendor/autoload.php";
use Maicol07\Flarum\Api\Client;
$api = new Client('http://example.com');
// A collection of discussions from the first page of your Forum index.
$discussions = $api->discussions()->request();
// Read a specific discussion.
$discussion = $api->discussions()->id(1)->request();
// Read the first page of users.
$users = $api->users()->request();
An authorized example:
<?php
require_once "vendor/autoload.php";
use Maicol07\Flarum\Api\Client;
$api = new Client('http://example.com', ['token' => '<insert-master-token>']);