filament-api
Generate APIs from your filament resource using single line of code
Extends filament
composer require tomatophp/filament-api- api
- filament-plugin
- filamentphp
- generator
- rest
- tomatophp
Readme

Resource API Generator
Generate JSON APIs from your Filament resources with a single line of code.
Version Compatibility
| Plugin | Filament | Laravel | PHP |
|---|---|---|---|
| 1.x | 3.x | 10.x / 11.x | 8.1+ |
| 5.x | 5.x | 12.x / 13.x | 8.2+ |
Installation
The APIs list page keeps the generated endpoints in an in-memory SQLite table, so the pdo_sqlite PHP extension is required.
To list the generated endpoints in your panel, register the plugin in /app/Providers/Filament/AdminPanelProvider.php:
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.
Screenshots

Usage
Add the trait to your resource pages:
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} |
- The list returns the visible columns of the resource table, searches its searchable columns and uses its default sort.
Relationship columns such as
author.nameare eager loaded and searchable. - Create and update validate the request with the rules of every field of the resource form (fields inside sections, tabs and grids included) and save only the form fields.
- Queries go through the resource
getEloquentQuery(), so scopes, soft deletes and tenancy filters apply. - When the model has a policy, the
viewAny,view,create,updateanddeleteabilities are checked for the API user. - The routes point at a controller, so
php artisan route:cacheworks.
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).
Customize your API
Override these methods on the page:
Publish Assets
Testing
Other Filament Packages
Checkout our Awesome TomatoPHP