PHPackages                             fofx/api-cache - 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. [Caching](/categories/caching)
4. /
5. fofx/api-cache

ActiveLibrary[Caching](/categories/caching)

fofx/api-cache
==============

Laravel-based API response caching library

v1.4.1(2mo ago)00MITPHPPHP ^8.3

Since Jan 17Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/fofxtools/api-cache)[ Packagist](https://packagist.org/packages/fofx/api-cache)[ RSS](/packages/fofx-api-cache/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (12)Versions (142)Used By (0)

API Cache Library
=================

[](#api-cache-library)

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.

Requirements
------------

[](#requirements)

- **PHP 8.3+**
- **Laravel 11.38+**
- **Redis** (for distributed rate limiting)

Development Setup
-----------------

[](#development-setup)

1. Clone the repository
2. Install dependencies:

```
composer install
```

3. Copy `.env.example` to `.env`
4. For testing the demo API:

```
php -S 0.0.0.0:8000 -t public
```

Documentation
-------------

[](#documentation)

Please see the [docs](docs) folder for:

- [Laravel Integration Guide](docs/laravel-integration.md) - How to use this library in a full Laravel project
- [Usage](docs/usage-intro.md) - Basic setup guide
- [Database Migrations](docs/database-migrations.md) - Explanation of unconventional approach to database migrations
- [Rate Limiting](docs/rate-limiting.md) - Rate limiting with Redis
- [Cloudflare Tunnel](docs/cloudflare-tunnel.md) - Usage of Cloudflare Tunnel for local development

### Diagrams

[](#diagrams)

- [Workflow Diagram](docs/diagrams/workflow-diagram.mmd)
- [Sequence Diagram](docs/diagrams/sequence-diagram.mmd)

Features
--------

[](#features)

- API response caching
- Rate limiting with Redis
- Compression support
- Multiple API client support

Caching Control
---------------

[](#caching-control)

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);
```

Rate Limiting
-------------

[](#rate-limiting)

Redis-based distributed rate limiting is implemented to ensure consitent rate limiting across multiple application instances.

See [Rate Limiting Documentation](docs/rate-limiting.md) for details.

Database Migrations
-------------------

[](#database-migrations)

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](docs/database-migrations.md).

Laravel Integration
-------------------

[](#laravel-integration)

To use this library in a full Laravel project, see the [Laravel Integration Guide](docs/laravel-integration.md) for step-by-step setup instructions including installation, configuration, and usage examples.

Usage
-----

[](#usage)

### Getting Started

[](#getting-started)

- [Usage Introduction](docs/usage-intro.md) - Basic setup and usage guide

### API Clients

[](#api-clients)

- [Jina AI](docs/usage-jina.md)
- [OpenAI](docs/usage-openai.md)
- [OpenPageRank](docs/usage-openpagerank.md)
- [OpenRouter](docs/usage-openrouter.md)
- [Pixabay](docs/usage-pixabay.md)
- [ScraperAPI](docs/usage-scraperapi.md)
- [ScrapingDog](docs/usage-scrapingdog.md)
- [YouTube](docs/usage-youtube.md)

### DataForSEO API

[](#dataforseo-api)

- [DataForSEO Setup](docs/usage-dataforseo-setup.md)
- [DataForSEO Webhooks](docs/usage-dataforseo-webhooks.md)
- [SERP Google Organic](docs/usage-dataforseo-serpGoogleOrganic.md)
- [SERP Google Autocomplete](docs/usage-dataforseo-serpGoogleAutocomplete.md)
- [Keywords Data Google Ads](docs/usage-dataforseo-keywordsDataGoogleAds.md)
- [Labs](docs/usage-dataforseo-labs.md)
- [Labs Google](docs/usage-dataforseo-labsGoogle.md)
- [Merchant Amazon Products](docs/usage-dataforseo-merchantAmazonProducts.md)
- [Merchant Amazon ASIN](docs/usage-dataforseo-merchantAmazonAsin.md)
- [On Page](docs/usage-dataforseo-onPage.md)
- [Backlinks](docs/usage-dataforseo-backlinks.md)
- [Backlinks Bulk](docs/usage-dataforseo-backlinksBulk.md)

### Utilities

[](#utilities)

- [Responses Table Converters](docs/usage-responses-table-converters.md) - Can be used to convert between compressed and uncompressed response tables

License
-------

[](#license)

MIT

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance86

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity71

Established project with proven stability

 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

Every ~3 days

Recently: every ~35 days

Total

141

Last Release

74d ago

Major Versions

v0.9.9 → v1.0.02025-06-28

PHP version history (2 changes)v0.0.1PHP ^8.2

v0.8.1PHP ^8.3

### Community

Maintainers

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

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/fofx-api-cache/health.svg)

```
[![Health](https://phpackages.com/badges/fofx-api-cache/health.svg)](https://phpackages.com/packages/fofx-api-cache)
```

###  Alternatives

[svix/svix

Svix PHP Library

3.2k722.4k6](/packages/svix-svix)[eliashaeussler/typo3-warming

Warming - Warms up Frontend caches based on an XML sitemap. Cache warmup can be triggered via TYPO3 backend or using a console command. Supports multiple languages and custom crawler implementations.

20229.9k](/packages/eliashaeussler-typo3-warming)[byerikas/cache-tags

Allows for Redis/Valkey cache flushing multiple tagged items by a single tag.

1413.9k](/packages/byerikas-cache-tags)

PHPackages © 2026

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