filahq/statify

Export your Filament stat widgets as API.

Maintainers

Package info

github.com/filahq/filament-statify

pkg:composer/filahq/statify

Statistics

Installs: 3

Dependents: 0

Suggesters: 1

Stars: 0

Open Issues: 0

v0.1.2 2026-03-19 23:21 UTC

This package is auto-updated.

Last update: 2026-03-19 23:24:21 UTC


README

Export your Filament stat widgets as API.

Installation

composer require filahq/statify

Statify's core package only requires Filament widgets.

If you also want the optional StatifyPlugin panel integration, install the full Filament package in your app:

composer require filament/filament

Publish the config:

php artisan vendor:publish --tag=statify-config

Configuration

// config/statify.php

return [
    'guard' => env('STATIFY_GUARD', 'token'), // "token" or "sanctum"
    'token' => env('STATIFY_TOKEN'),           // for "token" guard; null = open access
    'cache_ttl' => 60,                         // seconds
    'cache_prefix' => 'statify',
    'prefix' => 'api/statify',
];

Usage

Register Widgets

Register your StatsOverviewWidget classes in a service provider:

use FilaHQ\Statify\Statify;

Statify::widgets([
    RevenueStatsWidget::class,
    UsersStatsWidget::class,
]);

Or, if your app has the full filament/filament package installed, use the optional Filament plugin in your panel provider:

use FilaHQ\Statify\StatifyPlugin;

$panel->plugin(
    StatifyPlugin::make()->widgets([
        RevenueStatsWidget::class,
        UsersStatsWidget::class,
    ])
);

API Endpoints

Get all stats:

GET /api/statify/stats

Get stats from a specific widget:

GET /api/statify/widgets/{widget-slug}

The widget slug is the kebab-case version of the class name (e.g., RevenueStatsWidget becomes revenue-stats-widget).

Authentication

Statify supports two authentication modes, configured via STATIFY_GUARD:

Static Token (default)

Set STATIFY_TOKEN in your .env file:

STATIFY_TOKEN=your-secret-token

Authenticate via query parameter or header:

GET /api/statify/stats?token=your-secret-token
Authorization: Bearer your-secret-token

If no token is configured, the API is open (no auth required).

Laravel Sanctum

Set the guard to Sanctum in your .env:

STATIFY_GUARD=sanctum

Install and configure Laravel Sanctum in your application before using this mode.

Generate a personal access token for your user:

$token = $user->createToken('statify')->plainTextToken;

Authenticate with the Sanctum token:

Authorization: Bearer {sanctum-token}

Response Format

{
  "responded_at": "2026-03-13T12:00:00+00:00",
  "stats": [
    {
      "widget": "revenue-stats-widget",
      "id": "revenue-today",
      "label": "Revenue Today",
      "value": "$2,430",
      "raw_value": 2430,
      "description": "+12%",
      "icon": null,
      "color": "success",
      "chart": null
    }
  ]
}

License

MIT