Resource API Generator plugin screenshot
Dark mode ready
Multilingual support
No v5.x support

Resource API Generator by Fady Mondy

Community

Generate APIs from your Filament resource using single line of code

Tags: Developer Tool
Supported versions:
3.x
Fady Mondy avatar Author: Fady Mondy

Package health

Automated checks of this plugin's Composer package

79 / 100
Security 68
Maintenance 90
Ecosystem 100
15 checks
  • Failed: GitHub Actions pinned to SHA — View details on Plumb
  • Skipped: GitLab CI includes pinned to SHA
  • Passed: Open security advisories
  • Passed: Dependabot PR responsiveness — No stale Dependabot PRs.
  • Skipped: Renovate MR responsiveness
  • Passed: Dependabot or Renovate configured
  • Failed: Dependency update cooldown configured — No cooldown configured in .github/dependabot.yml. View details on Plumb
  • Passed: Provides a security policy
  • Passed: Abandoned or archived — No consulted source marks the package abandoned (packagist, github).
  • Passed: Commit and release recency — Active: last commit 0 days ago; last release 0 days ago.
  • Passed: composer.lock not committed by library — composer.lock is absent from the released dist archive.
  • Warning: Dist archive is lean
  • Passed: Current Laravel version supported — Package dependencies resolve together with current Laravel 13.0.
  • Passed: Current PHP version supported — Constraint ^8.2 supports current PHP 8.5.
  • Skipped: Current Symfony version supported
Third-party plugin. This is built by the community, not the Filament team. Filament does not review, endorse, or vet the security of plugins outside the filament/ namespace. Review the source and install at your own risk. Found malware or an unresolved security issue the author won't address? Report it .
Powered by Plumb Last scanned 2 months ago

Documentation

Screenshot

Latest Stable Version License Downloads

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.

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.

#Screenshots

APIs Resource APIs Resource Dark

#Usage

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}
  • The list returns the visible columns of the resource table, searches its searchable columns and uses its default sort. Relationship columns such as author.name are 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, update and delete abilities are checked for the API user.
  • The routes point at a controller, so 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).

#Customize your API

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);
}

#Publish Assets

php artisan vendor:publish --tag="filament-api-config"

#Testing

composer test

#Other Filament Packages

Checkout our Awesome TomatoPHP