revolution/laravel-mastodon-api
Mastodon API for Laravel
92,342
27
| Install | |
|---|---|
composer require revolution/laravel-mastodon-api |
|
| Latest Version: | 3.5.0 |
| PHP: | ^8.3 |
| Laravel: | 12 · 13 |
| Older releases: | 4 – 11 |
| License: | MIT |
| Last Updated: | Jun 20, 2026 |
| Links: | GitHub · Packagist |
Maintainer: revolution
Mastodon API for Laravel
Requirements
- PHP >= 8.3
- Laravel >= 12.0
Installation
Composer
composer require revolution/laravel-mastodon-api
Socialite and Notification packages will also be installed.
Usage
Registering an application
By Web UI
- Go to your Mastodon's user preferences page.
- Go to development page.
By API
use Revolution\Mastodon\Facades\Mastodon;
class MastodonController
{
public function app()
{
$client_name = 'my-app';
$redirect_uris = 'https://my-instance/callback';
$scopes = 'read write follow';
$app_info = Mastodon::domain('https://example.com')
->createApp($client_name, $redirect_uris, $scopes);
dd($app_info);
//[
// 'id' => '',
// 'client_id' => '',
// 'client_secret' => '',
//]
}
}
OAuth authentication
Use https://github.com/invokable/socialite-mastodon
Save account info.(id, token, username, acct...and more.)
Get statuses
use Revolution\Mastodon\Facades\Mastodon;
$statuses = Mastodon::domain('https://example.com')
->token('token')
->statuses($account_id);
dd($statuses);
Get one status
use Revolution\Mastodon\Facades\Mastodon;
$status = Mastodon::domain('https://example.com')
->token('token')
->status($status_id);
dd($status);
Post status
use Revolution\Mastodon\Facades\Mastodon;
Mastodon::domain('https://example.com')->token('token');
$response = Mastodon::createStatus('test1');
$response = Mastodon::createStatus('test2', ['visibility' => 'unlisted']);
dd($response);
Any API by get or post method
use Revolution\Mastodon\Facades\Mastodon;
$response = Mastodon::domain('https://example.com')
->token('token')
->get('/timelines/public', ['local' => true]);
use Revolution\Mastodon\Facades\Mastodon;
$response = Mastodon::domain('https://example.com')
->token('token')
->post('/follows', ['uri' => '']);
Any API can call by call method
use Revolution\Mastodon\Facades\Mastodon;
$response = Mastodon::domain('https://example.com')
->token('token')
->call('DELETE', '/statuses/1');
Other methods
Check public methods in Contracts/Factory.php
Streaming API
Edit $token and $url in streaming_example.php
php ./streaming_example.php
Ctrl+C to quit.
LICENSE
MIT
Related Packages
doctrine/dbal
Powerful PHP database abstraction layer (DBAL) with many features for database s...
644,549,754
9,698
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| 3.5.0 | ^8.3 | ^12.0|| | MIT | |
| 3.4.0 | ^8.2 | ^11.0|| | MIT | |
| 3.3.2 | ^8.2 | ^11.0|| | MIT | |
| 3.3.1 | ^8.2 | ^11.0|| | MIT | |
| 3.3.0 | ^8.2 | ^11.0|| | MIT | |
| 3.2.0 | ^8.2 | ^10.0|| | MIT | |
| 3.1.5 | ^8.1 | ^10.0|| | MIT | |
| 3.1.4 | ^8.1 | ^10.0|| | MIT | |
| 3.1.3 | ^8.1 | ^10.0|| | MIT | |
| 3.1.2 | ^8.1 | ^10.0|| | MIT | |
| 3.1.1 | ^8.1 | ^10.0|| | MIT | |
| 3.1.0 | ^8.1 | ^10.0|| | MIT | |
| 3.0.3 | ^8.0 | ^9.0|| | MIT | |
| 3.0.2 | ^8.0 | ^9.0|| | MIT | |
| 3.0.1 | ^8.0 | ^9.0|| | MIT | |
| 3.0.0 | ^8.0 | ^9.0|| | MIT | |
| 2.4.0 | ^7.3|| | * | MIT | |
| 2.3.1 | ^7.2|| | * | MIT | |
| 2.3.0 | ^7.2|| | * | MIT | |
| 2.2.0 | ^7.2|| | ^6.0|| | MIT | |
| 2.1.0 | ^7.2|| | * | MIT | |
| 2.0.3 | >=7.1.3 | * | MIT | |
| 2.0.2 | >=7.1.3 | * | MIT | |
| 2.0.1 | >=7.1.3 | ^5.8 || | MIT | |
| 2.0.0 | >=7.1.3 | ^5.8 | MIT | |
| 1.5.2 | >=7.0.0 | ^5.5 | MIT | |
| 1.5.1 | >=7.0.0 | ^5.5 | MIT | |
| 1.5.0 | >=7.0.0 | ^5.5 | MIT | |
| 1.4.0 | >=7.0.0 | ^5.5 | MIT | |
| 1.3.2 | >=7.0.0 | ^5.5 | MIT |
Showing the latest 30 of 39. See every release on Packagist