https://github.com/israel-007/stashquiver
This library is set to support cache, API request, data compression, handle errors, format different data types, log data's, rate limiting e.t.c
https://github.com/israel-007/stashquiver
api api-request api-resources api-response cache cache-storage caching data-compression format-response log-data rate-limiter rate-limiting
Last synced: about 1 year ago
JSON representation
This library is set to support cache, API request, data compression, handle errors, format different data types, log data's, rate limiting e.t.c
- Host: GitHub
- URL: https://github.com/israel-007/stashquiver
- Owner: israel-007
- Created: 2024-10-27T21:37:48.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-26T21:26:04.000Z (over 1 year ago)
- Last Synced: 2025-02-26T22:26:54.073Z (over 1 year ago)
- Topics: api, api-request, api-resources, api-response, cache, cache-storage, caching, data-compression, format-response, log-data, rate-limiter, rate-limiting
- Language: PHP
- Homepage:
- Size: 28.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# APIStash Library
APIStash is a versatile PHP library designed to streamline API interactions. It offers robust features such as caching, rate limiting, error handling, and flexible HTTP request handling, making it an ideal choice for developers working with external APIs.
With APIStash, you can:
- Simplify API requests using a chainable, user-friendly interface.
- Cache API responses to reduce redundant API calls.
- Enforce rate limits to comply with API quotas.
- Retry failed requests with a configurable fallback mechanism.
- Seamlessly integrate with any PHP project using Composer.
---
## Features
- **Chainable API Requests**: Easily build and send API requests with a fluid interface.
- **Caching**: Cache API responses locally to minimize external requests.
- **Rate Limiting**: Prevent excessive requests to ensure compliance with API limits.
- **Error Handling**: Automatically retry failed requests with configurable fallback responses.
- **Guzzle Integration**: Use Guzzle for HTTP requests when available, with fallback options.
- **No Vendor Lock-In**: Customize or disable components like caching and rate limiting as needed.
## Installation
APIStash is available via Composer. To install it, run the following command:
```bash
composer require stashquiver/stashquiver
```
## Requirements
- **PHP 7.4 or higher**
- **Composer**
### Step 3: Basic Usage Example
#### Example
```markdown
## Basic Usage
Here's a quick example to demonstrate how to use APIStash to make a GET request:
```php
use StashQuiver\Requests;
// Create an instance of Requests
$requests = new Requests();
try {
// Build and send the request
$response = $requests
->url('https://api.example.com/data')
->method('GET')
->params(['param1' => 'value1']) // Optional query parameters
->headers(['Custom-Header' => 'HeaderValue']) // Optional headers
->send();
// Output the raw API response
echo $response;
} catch (\Exception $e) {
// Handle any errors
echo "Request failed: " . $e->getMessage();
}
---