Symfony bundle that integrates the UniRate API as an autowired service for currency exchange rates, conversions, and VAT data.
composer require unirate-api/unirate-bundleRegister the bundle in config/bundles.php:
UniRateApi\Bundle\UniRateBundle::class => ['all' => true],Create config/packages/unirate.yaml:
unirate:
api_key: '%env(UNIRATE_API_KEY)%'
# base_url: 'https://api.unirateapi.com' # default
# timeout: 30 # seconds, defaultThe UniRateClient service is autowired automatically:
use UniRateApi\Bundle\UniRateClient;
class CurrencyController
{
public function __construct(private readonly UniRateClient $unirate) {}
public function rate(): Response
{
// Single rate
$rate = $this->unirate->getRate('USD', 'EUR'); // → 0.9234
// All rates for a base
$rates = $this->unirate->getRates('USD'); // → ['EUR' => 0.92, ...]
// Convert amount
$result = $this->unirate->convert(100.0, 'USD', 'EUR'); // → 92.34
// Supported currencies
$currencies = $this->unirate->listCurrencies(); // → ['USD', 'EUR', ...]
// VAT rates
$allVat = $this->unirate->getVatRates(); // all countries
$deVat = $this->unirate->getVatRates('DE'); // Germany only
}
}use UniRateApi\Bundle\UniRateException;
try {
$rate = $this->unirate->getRate('USD', 'EUR');
} catch (UniRateException $e) {
$httpStatus = $e->getStatusCode(); // 401, 403, 404, 429, etc.
$message = $e->getMessage();
}HTTP status codes: 401 = invalid key · 403 = Pro required · 404 = currency not found · 429 = rate limit exceeded.
Free tier: rates, convert, currencies, VAT. Historical data requires Pro.
Distribution via Packagist. Registration is required once at packagist.org — point it at this GitHub repo and GitHub webhooks handle all subsequent updates automatically.
UniRate API client libraries: Python · Node.js · Go · Rust · Ruby · PHP · Java · Swift · .NET
PHP ecosystem: Laravel Money · WordPress · Symfony Bundle (this package)
Framework integrations: Next.js · Nuxt · SvelteKit · Astro · NestJS · Strapi
Data & AI: LangChain Python · FastAPI · Flask · Django REST · dbt · Airflow
Other: MCP server · CLI · Directus · Medusa · Home Assistant
MIT © Unirate Team