ECB Exchange Rate Worker
Automatically fetches and updates EUR-based currency exchange rates from the European Central Bank, retrieved as JSON through the Frankfurter API.
Registered automatically by registerCryptoPlugins() / registerAllPlugins().
Registration
import { pluginRegistry } from '@unchainedshop/core';
import { UpdateECBRatesPlugin } from '@unchainedshop/plugins/worker/update-ecb-rates';
pluginRegistry.register(UpdateECBRatesPlugin);
Purpose
The ECB publishes daily reference exchange rates for major currencies against EUR. This worker:
- Fetches the latest ECB reference rates from Frankfurter (
https://api.frankfurter.dev/v2/rates?base=EUR&providers=ecb) - Updates product price rates in the database (rates expire after 24 hours)
The worker needs outbound HTTPS access to api.frankfurter.dev.
Auto-Scheduling
During plugin initialization, this worker schedules itself to run daily at 15:00 in the server's local timezone (cron 0 15 * * *). Set the server's TZ and schedule to match when you want to fetch rates.
Manual Trigger
You can also trigger an update manually:
mutation UpdateRates {
addWork(type: UPDATE_ECB_RATES) {
_id
status
}
}
Supported Currencies
The ECB provides rates for approximately 30 currencies including:
- USD, GBP, JPY, CHF, CAD, AUD
- SEK, NOK, DKK, PLN, CZK, HUF
- And many more
Only currencies that exist in your Unchained system (active or inactive) are updated, and EUR itself must be one of them — otherwise the run is a no-op.
Result
{
"ratesUpdated": 25
}
If EUR is not configured, the result is { "ratesUpdated": 0, "info": "EUR not enabled" } and no request is made.
If Frankfurter responds with an HTTP error or returns no rates, the work fails with UPDATE_ECB_RATES_FAILED (the message names the cause) and is retried.
Adapter Details
| Property | Value |
|---|---|
| Key | shop.unchained.worker.update-ecb-rates |
| Type | UPDATE_ECB_RATES |
| Auto-Schedule | Daily at 15:00 |
| Retries | 5 |
| Source | worker/update-ecb-rates |