定制 chrisreedio/api-amigo 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

chrisreedio/api-amigo

Composer 安装命令:

composer require chrisreedio/api-amigo

包简介

API Quota Management and Analytics

README 文档

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Overview

API Amigo is a comprehensive Laravel package tailored to elevate your API integration experience.

It's more than just a quota manager; it's a robust tool for monitoring API health, tracking failed requests, and delivering actionable insights through aggregate statistics.

API Amigo is your dependable partner, ensuring that you make the most out of every API interaction.

Key Features

  • Quota Monitoring: Stay informed on your API usage with real-time tracking of quota limits. API Amigo diligently monitors quota headers in API responses, ensuring you're always within bounds.
  • Failure Analysis: Track and analyze failed API requests. Understand the 'why' behind failures to improve reliability and efficiency in your API interactions.
  • Aggregate Statistics: Get a comprehensive view of your API usage with detailed statistics. Understand usage patterns, peak request times, and more, enabling data-driven decisions.
  • Intuitive Dashboard: Seamlessly integrated with Laravel's Filament admin panel, API Amigo provides a clear, concise view of your API landscape, all in one place.
  • Custom Alerts: Configure alerts for approaching quota limits and detect anomalies in API performance. Stay proactive and prevent unexpected downtimes.
  • Easy Integration: Designed with simplicity in mind, API Amigo offers a straightforward setup process, allowing you to focus on building, not configuring.

Installation

You can install the package via composer:

composer require chrisreedio/api-amigo

You can publish and run the migrations with:

php artisan vendor:publish --tag="api-amigo-migrations"
php artisan migrate

Install the plugin into your panel by adding the following to your AdminPanelProvider.php (or other panel) file:

    ->plugins([
        // ... Other plugins
        \ChrisReedIO\APIAmigo\APIAmigoPlugin::make(),
    ])

Be sure to enable API Amigo tracking globally via your .env:

AMIGO_ENABLED=true

You can publish the config file with:

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

Optionally, you can publish the views using

php artisan vendor:publish --tag="api-amigo-views"

Response Aggregation

API Amigo provides powerful commands to aggregate API response data for analytics and reporting. These commands help you track performance metrics, success rates, and usage patterns over time.

Available Commands

  1. Daily Aggregation

    php artisan responses:aggregate-daily

    This command processes the previous day's responses and creates hourly aggregations. It's designed to be run daily via the scheduler.

  2. Historical Data Processing

    # Process all historical data up to yesterday
    php artisan responses:aggregate --all
    
    # Process a specific date range
    php artisan responses:aggregate 2023-01-01 2023-12-31 --bulk
    
    # Process a single day
    php artisan responses:aggregate 2023-01-01
  3. Pruning Old Responses

    # Prune responses older than the configured lifetime (default: 90 days)
    php artisan responses:prune
    
    # Force prune without confirmation
    php artisan responses:prune --force

Setting Up Scheduling

For Laravel 11/12 applications, add the following to your app/Console/Kernel.php:

use Illuminate\Support\Facades\Schedule;
use ChrisReedIO\APIAmigo\Commands\ResponsesDailyAggregationCommand;
use ChrisReedIO\APIAmigo\Commands\PruneResponsesCommand;

protected function schedule(Schedule $schedule): void
{
    // Run daily aggregation at 1 AM in your configured timezone
    Schedule::command(new ResponsesDailyAggregationCommand)
        ->dailyAt('22:00')
        ->timezone(config('api-amigo.aggregation.timezone', 'UTC'));

    // Run pruning weekly on Sunday at 2 AM
    Schedule::command(new PruneResponsesCommand, ['--force'])
        ->weekly()
        ->sundays()
        ->at('02:00');
}

Configuration

You can configure the timezone and response lifetime in your .env file:

AMIGO_AGGREGATION_TIMEZONE=America/New_York
AMIGO_PRUNE_LIFETIME_DAYS=90

Or directly in config/api-amigo.php:

'aggregation' => [
    'timezone' => 'America/New_York',
    'prune_lifetime_days' => 90,
],

Initial Setup

When first installing API Amigo or after a long period without aggregation, you should:

  1. Process all historical data:

    php artisan responses:aggregate --all
  2. Set up the daily scheduler as shown above

The --all command will:

  • Find your earliest response date
  • Process all data up to yesterday
  • Use bulk processing to handle large datasets efficiently
  • Show progress and statistics during processing

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

This is currently closed source.

License choice is pending. Please check back soon.

统计信息

  • 总下载量: 1.53k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-21

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固