PHPackages                             taoshan98/laravel-api-watcher - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. taoshan98/laravel-api-watcher

ActiveLibrary[API Development](/categories/api)

taoshan98/laravel-api-watcher
=============================

A modern Laravel package to intercept, analyze, and visualize API requests.

v1.0.0(2mo ago)053MITPythonPHP ^8.2

Since Feb 19Pushed 2mo agoCompare

[ Source](https://github.com/Taoshan98/laravel-api-watcher)[ Packagist](https://packagist.org/packages/taoshan98/laravel-api-watcher)[ RSS](/packages/taoshan98-laravel-api-watcher/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (8)Versions (2)Used By (0)

Laravel API Watcher 🦅
=====================

[](#laravel-api-watcher-)

[![Latest Version on Packagist](https://camo.githubusercontent.com/c0a3a71a63b890b8c68b0c98332e074ab80d00cb8a510740a5f25ac33029b290/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f74616f7368616e39382f6c61726176656c2d6170692d776174636865722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/taoshan98/laravel-api-watcher)[![Total Downloads](https://camo.githubusercontent.com/669e2fdeba12aae3eb5caf6a48bb8500c5484df1d0334738a8d501ab9e0b71c7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f74616f7368616e39382f6c61726176656c2d6170692d776174636865722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/taoshan98/laravel-api-watcher)[![License](https://camo.githubusercontent.com/ea5f3f3baa2bdb864f6932816691b48914f931d57d1cae3f712d4f10688ab330/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f74616f7368616e39382f6c61726176656c2d6170692d776174636865722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/taoshan98/laravel-api-watcher)

**Laravel API Watcher** is a powerful, zero-latency monitoring and debugging tool for your API. It provides a beautiful dashboard to inspect requests, analyze performance trends, and receive proactive health alerts.

[![Dashboard Preview](./art/dashboard.png)](./art/dashboard.png)

✨ Features
----------

[](#-features)

- **🔍 Request Inspector**: View detailed logs of every API request (Headers, Body, Response, Queries, Timeline).
- **🚀 Zero Latency**: Uses `dispatch()->afterResponse()` to ensure monitoring never slows down your API.
- **📊 Analytics Dashboard**: Visualize request volume, error rates, and latency trends.
- **🛡️ Sensitive Data Redaction**: Automatically masks passwords, tokens, and credit cards.
- **🔌 Public API**: Secure, authenticated API to retrieve logs programmatically (supports **Database-backed API Keys**).
- **🔐 Security &amp; Privacy**:
    - **Encryption at Rest**: Optional AES-256 encryption for request bodies.
    - **Hashed API Keys**: Keys are stored securely using SHA-256 hashing.
    - **Authorization**: Dashboard access restricted by Gate.
- **🚨 Proactive Alerting**: Receive notifications via **Mail** or any **Custom Channel** when error rates or latency spike.
- **🛠️ Maintenance Tools**: Prune old logs, export data (JSON/CSV), and clear history directly from the UI.
- **🌑 Dark Mode**: Fully supported dark mode for late-night debugging.

📸 Screenshots
-------------

[](#-screenshots)

### Dashboard

[](#dashboard)

Overview of your API health with real-time stats and performance charts. [![Dashboard](./art/dashboard.png)](./art/dashboard.png)

### Request Inspector

[](#request-inspector)

Deep dive into request details with payload formatting, headers, and timeline execution. [![Request Details](./art/request_details.png)](./art/request_details.png)

### Analytics

[](#analytics)

Analyze traffic trends, status code distribution, and slowest endpoints. [![Analytics](./art/analytics.png)](./art/analytics.png)

### API Management

[](#api-management)

Manage secure access keys for the Public API. [![API Keys](./art/keys.png)](./art/keys.png)

---

🚀 Installation
--------------

[](#-installation)

1. **Require the package via Composer**:

    ```
    composer require taoshan98/laravel-api-watcher
    ```
2. **Publish the configuration and assets**:

    ```
    php artisan vendor:publish --tag=api-watcher-config
    php artisan vendor:publish --tag=api-watcher-assets
    ```
3. **Run Migrations**:

    ```
    php artisan migrate
    ```

    ```
    php artisan api-watcher:clear
    ```

    #### Manage API Keys

    [](#manage-api-keys)

    - **List Keys**: `php artisan api-watcher:list-keys`
    - **Create Key**: `php artisan api-watcher:create-key "My App"`
    - **Rename Key**: `php artisan api-watcher:rename-key {id} "New Name"`
    - **Regenerate Key**: `php artisan api-watcher:regenerate-key {id}`
    - **Delete Key**: `php artisan api-watcher:delete-key {id}`
4. **Add the Middleware**: Add `CaptureApiRequest` to your `api` middleware group in `bootstrap/app.php` (Laravel 11) or `app/Http/Kernel.php` (Laravel 10).

    ```
    // bootstrap/app.php
    ->withMiddleware(function (Middleware $middleware) {
        $middleware->api(prepend: [
            \Taoshan98\LaravelApiWatcher\Middleware\CaptureApiRequest::class,
        ]);
    })
    ```
5. **Schedule the Monitor** (Optional, for Alerts): In `routes/console.php`:

    ```
    Schedule::command('api-watcher:monitor')->everyFiveMinutes();
    ```

### 🔄 Keeping Assets Updated

[](#-keeping-assets-updated)

When you update the package, the compiled dashboard assets in your `public` folder need to be synchronized. To automate this, add the following to your `composer.json` file:

```
"scripts": {
    "post-update-cmd": [
        "@php artisan vendor:publish --tag=api-watcher-assets --force --quiet"
    ]
}
```

---

⚙️ Configuration
----------------

[](#️-configuration)

The configuration file is located at `config/api-watcher.php`.

### Basic Settings

[](#basic-settings)

```
# Enable/Disable Recording
API_WATCHER_ENABLED=true

# Dashboard Path (Default: /api-watcher)
API_WATCHER_PATH=api-watcher
```

### 🔒 Security

[](#-security)

#### Dashboard Access

[](#dashboard-access)

By default, the dashboard is only accessible in `local` environment. To allow access in production, define the `viewApiWatcher` gate in your `AppServiceProvider`:

```
use Illuminate\Support\Facades\Gate;

public function boot()
{
    Gate::define('viewApiWatcher', function ($user) {
        return in_array($user->email, ['admin@yourcompany.com']);
    });
}
```

#### Data Encryption

[](#data-encryption)

To encrypt request headers and bodies in the database:

```
API_WATCHER_ENCRYPT_BODY=true
```

---

🔌 Public API
------------

[](#-public-api)

You can programmatically retrieve logs and statistics via the secure Public API. The API is authenticated mechanism using database-backed keys.

### 1. Enable

[](#1-enable)

In `.env`:

```
API_WATCHER_API_ENABLED=true
```

### 2. Manage Keys

[](#2-manage-keys)

You can generate API Tokens via the **Dashboard** &gt; **API Keys** or via Artisan:

```
php artisan api-watcher:create-key "My App"
```

Or via the UI: Go to `/api-watcher/keys`. *Note*: Keys are hashed. You can only see the token once upon creation.

### 3. Endpoints

[](#3-endpoints)

Pass the key in the header: `X-API-WATCHER-KEY: `.

- `GET /api-watcher/api/v1/stats`: Returns total requests, error rate, and trends.
- `GET /api-watcher/api/v1/requests`: List requests with filters (`status_code`, `method`, `date_from`, etc.).
- `GET /api-watcher/api/v1/requests/{id}`: Get full details of a request.

---

🚨 Alerts &amp; Monitoring
-------------------------

[](#-alerts--monitoring)

API Watcher checks your API health every 5 minutes (via the scheduled command).

### Configuration

[](#configuration)

In `config/api-watcher.php`:

```
'alerts' => [
    'enabled' => true,
    'channels' => ['mail'], // Supports 'slack', 'discord', or custom classes
    'thresholds' => [
        'error_rate' => 5, // Alert if > 5% requests are errors
        'high_latency_ms' => 1000, // Alert if avg latency > 1000ms
    ],
    'check_interval_minutes' => 5,
],
```

---

🧼 GDPR &amp; Pruning
--------------------

[](#-gdpr--pruning)

To keep your database clean, the `prune` command automatically deletes logs older than the configured retention period (default: 30 days).

```
# Run manually
php artisan api-watcher:prune

# Schedule in routes/console.php
Schedule::command('api-watcher:prune')->daily();
```

---

🤝 Contributing
--------------

[](#-contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

📄 License
---------

[](#-license)

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

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance83

Actively maintained with recent releases

Popularity12

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

88d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ec8deb2b4139351fe8bc873ec640aada2a457949d3bbaf04d920ac703bd9c12e?d=identicon)[Taoshan98](/maintainers/Taoshan98)

---

Top Contributors

[![Taoshan98](https://avatars.githubusercontent.com/u/15851056?v=4)](https://github.com/Taoshan98 "Taoshan98 (4 commits)")

---

Tags

analyticsapilaravelrequestswatcherapilaraveldebuggingdashboardmonitorwatcherrequests

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/taoshan98-laravel-api-watcher/health.svg)

```
[![Health](https://phpackages.com/badges/taoshan98-laravel-api-watcher/health.svg)](https://phpackages.com/packages/taoshan98-laravel-api-watcher)
```

###  Alternatives

[essa/api-tool-kit

set of tools to build an api with laravel

52680.5k](/packages/essa-api-tool-kit)[resend/resend-laravel

Resend for Laravel

1191.4M6](/packages/resend-resend-laravel)[api-platform/laravel

API Platform support for Laravel

59126.4k6](/packages/api-platform-laravel)[simplestats-io/laravel-client

Client for SimpleStats!

4515.5k](/packages/simplestats-io-laravel-client)[dragon-code/laravel-json-response

Automatically always return a response in JSON format

1118.6k1](/packages/dragon-code-laravel-json-response)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
