Search by

unirate-api / sylius-unirate-plugin

unirateapi

Sylius plugin that keeps your store's exchange rates up to date from the UniRate currency-exchange API — autowired client service plus a console command that upserts Sylius ExchangeRate entities.

Package info

github.com/UniRate-API/sylius-unirate

Homepage

Type:sylius-plugin

pkg:composer/unirate-api/sylius-unirate-plugin

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.0 2026-10-21 04:10 UTC

This package is not auto-updated.

Last update: 2026-10-22 02:47:48 UTC


README

Keep your Sylius store's exchange rates up to date from the UniRate currency-exchange API. Sylius stores exchange rates in the database but ships no way to refresh them automatically — this plugin adds an autowired API client plus a console command that upserts your ExchangeRate entities from live UniRate data.

  • 170+ fiat currencies, one free API key from unirateapi.com
  • Autowired UniRateClient service (rates, conversion, currency list)
  • sylius:unirate:update-exchange-rates command — cron-friendly
  • Updates existing pairs in place, preserving their stored direction
  • Zero runtime dependencies beyond Sylius + Symfony contracts

Installation

composer require unirate-api/sylius-unirate-plugin

Register the plugin (Symfony Flex usually does this for you):

// config/bundles.php
return [
    // ...
    UniRateApi\SyliusPlugin\UniRateSyliusPlugin::class => ['all' => true],
];

Configure your API key:

# config/packages/unirate_sylius.yaml
unirate_sylius:
    api_key: '%env(UNIRATE_API_KEY)%'
    # base_url: 'https://api.unirateapi.com'  # optional
    # timeout: 30                             # optional (seconds)
# .env.local
UNIRATE_API_KEY=your-key-from-unirateapi.com

Updating exchange rates

Run against your store's base currency (defaults to USD):

bin/console sylius:unirate:update-exchange-rates EUR

For every currency enabled in the store, the command upserts the exchange rate against the base currency. Schedule it with cron for hands-off rates:

0 * * * * /usr/bin/php /var/www/sylius/bin/console sylius:unirate:update-exchange-rates EUR

Using the client directly

use UniRateApi\SyliusPlugin\UniRateClient;

final class PriceWidget
{
    public function __construct(private readonly UniRateClient $unirate) {}

    public function eurFromUsd(float $usd): float
    {
        return $this->unirate->convert($usd, 'USD', 'EUR');
    }
}

License

Released under the MIT License. Powered by UniRate.