A Laravel-based PHP library for caching API responses from various services (OpenAI, DataForSEO, Pixabay, YouTube, and more). Provides intelligent caching, rate limiting, compression, and response management through a unified interface.
- PHP 8.3+
- Laravel 11.38+
- Redis (for distributed rate limiting)
- Clone the repository
- Install dependencies:
composer install
- Copy
.env.example
to.env
- For testing the demo API:
php -S 0.0.0.0:8000 -t public
Please see the docs folder for:
- Laravel Integration Guide - How to use this library in a full Laravel project
- Usage - Basic setup guide
- Database Migrations - Explanation of unconventional approach to database migrations
- Rate Limiting - Rate limiting with Redis
- Cloudflare Tunnel - Usage of Cloudflare Tunnel for local development
- API response caching
- Rate limiting with Redis
- Compression support
- Multiple API client support
The sendCachedRequest()
method respects the caching settings of the API client. You can control caching behavior using:
// Create a new client instance
$client = new ScraperApiClient();
// Disable caching for a specific request
$client->setUseCache(false);
// Check current caching status
$isCachingEnabled = $client->getUseCache();
echo 'Is caching enabled: ' . ($isCachingEnabled ? 'true' : 'false') . PHP_EOL;
$response = $client->scrape('https://httpbin.org/headers');
echo format_api_response($response, true);
// Re-enable caching
$client->setUseCache(true);
Redis-based distributed rate limiting is implemented to ensure consitent rate limiting across multiple application instances.
See Rate Limiting Documentation for details.
This library takes an unconventional approach to database migrations in order to follow the DRY principle and simplify maintenance across multiple clients, while maintaining consistency between tables.
For more details, see Database Migrations Documentation.
To use this library in a full Laravel project, see the Laravel Integration Guide for step-by-step setup instructions including installation, configuration, and usage examples.
- Usage Introduction - Basic setup and usage guide
- DataForSEO Setup
- DataForSEO Webhooks
- SERP Google Organic
- SERP Google Autocomplete
- Keywords Data Google Ads
- Labs
- Labs Google
- Merchant Amazon Products
- Merchant Amazon ASIN
- On Page
- Backlinks
- Backlinks Bulk
- Responses Table Converters - Can be used to convert between compressed and uncompressed response tables
MIT