# dated\_exchange\_rate in nodejs?

**URL:** <https://community.hubspot.com/t/dated-exchange-rate-in-nodejs/128609>\
**Category:** APIs & Integrations\
**Tags:** professional\
**Created:** [March 25, 2025, 2:08pm UTC](https://community.hubspot.com/t/dated-exchange-rate-in-nodejs/128609 "2025-03-25T14:08:52Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ajinvise](https://avatars.discourse-cdn.com/v4/letter/a/9dc877/32.png) [@ajinvise](https://community.hubspot.com/u/ajinvise)\
**Post date:** [March 25, 2025, 2:08pm UTC](https://community.hubspot.com/t/dated-exchange-rate-in-nodejs/128609/1 "2025-03-25T14:08:52Z")

</div>

When using _calculated properties_ we have access to a **dated\_exchange\_rate** function.How can I replicate that functionallity in a nodejs script?

---

<div class="post-metadata">

**Author:** ![Berangere](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/berangere/32/220784_2.png) [@Berangere](https://community.hubspot.com/u/Berangere)\
**Post date:** [March 26, 2025, 9:47am UTC](https://community.hubspot.com/t/dated-exchange-rate-in-nodejs/128609/2 "2025-03-26T09:47:55Z")

</div>

Hi @ajinvise, I hope that you are well!  
Great question, thanks for asking the HubSpot Community!  
I have found for you this similar post “[[SOLVED] dated\_exchange\_rate formula for calculated property](https://community.hubspot.com/t5/CRM/SOLVED-dated-exchange-rate-formula-for-calculated-property/td-p/891977)” that might help you!  
Let us know if that did the trick for you!  
Have a beautiful day! 🌞  
Warmly,  
Bérangère

---

<div class="post-metadata">

**Author:** ![ajinvise](https://avatars.discourse-cdn.com/v4/letter/a/9dc877/32.png) [@ajinvise](https://community.hubspot.com/u/ajinvise)\
**Post date:** [March 27, 2025, 6:32am UTC](https://community.hubspot.com/t/dated-exchange-rate-in-nodejs/128609/3 "2025-03-27T06:32:36Z")

</div>

Thank you [@BérangèreL](https://community.hubspot.com/t5/user/viewprofilepage/user-id/230185) , though that is in the UI, Im looking for the equivalent when not in the UI, but in code 😊

---

<div class="post-metadata">

**Author:** ![Berangere](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/berangere/32/220784_2.png) [@Berangere](https://community.hubspot.com/u/Berangere)\
**Post date:** [March 27, 2025, 3:40pm UTC](https://community.hubspot.com/t/dated-exchange-rate-in-nodejs/128609/4 "2025-03-27T15:40:56Z")

</div>

Hi @ajinvise, thanks for the clarification!  
I’d love to invite our Top Experts to this discussion: Hi @stefen, @miljkovicmisa and @Teun do you have tips to help @ajinvise use the “dated\_exchange\_rate” in nodejs script, please?  
Have a great day and thanks so much for your help! ❤  
Warmly,  
Bérangère

---

<div class="post-metadata">

**Author:** ![Berangere](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/berangere/32/220784_2.png) [@Berangere](https://community.hubspot.com/u/Berangere)\
**Post date:** [April 10, 2025, 3:43pm UTC](https://community.hubspot.com/t/dated-exchange-rate-in-nodejs/128609/5 "2025-04-10T15:43:44Z")

</div>

Hi @Anton, @Upvise and [@zach\_threadint](https://community.hubspot.com/t5/user/viewprofilepage/user-id/324811), I hope that you are well!  
Do you have any tips to share with @ajinvise to use the “dated\_exchange\_rate” in nodejs script, please?  
Have a lovely day and thanks so much for your valuable contributions!  
Bérangère

---

<div class="post-metadata">

**Author:** ![Upvise](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/upvise/32/17772_2.png) [@Upvise](https://community.hubspot.com/u/Upvise)\
**Post date:** [April 14, 2025, 11:24am UTC](https://community.hubspot.com/t/dated-exchange-rate-in-nodejs/128609/6 "2025-04-14T11:24:57Z")

</div>

Hi @ajinvise

Great question! The dated\_exchange\_rate function in HubSpot’s calculated properties lets you fetch historical exchange rates for currency conversion based on a specific date. There’s no public API directly named dated\_exchange\_rate, but you can replicate the logic in Node.js like this:

**Option 1: Use a 3rd-party exchange rate API**

You’ll need a service that supports historical rates. Examples:

- [ExchangeRate.host](https://exchangerate.host) (free, no API key required)
- [Open Exchange Rates](https://openexchangerates.org)
- [CurrencyStack](https://currencystack.io)
- [Fixer.io](https://fixer.io)

```lia-code-sample
const axios = require('axios');

async function getHistoricalExchangeRate(date, fromCurrency, toCurrency) {
 const url = `https://api.exchangerate.host/${date}?base=${fromCurrency}&symbols=${toCurrency}`;
 const response = await axios.get(url);
 return response.data.rates[toCurrency];
}

// Example usage
getHistoricalExchangeRate('2023-04-10', 'USD', 'EUR')
 .then(rate => {
 console.log(`Exchange rate on 2023-04-10: ${rate}`);
 })
 .catch(console.error);

```

**Then multiply your amount:**

```lia-code-sample
const amountInUSD = 100;
const convertedAmount = amountInUSD * rate;

```

**Option 2: Use HubSpot workflows or Operations Hub custom code action**

If you want to run it _inside_ HubSpot (e.g. using a workflow with a custom code action), you can do the same logic in a @hubspot/api-client script and call an external exchange rate API in there.
