Overview
The Currency Rates API provides endpoints to retrieve and update USD (Dollar) and EUR (Euro) exchange rates for Venezuelan Bolivares. Rates are fetched from DolarAPI and cached for performance.Caching
- Rates are cached for 1 hour (3600 seconds)
- Cache is automatically invalidated when rates are refreshed
- Fallback rates are used if the database has no active rates:
- USD:
36.50Bs. - EUR:
495.00Bs.
- USD:
Get Dollar Rate
Retrieve the current USD exchange rate from cache or database. This is a public endpoint.Response
Always
trueCurrent USD exchange rate in Bolivares
Get Euro Rate
Retrieve the current EUR exchange rate from cache or database. This is a public endpoint.Response
Always
trueCurrent EUR exchange rate in Bolivares
Refresh Dollar Rate
Fetch the latest USD rate from DolarAPI and propagate it to all active tenants with auto-update enabled.Process Flow
- Fetch rate from
https://ve.dolarapi.com/v1/dolares/oficial - Validate rate is positive and reasonable (max 10% change warning)
- Deactivate previous USD rates in database
- Store new rate with
source: 'dolarapi' - Invalidate cache
- Propagate to all active tenants with
auto_update: true
Response
Whether the operation was successful
The new exchange rate (only on success)
Always
'dolarapi' (only on success)Descriptive message about the operation result
Rate Change Alerts
If the new rate differs from the previous rate by more than 10%, a warning is logged:Refresh Euro Rate
Fetch the latest EUR rate from DolarAPI and propagate it to all active tenants with auto-update enabled.Process Flow
- Fetch rate from
https://ve.dolarapi.com/v1/euros/oficial - Validate rate is positive
- Deactivate previous EUR rates in database
- Store new rate with
source: 'dolarapi' - Invalidate cache
- Propagate to all active tenants with
auto_update: true
Response
Whether the operation was successful
The new exchange rate (only on success)
Always
'dolarapi' (only on success)Descriptive message about the operation result
Auto-Propagation to Tenants
When rates are refreshed, they are automatically propagated to all active tenants that haveauto_update enabled in their currency settings.
Tenant Currency Settings Updated
For USD:Skipping Tenants
Tenants are skipped if:statusis not'active'auto_updateis set tofalse
Implementation Notes
HTTP Timeout
All external API requests use a 10-second timeout to prevent hanging.Database Schema
Rates are stored in thedollar_rates table:
| Column | Type | Description |
|---|---|---|
rate | decimal(10,4) | Exchange rate value |
source | string | Always 'dolarapi' |
currency_type | enum | 'USD' or 'EUR' |
effective_from | timestamp | When rate became active |
effective_until | timestamp | When rate was deactivated |
is_active | boolean | Whether this is the current rate |