{"result":{"depiction_url":null,"edges":{"subject":{"objects":[{"created":"2026-10-22T10:23:04Z","object_id":{"id":2555,"is_a":["categorization","keyword","keyword_information_type"],"name":"zotonic_topic_reference","title":"Reference","uri":"https:\/\/zotonic.com\/id\/2555"},"seq":1},{"created":"2026-10-22T10:23:04Z","object_id":{"id":2564,"is_a":["categorization","keyword","keyword_audience"],"name":"zotonic_topic_backend_developer","title":"Backend developer","uri":"https:\/\/zotonic.com\/id\/2564"},"seq":2},{"created":"2026-10-22T10:23:04Z","object_id":{"id":2565,"is_a":["categorization","keyword","keyword_audience"],"name":"zotonic_topic_integrator","title":"Integrator","uri":"https:\/\/zotonic.com\/id\/2565"},"seq":3},{"created":"2026-10-22T10:23:04Z","object_id":{"id":2599,"is_a":["categorization","keyword","keyword_domain"],"name":"zotonic_topic_api_and_integration","title":"API and integration","uri":"https:\/\/zotonic.com\/id\/2599"},"seq":4},{"created":"2026-10-22T10:23:04Z","object_id":{"id":2606,"is_a":["categorization","keyword","keyword_domain"],"name":"zotonic_topic_scheduled_and_background_work","title":"Scheduled and background work","uri":"https:\/\/zotonic.com\/id\/2606"},"seq":5},{"created":"2026-10-22T10:23:04Z","object_id":{"id":2635,"is_a":["categorization","keyword","keyword_architecture"],"name":"zotonic_topic_module","title":"Module","uri":"https:\/\/zotonic.com\/id\/2635"},"seq":6},{"created":"2026-10-22T10:23:04Z","object_id":{"id":2660,"is_a":["categorization","keyword","keyword_data_type"],"name":"zotonic_topic_number","title":"Number","uri":"https:\/\/zotonic.com\/id\/2660"},"seq":7}],"predicate":{"id":308,"is_a":["meta","predicate"],"name":"subject","title":{"_type":"trans","tr":{"en":"Keyword"}},"uri":"http:\/\/purl.org\/dc\/elements\/1.1\/subject"}}},"id":3101,"is_a":["text","documentation","reference","module"],"links":[{"rel":"self","target":"https:\/\/zotonic.com\/.zotonic\/websub\/topic\/3101"},{"rel":"hub","target":"https:\/\/zotonic.com\/.zotonic\/websub"}],"medium":null,"medium_url":null,"name":"doc_external_7_mod_exchange_rates","page_url":{"en":"https:\/\/zotonic.com\/docs\/3101\/mod_exchange_rates","x-default":"https:\/\/zotonic.com\/docs\/3101\/mod_exchange_rates"},"preview_url":null,"resource":{"version":15,"pivot_location_lat":null,"title":"mod_exchange_rates","is_authoritative":true,"body":"<p>Fetch currency exchange rates from the ECB daily XML feed and expose them\nthrough <code>m_exchange_rates<\/code>, the <code>exchange_rates<\/code> template filter and Erlang\nfunctions. Enable <code>mod_exchange_rates<\/code> with its dependency <code>mod_tkvstore<\/code>.\nThere are no module configuration keys or API credentials.<\/p>\n<h2>Updates and rate units<\/h2>\n<p>A per-site server fetches rates asynchronously at startup and on <code>tick_12h<\/code>.\n<code>update(Context)<\/code> requests another asynchronous fetch and returns <code>ok<\/code> before\nit finishes. Rates are normalized to USD: a rate is the number of units of\nthat currency per US dollar, with USD fixed at <code>1.0<\/code>.<\/p>\n<p>After fetching, the server merges in-memory and persisted rates, then writes\nthe result to <code>mod_tkvstore<\/code>. Fresh values override stored values. Handled\nfetch failures retain previous currencies; rates have no exposed timestamp\nor expiry check. Before the initial update finishes, the rates map is empty.<\/p>\n<h2>Erlang interface<\/h2>\n<pre class=\"notranslate\"><code class=\"notranslate language-erlang\">mod_exchange_rates:rate(&lt;&lt;&quot;EUR&quot;&gt;&gt;, Context).\nmod_exchange_rates:convert(100, &lt;&lt;&quot;USD&quot;&gt;&gt;, &lt;&lt;&quot;EUR&quot;&gt;&gt;, Context).\n<\/code><\/pre>\n<p><code>base_currency\/1<\/code> returns <code>&lt;&lt;&quot;USD&quot;&gt;&gt;<\/code>. <code>rates\/1<\/code> returns <code>{ok, Map}<\/code> and\n<code>currencies\/1<\/code> returns <code>{ok, SortedCurrencyCodes}<\/code>. <code>rate\/2<\/code> normalizes the\ncurrency code to uppercase and returns <code>{ok, Rate}<\/code> or\n<code>{error, unknown_currency}<\/code>. USD always has rate <code>1.0<\/code>.<\/p>\n<p><code>convert\/4<\/code> computes <code>Amount \/ FromRate * ToRate<\/code>, rounded using the module&#39;s\ncurrency exponent table (two decimal places by default). It returns\n<code>{ok, Amount}<\/code> or <code>{error, currency_from | currency_to}<\/code> for a missing or\nunavailable currency. Identical source and destination values bypass rate\nlookup and return the input as a float without currency rounding.\nThese data-access functions do not perform ACL checks.<\/p>","slug":"mod_exchange_rates","doc_module_config":[],"is_protected":false,"visible_for":0,"tz":"UTC","language":["en"],"doc_source_hash":"b49cb801b4824f8c32ccb4a28063578ef3184b95e3703b785cd63d6a6dcfb6bc","doc_module_observers":[{"name":"tick_12h","page_name":"doc_notification_tick_12h"}],"is_featured":false,"content_group_id":{"id":2551,"is_a":["meta","content_group"],"name":"content_group_imported_docs","title":"Imported documentation","uri":"https:\/\/zotonic.com\/id\/content_group_imported_docs"},"external_module_id":{"id":7,"is_a":[],"name":null,"title":null,"uri":"https:\/\/zotonic.com\/id\/7"},"git_url":"https:\/\/github.com\/zotonic\/zotonic_mod_exchange_rates.git","category_id":{"id":320,"is_a":["meta","category"],"name":"module","title":"Modules","uri":"https:\/\/test.zotonic.com\/id\/320"},"doc_source_path":".\/src\/mod_exchange_rates.erl","publication_start":"2026-10-22T10:23:04Z","github_url":"https:\/\/github.com\/zotonic\/zotonic_mod_exchange_rates.git","pivot_location_lng":null,"doc_source_kind":"external","name":"doc_external_7_mod_exchange_rates","is_unfindable":false,"is_published":true,"pivot_geocode":null,"external_module_title":"Exchange Rates","created":"2026-10-22T10:23:04Z","uri":null,"doc_status":"current","is_dependent":false,"is_external_module":true,"publication_end":"9999-06-01T00:00:00Z","modifier_id":{"id":1,"is_a":["person"],"name":"administrator","title":"Site Administrator","uri":"https:\/\/zotonic.com\/id\/1"},"privacy":0,"doc_source_commit":"f0bb18d4d2e8937a1b79eb9fe1c2e76082dd717d","creator_id":{"id":1,"is_a":["person"],"name":"administrator","title":"Site Administrator","uri":"https:\/\/zotonic.com\/id\/1"},"modified":"2026-10-22T10:23:05Z","title_slug":"mod_exchange_rates"},"uri":"https:\/\/zotonic.com\/id\/3101","uri_template":"https:\/\/zotonic.com\/id\/:id","websub":{"hub":"https:\/\/zotonic.com\/.zotonic\/websub","topic":"https:\/\/zotonic.com\/.zotonic\/websub\/topic\/3101"}},"status":"ok"}