Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Official PHP SDK for OpenExchangeAPI — fetch currency rates and perform conversions using simple, native PHP code.

License

Notifications You must be signed in to change notification settings

OpenExchangeAPI/sdk-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

1 Commit

Repository files navigation

OpenExchangeAPI PHP SDK

Minimal, idiomatic PHP client for OpenExchangeAPI

  • All endpoints supported
  • API key is optional
  • Returns associative arrays for all responses
  • Flexible for use in CakePHP, Laravel, Symfony, or any PHP project

Installation

Just copy OpenExchangeApiClient.php into your project, or use Composer:

composer require openexchangeapi/openexchangeapi-php

Usage

use OpenExchangeApi\OpenExchangeApiClient;
$client = new OpenExchangeApiClient('YOUR_API_KEY'); // API key optional
// Get latest rates
$latest = $client->getLatest();
// Convert currency
$result = $client->convert('USD', 'EUR', 100);
// List currencies
$currencies = $client->listCurrencies();
// Get currency details
$eur = $client->getCurrency('EUR');

API Reference

  • getLatest($base = null)
  • getLatestPrecise($base = null)
  • getHistorical($date, $base = null)
  • getHistoricalPrecise($date, $base = null)
  • convert($from, $to, $amount)
  • convertPrecise($from, $to, $amount)
  • listCurrencies($type = null)
  • getCurrency($code)

All methods throw OpenExchangeApiException on error.

Custom HTTP Client

You can inject your own HTTP client (e.g., Guzzle, CakePHP, Laravel, Symfony):

$client = new OpenExchangeApiClient(null, null, function($url, $params) {
 // ...your HTTP logic...
 return $arrayResponse;
});

Error Handling

All errors throw OpenExchangeApiException:

try {
 $data = $client->getLatest();
} catch (OpenExchangeApiException $e) {
 // Handle error
}

License

MIT

About

Official PHP SDK for OpenExchangeAPI — fetch currency rates and perform conversions using simple, native PHP code.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

AltStyle によって変換されたページ (->オリジナル) /