KursBI π¦
KursBI is a lightweight PHP library designed to simplify the process of fetching exchange rate data directly from the official Bank Indonesia (BI) API. Whether you are building a financial dashboard with Laravel or a simple currency converter in vanilla PHP, KursBI provides a robust and easy-to-use interface.
Key Features β¨
- Flexible Retrieval: Fetch exchange rates for a single currency or multiple currencies in one go.
- Date Ranges: Retrieve historical data by specifying start and end dates.
- Data Limiting: Easily cap the number of results returned to keep your application fast.
- Built-in Conversion: Automatically calculate currency conversions using official buy and sell rates.
- Smart Caching: Fully compatible with Laravel Cache, reducing redundant API calls and improving performance.
- Stealth Requests: Uses dynamic User-Agents to ensure stable and natural communication with the BI servers.
- Seamless Integration: Native support for Laravel, including built-in error handling and configuration.
Why Use KursBI? π€
Fetching financial data manually can be tedious and prone to errors. KursBI handles the complexity of API communication, data parsing, and caching so you can focus on building your application's core logic.
Installation π
You can easily install KursBI via Composer:
composer require fyyyn1210/kursbi
Quick Usage Examples π‘
1. Fetch Today's USD Rate
use Fyyyn1210\KursBI; $kursBI = new KursBI(); $result = $kursBI->getKurs('USD'); print_r($result);
2. Multi-Currency Conversion
// Convert 1000 USD to IDR using today's rate $result = $kursBI->getKurs( 'USD', null, // Current date null, // Current date null, // No limit 1000 // Amount to convert );
Supported Currencies π―
KursBI supports all currencies provided by the Bank Indonesia API, including:
- USD (US Dollar)
- EUR (Euro)
- JPY (Japanese Yen)
- GBP (British Pound)
- SGD (Singapore Dollar)
- ...and many more.
Contribution π€
This is an open-source project. If you find a bug or have a feature request, feel free to open an issue or submit a pull request on GitHub.
β Found this useful? Give it a star on GitHub and Packagist!
