Looking to hire Laravel developers? Try LaraJobs

laravel-api-usage-pulse maintained by kodamity

Description
API usage cards for Laravel Pulse
Last update
2026/02/02 01:34 (dev-dependabot/composer/livewire/livewire-tw-4.1)
License
Downloads
412

Comments
comments powered by Disqus

API usage cards for Laravel Pulse

This is package that adds API usage cards and recorders for Laravel Pulse.

Installation

You can install the package via composer:

composer require kodamity/laravel-api-usage-pulse

Recorders

Add recorders configuration inside config/pulse.php. (If you don't have this file make sure you have published the config file of Laravel Pulse using php artisan vendor:publish --tag=pulse-config)

Requests Statistics recorder

Requests Statistics recorder records the number of requests and the number of successful requests in general for all users. And it records the number of requests and the number of successful requests for each user.

return [
    // ...
    
    'recorders' => [
        // Existing recorders...
        
        \Kodamity\Libraries\ApiUsagePulse\Recorders\RequestsStatistics::class => [
            'enabled' => env('PULSE_KDM_API_USAGE_REQUESTS_STATISTICS_ENABLED', true),
            'sample_rate' => env('PULSE_KDM_API_USAGE_REQUESTS_STATISTICS_SAMPLE_RATE', 1),
            'ignore' => [
                '#^/pulse$#', // Pulse dashboard...
            ],
        ],
    ],
];

Responses Statistics recorder

Responses Statistics recorder records the average response time and the number of responses by status code group for all users.

return [
    // ...
    
    'recorders' => [
        // Existing recorders...
        
        \Kodamity\Libraries\ApiUsagePulse\Recorders\ResponsesStatistics::class => [
            'enabled' => env('PULSE_KDM_API_USAGE_RESPONSES_STATISTICS_ENABLED', true),
            'sample_rate' => env('PULSE_KDM_API_USAGE_RESPONSES_STATISTICS_SAMPLE_RATE', 1),
            'ignore' => [
                '#^/pulse$#', // Pulse dashboard...
            ],
            'records' => [
                \Kodamity\Libraries\ApiUsagePulse\Enums\ResponseStatusGroup::Informational->value,
                \Kodamity\Libraries\ApiUsagePulse\Enums\ResponseStatusGroup::Successful->value,
                \Kodamity\Libraries\ApiUsagePulse\Enums\ResponseStatusGroup::Redirection->value,
                \Kodamity\Libraries\ApiUsagePulse\Enums\ResponseStatusGroup::ClientError->value,
                \Kodamity\Libraries\ApiUsagePulse\Enums\ResponseStatusGroup::ServerError->value,
            ],
        ],  
    ],
];

Dashboards

To add the card to the Pulse dashboard, you must first publish the vendor view.

php artisan vendor:publish --tag=pulse-dashboard

Then, you can modify the dashboard.blade.php file and add the card to the dashboard.

<livewire:kodamity.pulse.api-usage.requests-summary cols="5" rows="2" />

<livewire:kodamity.pulse.api-usage.response-statuses-graph cols="7" />

<livewire:kodamity.pulse.api-usage.response-times-graph cols="7" />

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.