Generate APIs from your filament resource using single line of code
tomatophp/filament-api is a Laravel package for generate apis from your filament resource using single line of code.
It currently has 55 GitHub stars and 7.526 downloads on Packagist (latest version 5.0.0).
Install it with composer require tomatophp/filament-api.
Discover more Laravel packages by tomatophp
or browse all Laravel packages to compare alternatives.
Last updated

Generate JSON APIs from your Filament resources with a single line of code.
| Plugin | Filament | Laravel | PHP | |--------|----------|---------|-----| | 1.x | 3.x | 10.x / 11.x | 8.1+ | | 5.x | 5.x | 12.x / 13.x | 8.2+ |
The APIs list page keeps the generated endpoints in an in-memory SQLite table, so the pdo_sqlite PHP extension is required.
composer require tomatophp/filament-api
php artisan filament-api:install
To list the generated endpoints in your panel, register the plugin in /app/Providers/Filament/AdminPanelProvider.php:
->plugin(\TomatoPHP\FilamentApi\FilamentAPIPlugin::make())
The endpoints use the auth:sanctum middleware by default. Install Laravel Sanctum (php artisan install:api) or change default_middleware in config/filament-api.php.

Add the trait to your resource pages:
use Filament\Resources\Pages\ListRecords;
use TomatoPHP\FilamentApi\Traits\InteractWithAPI;
class ListPosts extends ListRecords
{
use InteractWithAPI;
}
That's it, the API is available under /api/{slug}. Each page type adds its endpoints:
| Page | Endpoints |
|------|-----------|
| ListRecords | GET /api/{slug} (list, ?search= and ?page=), DELETE /api/{slug}/{id} |
| ManageRecords | all five endpoints |
| CreateRecord | POST /api/{slug} |
| EditRecord | PUT /api/{slug}/{id} |
| ViewRecord | GET /api/{slug}/{id} |
author.name are eager loaded and searchable.getEloquentQuery(), so scopes, soft deletes and tenancy filters apply.viewAny, view, create, update and delete abilities are checked for the API user.php artisan route:cache works.Responses look like {"status": "success", "message": "OK", "data": ...}; errors return {"status": "error", "message": "..."}
with the status code (404, 403, and 422 with an errors object for validation).
Override these methods on the page:
// Return a JSON resource from the list, show, store and update endpoints
public static function getFilamentAPIResource(): ?string
{
return PostResource::class;
}
// The middleware of the endpoints
public static function getFilamentAPIMiddleware(): array
{
return ['auth:sanctum'];
}
// The endpoint slug, defaults to the resource slug
public static function getFilamentAPISlug(): ?string
{
return 'articles';
}
// The form used to validate and save the store and update endpoints
public static function getFilamentAPIForm(Schema $schema): Schema
{
return static::getResource()::form($schema);
}
// The table used to shape the list endpoint
public static function getFilamentAPITable(Table $table): Table
{
return static::getResource()::table($table);
}
php artisan vendor:publish --tag="filament-api-config"
composer test
Checkout our Awesome TomatoPHP