# m\_exchange\_rates

Source: https://zotonic.com/docs/3103/m_exchange_rates

URI: https://zotonic.com/id/3103

Language: en



Read currency rates and convert amounts using the site's `mod_exchange_rates` server. Rates express currency units per USD and may be retained from earlier updates. No ACL check is applied by this model.

| Template path                                | Result                                      |
| -------------------------------------------- | ------------------------------------------- |
| `m.exchange_rates.base_currency`             | Base currency code, `USD`.                  |
| `m.exchange_rates.currencies`                | Sorted list of known binary currency codes. |
| `m.exchange_rates.rates`                     | Map from binary currency codes to rates.    |
| `m.exchange_rates.convert[from][to][amount]` | Converted numeric amount.                   |

For example:

```django
{{ m.exchange_rates.convert["USD"]["EUR"][100] }}
```

The conversion path order is source currency, destination currency, amount. Its Erlang equivalent is `mod_exchange_rates:convert(100, <<"USD">>, <<"EUR">>, Context)`. Conversion follows the rounding rules documented by `mod_exchange_rates`; missing or unavailable currencies return `currency_from` or `currency_to` errors. The `m_get/3` callback wraps successful values as `{ok, {Value, Rest}}` and propagates conversion errors. There is no catch-all clause for unsupported model paths.

License: 

Attribution: 

Related resources: https://zotonic.com/api/agent/related/3103?language=en


## API access

- [API help](<https://zotonic.com/api-help>)
- [OpenAPI specification](<https://zotonic.com/openapi.json>)
- [This resource as JSON](<https://zotonic.com/api/agent/resource/3103?language=en>)
